• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


ping
#1
Hi,

my TV are connected in my lan. When i turn on my tv, the tv become an ip-adress.
Now i will make a rule
Code:
IF DEVICE TV is connected THEN switch DEVICE lamp TO on
But service pilight start is failed
What is wrong in my rule?
 
Reply
#2
Never tried but the new protocol arping should do this job.
Create a new device TV with protocol arping, (find out the MAC of your TV) and create a rule with this device.
IP can change, the MAC never.
If the MAC of your TV is found the rule executes.

Take a look at the wiki for this.

Edit:
Created a config for testing arping to integrate in the gui.
Maybe you can need:
Code:
    "devices": {
        "tvlampe": {
            "protocol": [ "relay" ],
            "id": [{
                "gpio": 2
            }],
            "state": "off"
        },
        "tvcheck": {
            "protocol": [ "arping" ],
            "id": [{
                "mac": "xx:xx:xx:xx:xx:xx"
            }],
            "ip": "x.x.x.x",
            "state": "disconnected"
        },
        "tvstate": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 30
            }],
            "state": "off"
        },
        "tvrule": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 31
            }],
            "state": "on"
        }
    },
    "rules": {
        "tv-check_on": {
            "rule": "IF tvrule.state IS on AND tvcheck.state IS connected AND tvstate.state IS off THEN switch DEVICE tvstate TO on",
            "active": 1
        },
        "tv-check_off": {
            "rule": "IF tvrule.state IS on AND tvcheck.state IS disconnected AND tvstate.state IS on THEN switch DEVICE tvstate TO off",
            "active": 1
        },
        "switch_tv_lamp": {
            "rule": "IF tvrule.state IS on AND tvcheck.state IS connected AND tvstate.state IS on AND tvlampe.state IS off THEN switch DEVICE tvlampe TO on",
            "active": 1
        }
    },
    "gui": {
        "tvrule": {
            "name": "TV aut. Regelung",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ]
        },
        "tvstate": {
            "name": "TV Status",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ],
            "readonly": 1
        },
        "tvlampe": {
            "name": "TV Lampe",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ]
        }
    },
    "settings": {
        "log-level": 4,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "send-repeats": 10,
        "receive-repeats": 1,
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-port": 5001,
        "webserver-cache": 1,
        "firmware-update": 0
    },
    "hardware": {
        "433gpio": {
            "sender": 0,
            "receiver": 1
        }
    },
    "registry": {
        "webgui": {
            "tabs": 1
        },
        "pilight": {
            "version": {
                "current": "5.0"
            }
        }
    }
}

@curlymo: Does the arping protocol really need MAC AND IP?
What when using DHCP and the IP changes?
 
Reply
#3
Somehow the arping protocol wont work as it should?
Tried to find if a device is online but state does not change to connected.
 
Reply
#4
@terrar, the arping device doesn't need the ip for lookup. It updates the ip value itself with the last known ip associated with the mac address. The problem with this protocol is that it's more open to errors than the plain ping protocol. I derived the source from arp-scan. Can you check if that program does work for you?

@chief-wiggem, your rule doesn't look anything like the rule structure pilight uses. Please carefully read the pilight nightly pages on the pilight website.
 
Reply
#5
The arping protocol works for me now.
No matter why it did not work yesterday.
 
Reply
#6
OK here are my config

The Device one is:
Code:
        "tageslicht": {
            "protocol": [ "elro_hc" ],
            "id": [{
                "systemcode": 15,
                "unitcode": 29
            }],
            "state": "off"
        },
         "tvcheck": {
            "protocol": [ "ping" ],
            "id": [{
                "ip": "192.168.178.113"
                }],
            "state": "connected"
        },
.....

The Rules one is:
Code:
            "tvan": {
            "rule": "IF tvcheck.state IS connected THEN switch DEVICE tageslicht TO on",
            "active": 1
        }
the IP of my TV is a static ip.
The TV become only the IP when i turn on the tv
with this config i can start the Oilight deamon but when i turn on my tv the light dosent go on
 
Reply
#7
If you run pilight-receive do you see the tvcheck.state change?
 
Reply
#8
no there is nothing

a normal
Code:
ping 192.168.178.113
in the console of the raspberry works
 
Reply
#9
Is this a wrong configuration from me or is it something else?
 
Reply
#10
In your configuration file set the default value to disconnected

You are constantly firing ON commands to your switch,
only do that once:
- when it is OFF and your TV is on - turn it ON.
- when it is ON and your TV is off - turn it OFF.

"IF tvcheck.state IS connected AND Television.state IS off THEN switch DEVICE Television TO on",

"IF tvcheck.state IS disconnected AND Television.state IS on THEN switch DEVICE Television TO off",
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)