Skip to content

domoticz plugin to check and show presence via data from Fritz!Box router

License

Notifications You must be signed in to change notification settings

schurgan/domoticz-FritzPresence

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

domoticz-FritzPresence

PyPI pyversions Plugin version

Primary a Presence Detector that works with your Fritz!Box. And also lets you add easily other known hosts from your Box to Domoticz.

Attention: With Version 0.7.0 Parameter have changed. So adapt user and password if updating from <0.7.0!
Device Image Comment
Admin admin Here you can add know hosts from your router to Domoticz, or remove them all.
User switch device - on
switch device - off
User is shown like this in domoticz. There might come from admin:add function or straight form the settings MAC Address
IoT iot - on If the device name matches the naming rule IOT_NAME_PREFIXES, the IOT picture will be used for it
Notebook notebook - on If the device name matches the naming rule ICON_NOTEBOOK_PREFIXES,
Pi Pi - on If the device name matches the naming rule ICON_PI_PREFIXES, the Raspberry Pi picture will be used for it
Phone iot - on If the device name matches the naming rule ICON_PHONE_PREFIXES, the Mobile picture will be used for it
Tablet/Pad iot - on If the device name matches the naming rule ICON_TAB_PREFIXES, the Pad picture will be used for it
TV iot - on If the device name matches the naming rule ICON_TV_PREFIXES, the TV picture will be used for it

Summary

Originally this plugin was just for presence detection. But as I needed a bit more functions from fritzconnection, I extended it step by step.

Instead of pinging the device this presence detector uses the host list from the router to check if device is there or not. Benefit - Normally this also works if devices like smart phones save some battery.

Note: If connection between router and device got lost, this can take some time till router marks it as 'not connected' This plugin only works with Fritz Box.

This plugin is open source.

This is a wrapper around python lib fritzconnection from Klaus Bremer. Person Images are from DomoticzIcons, Domoticz Icon from Domoticz Wiki and Raspberry Pi from Raspberry Foundation.

Prepare

  • set up your Fritz!Box
    • enable TR064
    • create a user
    • set password
    • assign rights to this user

Installation and Setup

  • a running Domoticz: 2020.2 or 2021.1 with Python 3.7
  • Python >= 3.7 (mainly depending on requirements for fritzconnection)
  • install needed python modules:
    • fritzconnection version 1.4.0
    • urllib3
    • or even better use sudo pip3 install -r requirements.txt
    • might be worth testing fritzconnection - just run fritzconnection
  • clone project
    • go to domoticz/plugins directory
    • clone the project
      cd domoticz/plugins
      git clone https://github.com/belzetrigger/domoticz-FritzPresence.git
  • or just download, unzip and copy to domoticz/plugins
  • optional: adapt naming convention
    • what does it do: tries to scan name for this device for special chunks and pick different images for them
    • where: plugin.py
    • what: eg ICON_PI_PREFIXES = ["RASPBERRY", "PI"] will cause all devices containing PI to use raspberry image
  • no need on Raspbian for sys path adaption if using sudo for pip3
  • some extra work for Windows or Synology, make sure downloaded modules are in path eg. site-packages python paths or change in plugin.py / fritzHelper.py path
    • example adaption:
      import sys
      sys.path
      sys.path.append('/usr/lib/python3/dist-packages')
      # for synology python3 from community
      # sys.path.append('/volume1/@appstore/python3/lib/python3.5/site-packages')
      # for synology sys.path.append('/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages')
      # for windows check if installed packages as admin or user...
      # sys.path.append('C:\\Program Files (x86)\\Python37-32\\Lib\\site-packages')
  • restart Domoticz service
  • Now go to Setup, Hardware in your Domoticz interface. There add Fritz!Presence Plugin.

Settings

Parameter Information
name Domoticz standard hardware name.
Note: No support of setting device name over this field. Since 0.7.0 name is fetched from Fritz!Box.
host insert host name or IP Address of your fritz box. Normally fritz.box
user the user you have set up in your FritzBox
password keep in mind, domoticz stores it plain in the database!!!! So really create a new user with restricted rights
domoticz port this is the local port used for calling domoticz JSON-API to update device names with the value from Fritz!Box
MAC Addresses can hold a single or multiple ';' separated list of MAC addresses
config: mac with two entries
Note: If you have a lot MACs you wish to add, it is better to use the admin panel to add known devices straight from Fritz!Box.
Debug if True, the log will be hold a lot more output.

Usage

Admin

this functions are supported

  • add WiFi devices
  • add ethernet devices
  • add active devices
  • add all known devices

Keep in mind, normally a device must have been recent active to have a connection type. Also VPN devices are special, as they might not have a MAC-Address.

Wake on LAN

To send magic packet just click on an off device to switch it on. WOL works only for ethernet. And the hardware must support it! For example the network adapter on Raspberry Pi 3 does not support it.

Bugs and ToDos

  • integrate a threshold, when it is more stress-less for router to get full device list and parse this, instead of getting 20 devices/host information
  • at the moment support for python plugin rename a device is quite bad, so we use JSON-API call
  • On windows system changing icons for sensors did not work, so it's standard switch icon.
  • On windows system "update" the hardware breaks imported python libs. Plugin can not get data from FritzBox. But after restart services it works fine.

Versions

Version Note
0.7.0 * change handling in case of MAC-List usage. Device names are fetched from Fritz!Box and updated on Heartbeat
* Using domoticz special Parameter User/Password - so please reinsert.
* avoid overwriting custom images with default icons during start up
* better checking if inserted values are MAC-Addresses
0.6.4 small stability fixes, a bit restructure and tested with new version of lib
for issue#2, avoid resetting images on startup also if MAC-List is used, so custom symbols will be kept
0.6.3 button to add/remove know hosts from Fritz!Box to Domoticz and support for "Wake on LAN"
0.6.2 supports ';' separated list of MAC and names
>= 0.6 works with new fritzconnection 1.2.1 and so without need of lxml but Python >= 3.6
<= 0.5 worked with fritzconnection 0.6.x and 0.8.x, needs lxml

State

Under development but main function runs quite stabile.

Developing

Based on https://github.com/ffes/domoticz-buienradar/ there are

  • /blz/fakeDomoticz.py - used to run it outside of Domoticz
  • /blz/blzHelperInterface.py starting point for some more structure
  • unittest under folder /test - it's the new entry point for tests
    • copy sample_config.ini to my_config.ini and adapt to your liking

About

domoticz plugin to check and show presence via data from Fritz!Box router

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%