• 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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using generic_switch as variable / presence detection by "ping"
#1
Trying to implement presence detection by ping I am using two "generic_switch" as variables in rules.

1. generic_switch flags whether somebody has just reached home.
2. generic_switch flags whether somebody is already at home.

1. rule checks if somebody is arriving at home. If so generic switch "jemand_gekommen" is set to "on".
2. rule checks whether "jemand_gekommen.state" is "on". If so device "Stehlampe" is switched to "on" and generic switch "jemand_da" is set to "on" flagging now that somebody is already at home.
3. rule is used to "reset" the generic_switches.

The rules seem to work. Smile
But if I switch off device "Stehlampe" manually using the remote control after a while (3-4 minutes) strangewise it becomes "on" again though device "mobile_tom" is still in state "connected".Angry

Any idea how to solve this?

Code example:
Code:
{
    "devices": {
        "jemand_gekommen": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 1234
            }],
            "state": "on"
        },
        "jemand_da": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 5678
            }],
            "state": "on"
        },
        "Stehlampe": {
            "protocol": [ "rsl366" ],
            "id": [{
                "systemcode": 4,
                "programcode": 3
            }],
            "state": "on"
        },
        "mobile_tom": {
            "protocol": [ "ping" ],
            "id": [{
                "ip": "192.168.178.38"
            }],
            "state": "connected"
        }
    },
    "rules": {
        
        "jemand_gekommen": {
            "rule": "IF mobile_tom.state IS connected THEN switch DEVICE jemand_gekommen TO on",
            "active": 1
        },
        "lampe_an": {
            "rule": "IF jemand_gekommen.state IS on AND jemand_da.state IS off THEN switch DEVICE Stehlampe TO on AND switch DEVICE jemand_da TO on",
            "active": 1
        },
    "reset": {
            "rule": "IF mobile_tom.state IS disconnected THEN switch DEVICE jemand_gekommen TO off AND switch DEVICE jemand_da TO off",
            "active": 1
        }        
    },
 
Reply
#2
Can you post the rest of your config?
 
Reply
#3
Sure!
Here it is:

Code:
{
    "devices": {
        "jemand_gekommen": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 1234
            }],
            "state": "on"
        },
        "jemand_da": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 5678
            }],
            "state": "on"
        },
        "Stehlampe": {
            "protocol": [ "rsl366" ],
            "id": [{
                "systemcode": 4,
                "programcode": 3
            }],
            "state": "on"
        },
        "mobile_tom": {
            "protocol": [ "ping" ],
            "id": [{
                "ip": "192.168.178.38"
            }],
            "state": "connected"
        }
    },
    "rules": {    
        "jemand_gekommen": {
            "rule": "IF mobile_tom.state IS connected THEN switch DEVICE jemand_gekommen TO on",
            "active": 1
        },
        "lampe_an": {
            "rule": "IF jemand_gekommen.state IS on AND jemand_da.state IS off THEN switch DEVICE Stehlampe TO on AND switch DEVICE jemand_da TO on",
            "active": 1
        },
    "reset": {
            "rule": "IF mobile_tom.state IS disconnected THEN switch DEVICE jemand_gekommen TO off AND switch DEVICE jemand_da TO off",
            "active": 1
        }        
    },
"gui": {
        "jemand_gekommen": {
            "name": "jemand_gekommen",
            "group": [ "Misc" ],
            "media": [ "all" ],
            "readonly": 0
        },
        "jemand_da": {
            "name": "jemand_da",
            "group": [ "Misc" ],
            "media": [ "all" ],
            "readonly": 0
        },
        "Stehlampe": {
            "name": "Stehlampe",
            "group": [ "Wohnzimmer" ],
            "media": [ "all" ],
            "readonly": 0
        }
    },
    "settings": {
        "ntp-servers": [ "0.de.pool.ntp.org", "1.de.pool.ntp.org" ],
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-http-port": 5001,
        "webserver-cache": 1
    },
    "hardware": {
        "433gpio": {
            "sender": 0,
            "receiver": 1
        }
    },
    "registry": {
        "webgui": {
            "tabs": 0
        },
        "pilight": {
            "version": {
                "current": "7.0"
            }
        }
    }
}
 
Reply
#4
This is a known problem with the ping protocol, for which wo_rasp made a solution in the form of a "try" option that reduces (but not completely solves) the problem of false disconnects.

See this thread
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  invalid: trying to compare string variable "arctech_switch.unit" to an integer diman87 5 2,540 12-19-2017, 11:04 PM
Last Post: diman87
  variable "label" not allowed in rules Niek 4 2,528 09-30-2017, 06:39 PM
Last Post: curlymo
  DATE_FORMAT → invalid: trying to compare string variable "21:30:00" to an integer PekkaLahtela 6 3,912 12-22-2016, 09:49 AM
Last Post: wo_rasp
  invalid: trying to compare string variable "datetime.minute" to an integer raj 1 1,783 05-02-2016, 10:50 AM
Last Post: Niek
  ERROR: rule #21 invalid: variable "label" of device "WindMax" cannot be used in even koos147 2 1,829 04-02-2016, 10:24 PM
Last Post: koos147
  rule #1 invalid: trying to compare string variable "datetime.hour" to an integer Michel 2 1,879 12-16-2015, 09:45 PM
Last Post: Michel
  multiple use of ping protocol bastelwastel 3 2,105 10-11-2015, 02:42 AM
Last Post: wo_rasp
  help needed: ping rule not working meloen 4 3,185 02-25-2015, 12:55 AM
Last Post: meloen

Forum Jump:


Browsing: 1 Guest(s)