Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

All kinds of 'OS' scripts

Moderator: leecollings

Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by Prutsium »

Damn .... this created a Kazillion log entries as every time it sets the switch off and on .......
Somehow i liked the iDetect way but thats history as the Asus went out :)

So back to the roots and looking for a other way.
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

Prutsium wrote: Tuesday 27 August 2019 9:28 Damn .... this created a Kazillion log entries as every time it sets the switch off and on .......
Somehow i liked the iDetect way but thats history as the Asus went out :)

So back to the roots and looking for a other way.
Wich Logging do you mean it can be switched off
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by Prutsium »

funky wrote: Tuesday 27 August 2019 9:47 Wich Logging do you mean it can be switched off
I have about 60K log entries from this setup ;)
Seems it cant be turned off .....

Image
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by Prutsium »

Ps ... this happens when a phone is present:
Image

Seems the switch is everytime also triggered On/Off .....
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

Prutsium wrote: Tuesday 27 August 2019 10:21 Ps ... this happens when a phone is present:
Image

Seems the switch is everytime also triggered On/Off .....
Is this your présence switch? Or phone switch. My phone switch is logging only for about 5 times a day when i arrive or leave the house
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by Prutsium »

funky wrote: Tuesday 27 August 2019 11:12 Is this your présence switch? Or phone switch. My phone switch is logging only for about 5 times a day when i arrive or leave the house
It's the presence switch and it's flooding the logs by every time on/off when a phone is there.
(The phone is not flipping like this :))
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by AllesVanZelf »

Hi Prutsium,
You made a mistake in your blockly.That is why your log is running wild.
If presence is {on} AND ( phone1 = {off) AND phone2 = {off} AND phone3 = {off} )
Do presence is {Off}

Like in my earlier post:

Code: Select all

If 'Anyone home' = Off AND Phone1 = On OR Phone2 = On OR Phone3 = On
Set 'Anyone home = On
Else If 'Anyone home' = On AND Phone1 = Off AND Phone2 = Off AND Phone3 = Off
Set 'Anyone home = Off
The Or's between the phones should be AND's. Otherwise Else If is almost always true
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by Prutsium »

AllesVanZelf wrote: Tuesday 27 August 2019 17:09 Hi Prutsium,
You made a mistake in your blockly.That is why your log is running wild.
If presence is {on} AND ( phone1 = {off) AND phone2 = {off} AND phone3 = {off} )
Do presence is {Off}

Like in my earlier post:

Code: Select all

If 'Anyone home' = Off AND Phone1 = On OR Phone2 = On OR Phone3 = On
Set 'Anyone home = On
Else If 'Anyone home' = On AND Phone1 = Off AND Phone2 = Off AND Phone3 = Off
Set 'Anyone home = Off
The Or's between the phones should be AND's. Otherwise Else If is almost always true
Thanks thought already so as it's easy to mess up in Blockly.
Will check this when back home but based on the manual trigger it looks like it's not spamming the log :)
pauwauw
Posts: 2
Joined: Monday 23 December 2019 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by pauwauw »

Hi,

New forum user here. Apologies beforehand if any question I ask was already answered. I did search the forum and could not find them, so here it goes.
First, love the concept of this script. The wizard-like setup especially.

I encounter two issues. First, my domoticz (rpi) is user/password protected at login. I found I had to remove that protection to make this script work. The passcode for lightswitch protection entered in the config was not sufficient. Is there a way to pass username/password along with the domoticz URL? Is their a required syntax? Or is there another line required in the config.txt?

Second. I find that my devices are seen as on, even when no longer active on WLAN. Is this because of my specific Fritz boxes (7360 router and 4040 repeater)? This script is able to query the WLAN table, finds the devices, but sees them as active, while fritz.box console shows them as not connected. Is there something I am doing wrong?

Here is the debug output from manually running the script after I manually set both dummy devices to OFF in domoticz

------------------------------------------------------------
Presence detection for Domoticz using Fritzbox version 2.3
------------------------------------------------------------

checking:iPhonePaul
Mon 23 Dec 10:02:43 UTC 2019status router is not simular to status domoticz. We change status domoticz for iPhonePaul to On
debug information:
status domoticz:
Off
-----------------------
status fritzbox:

