Make your presence known

Post Reply
MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Make your presence known

Post by MatthijsD » Friday 31 March 2017 15:30

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
Automate.jpg
Automate.jpg (366.47 KiB) Viewed 739 times
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.

User avatar
Siewert308SW
Posts: 471
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Make your presence known

Post by Siewert308SW » Friday 31 March 2017 16:02

The script linked below does the trick for me for over 1.5 year

https://www.domoticz.com/wiki/Presence_detection
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Make your presence known

Post by MatthijsD » Friday 31 March 2017 16:30

Siewert308SW wrote:The script linked below does the trick for me for over 1.5 year

https://www.domoticz.com/wiki/Presence_detection
That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm having :(
But, I'm pretty happy with solution mentioned above :)

User avatar
Siewert308SW
Posts: 471
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Make your presence known

Post by Siewert308SW » Friday 31 March 2017 16:33

MatthijsD wrote:
Siewert308SW wrote:The script linked below does the trick for me for over 1.5 year

https://www.domoticz.com/wiki/Presence_detection
That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm having :(
But, I'm pretty happy with solution mentioned above :)
Could be more specific, what issues?
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Make your presence known

Post by MatthijsD » Friday 31 March 2017 19:00

Siewert308SW wrote:
MatthijsD wrote:
Siewert308SW wrote:The script linked below does the trick for me for over 1.5 year

https://www.domoticz.com/wiki/Presence_detection
That's the one I'm talking about, but unfortunately my knowledge on Python is to low to fix the issues I'm having :(
But, I'm pretty happy with solution mentioned above :)
Could be more specific, what issues?
After running the script, I get this:

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
I had more errors, but this is as far as my knowledge goes (and my patience) ;)

User avatar
Siewert308SW
Posts: 471
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Make your presence known

Post by Siewert308SW » Friday 31 March 2017 19:40

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
(2.15 KiB) Downloaded 20 times
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Make your presence known

Post by MatthijsD » Wednesday 05 April 2017 16:50

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
Thnx, I'll give it another try.
It's not on a Pi, but on a Synology NAS tho.

MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Make your presence known

Post by MatthijsD » Wednesday 05 April 2017 17:25

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>
:cry:

User avatar
Siewert308SW
Posts: 471
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Make your presence known

Post by Siewert308SW » Wednesday 05 April 2017 17:28

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.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>
:cry:
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?
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

MatthijsD
Posts: 38
Joined: Sunday 19 March 2017 12:48
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Make your presence known

Post by MatthijsD » Wednesday 05 April 2017 18:18

Siewert308SW 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?
I used a tutorial for Synology, that used the same script: https://www.domoticz.com/forum/viewtopi ... =28&t=9921
But, help is welcome.
The Automate app is pretty good, but error sensitive :(

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests