Make your presence known
Moderator: leecollings
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Make your presence known
Probably not the first to explain this, but I did a quick search and didn't really found anything.
So here goes:
I wanted to make my presence know at home for Domoticz.
Did some research on this forum and found a Python script that looks for an IP in the network. If found, your presence is know.
But, this didn't really go well, probably an outdated script.
So, I looked for something else.
I remembered I had the app Automate (https://play.google.com/store/apps/deta ... b.automate) installed on my phone and began thinking about a way to make my presence know with this and quickly saw my Wi-Fi connection as a good presence status.
I made this:
- I have a dummy On/Off switch in Domoticz "MyPresence"
- When Wi-Fi status changed, check connected to "MyWifiName"?
- Yes: HTTP request to JSON url "MyPresence" On
- No: HTTP request to JSON url "MyPresence" Off
The Events I made in Domoticz are now made with the check if "MyPresence" is on or off.
In example, when I'm home, our livingroom lights turn on when my dusk sensor goes On.
Now, with this setup: The lights won't go on when me or my girlfriend aren't at home.
Also, when everybody is gone, all lights will turn off automatically.
I hope this has some use for someone!
If you want to know more, I could post some screenshots if you want.
I've had some people asking me how I made this in Automate, so I made this explanation:
HOWTO This 'flow' has been running for days without stopping, so it's pretty stable as far as I can see.
So here goes:
I wanted to make my presence know at home for Domoticz.
Did some research on this forum and found a Python script that looks for an IP in the network. If found, your presence is know.
But, this didn't really go well, probably an outdated script.
So, I looked for something else.
I remembered I had the app Automate (https://play.google.com/store/apps/deta ... b.automate) installed on my phone and began thinking about a way to make my presence know with this and quickly saw my Wi-Fi connection as a good presence status.
I made this:
- I have a dummy On/Off switch in Domoticz "MyPresence"
- When Wi-Fi status changed, check connected to "MyWifiName"?
- Yes: HTTP request to JSON url "MyPresence" On
- No: HTTP request to JSON url "MyPresence" Off
The Events I made in Domoticz are now made with the check if "MyPresence" is on or off.
In example, when I'm home, our livingroom lights turn on when my dusk sensor goes On.
Now, with this setup: The lights won't go on when me or my girlfriend aren't at home.
Also, when everybody is gone, all lights will turn off automatically.
I hope this has some use for someone!
If you want to know more, I could post some screenshots if you want.
I've had some people asking me how I made this in Automate, so I made this explanation:
HOWTO This 'flow' has been running for days without stopping, so it's pretty stable as far as I can see.
Last edited by MatthijsD on Friday 07 April 2017 11:05, edited 1 time in total.
- Siewert308SW
- Posts: 290
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Make your presence known
The script linked below does the trick for me for over 1.5 year
https://www.domoticz.com/wiki/Presence_detection
https://www.domoticz.com/wiki/Presence_detection
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Make your presence known
That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm havingSiewert308SW wrote:The script linked below does the trick for me for over 1.5 year
https://www.domoticz.com/wiki/Presence_detection

But, I'm pretty happy with solution mentioned above

- Siewert308SW
- Posts: 290
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Make your presence known
Could be more specific, what issues?MatthijsD wrote:That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm havingSiewert308SW wrote:The script linked below does the trick for me for over 1.5 year
https://www.domoticz.com/wiki/Presence_detection
But, I'm pretty happy with solution mentioned above
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Make your presence known
After running the script, I get this:Siewert308SW wrote:Could be more specific, what issues?MatthijsD wrote:That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm havingSiewert308SW wrote:The script linked below does the trick for me for over 1.5 year
https://www.domoticz.com/wiki/Presence_detection
But, I'm pretty happy with solution mentioned above
Code: Select all
23:27:13- pid file exists
23:27:13- Seems to be an old file, ignoring.
23:27:13- script started.
Traceback (most recent call last):
File "check_device_online.py", line 101, in <module>
lastreported = domoticzstatus()
File "check_device_online.py", line 79, in domoticzstatus
json_object = json.loads(domoticzrequest(domoticzurl))
File "check_device_online.py", line 96, in domoticzrequest
response = urllib2.urlopen(request)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

- Siewert308SW
- Posts: 290
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Make your presence known
Looks like your copy/past from a windows box to Pi.
Unzip and upload the script to your pi and see if it solves the errors.
Unzip and upload the script to your pi and see if it solves the errors.
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Make your presence known
Thnx, I'll give it another try.Siewert308SW wrote:Looks like your copy/past from a windows box to Pi.
Unzip and upload the script to your pi and see if it solves the errors.
eth_device_online.zip
It's not on a Pi, but on a Synology NAS tho.
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Make your presence known
Siewert308SW wrote:Looks like your copy/past from a windows box to Pi.
Unzip and upload the script to your pi and see if it solves the errors.
eth_device_online.zip
Code: Select all
17:23:26- script started.
Traceback (most recent call last):
File "check_device_online.py", line 101, in <module>
lastreported = domoticzstatus()
File "check_device_online.py", line 79, in domoticzstatus
json_object = json.loads(domoticzrequest(domoticzurl))
File "check_device_online.py", line 96, in domoticzrequest
response = urllib2.urlopen(request)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>

- Siewert308SW
- Posts: 290
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Make your presence known
I see, so your running a Synology box.MatthijsD wrote:Siewert308SW wrote:Looks like your copy/past from a windows box to Pi.
Unzip and upload the script to your pi and see if it solves the errors.
eth_device_online.zipCode: Select all
17:23:26- script started. Traceback (most recent call last): File "check_device_online.py", line 101, in <module> lastreported = domoticzstatus() File "check_device_online.py", line 79, in domoticzstatus json_object = json.loads(domoticzrequest(domoticzurl)) File "check_device_online.py", line 96, in domoticzrequest response = urllib2.urlopen(request) File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 429, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 447, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno 111] Connection refused>
My best guess thats the issue, correct me if i'm wrong but a Synology box needs a other approach on this script.
Who has a Synology and runs this script and can help this guy out?
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 45
- Joined: Sunday 19 March 2017 11:48
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Make your presence known
I used a tutorial for Synology, that used the same script: https://www.domoticz.com/forum/viewtopi ... =28&t=9921Siewert308SW wrote: I see, so your running a Synology box.
My best guess thats the issue, correct me if i'm wrong but a Synology box needs a other approach on this script.
Who has a Synology and runs this script and can help this guy out?
But, help is welcome.
The Automate app is pretty good, but error sensitive

Who is online
Users browsing this forum: No registered users and 0 guests