FritzHosts:
version: 0.6.2
model: FRITZ!Box Fon WLAN 7360
ip: 192.168.178.1

Details for host: ***MAC1***

NewActive : 1
NewIPAddress : 192.168.178.96
NewInterfaceType : 802.11
NewHostName : iPhonevPBijlsma
NewAddressSource : DHCP
NewLeaseTimeRemaining : 0
-----------------------
status repeater:

FritzHosts:
version: 0.6.2
model: FRITZ!Box 4040
ip: 192.168.178.49

Details for host: ***MAC1***

NewActive : 0
NewIPAddress : 192.168.178.96
NewInterfaceType : None
NewHostName : d1109fcc-c9e4-48e8-87fa-3601136c4d3b1
NewAddressSource : Static
NewLeaseTimeRemaining : 0
-----------------------
checking:iPhoneMachteld
Mon 23 Dec 10:02:56 UTC 2019status router is not simular to status domoticz. We change status domoticz for iPhoneMachteld to On
debug information:
status domoticz:
Off
-----------------------
status fritzbox:

FritzHosts:
version: 0.6.2
model: FRITZ!Box Fon WLAN 7360
ip: 192.168.178.1

Details for host: ***MAC2***

NewActive : 0
NewIPAddress : 192.168.178.50
NewInterfaceType : 802.11
NewHostName : iMCV5s
NewAddressSource : DHCP
NewLeaseTimeRemaining : 0
-----------------------
status repeater:

FritzHosts:
version: 0.6.2
model: FRITZ!Box 4040
ip: 192.168.178.49

Details for host: ***MAC2***

NewActive : 1
NewIPAddress : None
NewInterfaceType : Ethernet
NewHostName : iMCV5s
NewAddressSource : Static
NewLeaseTimeRemaining : 0
-----------------------
dependencies installed:
installed python version:
Python 2.7.16
installed JQ version:
jq-1.5-1-a5b5cbe
---------------------

config file variables:
---------------------
ip_fritzbox=192.168.178.1
pass_fritzbox=******
ip_repeater=192.168.178.49
ip_domoticz=192.168.178.27:8080
domoticzpasscode=
device_names=(iPhonePaul iPhoneMachteld)
device_macs=(***MAC1*** ***MAC2***)
device_idx=(459 460)
---------------------
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

hi Paul

Some questions first:

1. As i can see the script is retrieving information from domoticz, that works. But does the script setting your dummy switches correctly? Are the idx ok? Maybe something went wrong bij making the dummie switches by the scripts since your Domoticz was password protected?.
2. The script works also with the WLAN table in your example the New active:1 means that its online and the Newactive:0 means it’s offline. Sometimes there is a lag of a minute. Or the repeater ip is not set.

What you can do it remove the dummy switches inside Domoticz, remove the config.txt , remove the password protection of the lightswitches. And do a reinstall.

After that run in debug mode and see if there are any errors. If so you can send me an pm with the complete logfile and I will look to it.

There is also a complete faq on: https://github.com/hydex80/presence_det ... /README.md
pauwauw
Posts: 2
Joined: Monday 23 December 2019 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by pauwauw »

funky wrote: Monday 23 December 2019 13:25 1. As i can see the script is retrieving information from domoticz, that works. But does the script setting your dummy switches correctly? Are the idx ok? Maybe something went wrong bij making the dummie switches by the scripts since your Domoticz was password protected?.
Yes, it created the dummy switches after I disabled username/password protection of domoticz. However, I need that to be enabled, because I also access Domoticz from outside my network

funky wrote: Monday 23 December 2019 13:25 2. The script works also with the WLAN table in your example the New active:1 means that its online and the Newactive:0 means it’s offline. Sometimes there is a lag of a minute. Or the repeater ip is not set.
The repeater IP is set. Problem was is set my devices to active while the fritz console shows them as not connected (also after 1 hour). The script is able to find the correct switches, because when I manually change the value to OFF (in domoticz webgui) the script will change them back to active/ON (as shown in de debug I shared)
funky wrote: Monday 23 December 2019 13:25 What you can do it remove the dummy switches inside Domoticz, remove the config.txt , remove the password protection of the lightswitches. And do a reinstall.
I do not have password protection on the switches, I have password protection on Domoticz login.

I would like to know if username/password can be passed along (not just the password for switch protection). If not, I am afraid I won't be able to use the script.

I would send you a PM, but as a new member I am not allowed ;-)
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

Send you a pm
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

Did you managed it to work.

Set in my own domesticz user name and password protection and script seems to work.

Please try:

Code: Select all

http://domoticz ip/json.html?type=commandtype=command&param=switchlight&idx=<IDX OFF DEVICE YOU WANT TO SET&switchcmd=<ON of OFF>&passcode=Lightswitch pasword. 
For example:

Code: Select all

http://192.168.178.33:8080/json.htm?type=command&param=switchlight&idx=494&switchcmd=Off&passcode=test1234
if you get:

{
"status" : "OK",
"title" : "SwitchLight"
}

it should be working. otherwise plz post here error code.
florisi
Posts: 78
Joined: Saturday 30 July 2016 10:14
Target OS: Linux
Domoticz version: 2020beta
Location: Arnhem
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by florisi »

Hello,

i'm running Domoticz on a Synology.
How can I install this on a Synology.
When I start the installer it says Dependencies should be installed, but then I got an error about apt-get.

What to do?

Thanks
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

florisi wrote: Sunday 29 December 2019 14:02 Hello,

i'm running Domoticz on a Synology.
How can I install this on a Synology.
When I start the installer it says Dependencies should be installed, but then I got an error about apt-get.

What to do?

Thanks
You can try pip to install the dependencies manually:

pip install python
pip install lxml

pip install jq

pip install requests

Or you can try easy install
easy install python
Easy install lxml
Easy install jq
Easy install requests
florisi
Posts: 78
Joined: Saturday 30 July 2016 10:14
Target OS: Linux
Domoticz version: 2020beta
Location: Arnhem
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by florisi »

both commands 'pip' and 'easy' are not recognized.
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

And easy_install

Forgot the underscore

And if that’s not working install pip first
http://domoticx.com/synology-nas-python ... stalleren/
florisi
Posts: 78
Joined: Saturday 30 July 2016 10:14
Target OS: Linux
Domoticz version: 2020beta
Location: Arnhem
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by florisi »

Easy_install did the job.
But still got an error on jq:

Code: Select all

checking for cl.exe... no
configure: error: in `/tmp/easy_install-AUWES3/jq-0.1.6/onig-5.9.6':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Traceback (most recent call last):
  File "/bin/easy_install", line 9, in <module>
    load_entry_point('setuptools==25.1.6', 'console_scripts', 'easy_install')()
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 2271, in main
    **kw
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 409, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 664, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 694, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 875, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1114, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1100, in run_setup
    run_setup(setup_script, args)
  File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 249, in run_setup
    raise
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
    yield
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 168, in save_modules
    saved_exc.resume()
  File "/usr/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 142, in resume
    type, exc = map(pickle.loads, self._saved)
  File "/usr/lib/python2.7/pickle.py", line 1388, in loads
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 864, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1139, in load_reduce
    value = func(*args)
TypeError: __init__() takes at least 3 arguments (1 given)[/quote][/quote]
funky
Posts: 74
Joined: Saturday 06 May 2017 22:38
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Zeist, Netherlands
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by funky »

Maybe try to install pip first and try to install it then. I self don’t have a synalogy. I see they are using custom Linux distribution. So im not sure if it works. But you can try. If it works plz let us know. Good luck
percy159
Posts: 2
Joined: Thursday 17 October 2019 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Presence detection for Fritzbox script v2.0: using TR064 protocol communication to your router

Post by percy159 »

Hey,

i have the same issue on my System.
I managed to get the System working on System1 without User&Password.
But how can i fix the issue on System2 where i have a User&Password?

Best wishes,
percy

P.S.:
A perfect Tool how far i could do some test!
Perfect documentation and a easy installation guide.
pauwauw wrote: Tuesday 24 December 2019 12:17
I do not have password protection on the switches, I have password protection on Domoticz login.

I would like to know if username/password can be passed along (not just the password for switch protection). If not, I am afraid I won't be able to use the script.

I would send you a PM, but as a new member I am not allowed ;-)
Post Reply

Who is online

Users browsing this forum: MikeVanD and 1 guest