Giter Site home page Giter Site logo

python-fritzhome's Introduction

Python Library to access AVM Fritz!Box homeautomation

BuildStatus PyPiVersion Python versions Coveralls Maintainability Codacy

Tested Devices

fritzhome CLI tool

You have to add a user with the rights to access the smarthome actors.

In the fritzbox webinterface under "System -> FRITZ!Box-Benutzer" you can add a new user.

$ fritzhome -f fritz.box  -u smarthome -p smarthome  list
##############################
name=Fenster Badezimmer
  ain=11934 0154799-1
  id=2000
  productname=HAN-FUN
  manufacturer=0x0feb
  present=True
  lock=None
  devicelock=None
  is_group=False
 Alert:
  alert=True
##############################
name=Thermostat Badezimmer
  ain=11959 0171328
  id=16
  productname=Comet DECT
  manufacturer=AVM
  present=True
  lock=False
  devicelock=False
  is_group=False
 Temperature:
  temperature=19
  offset=-3
 Thermostat:
  battery_low=False
  battery_level=80
  actual=19.0
  target=19.0
  comfort=22.0
  eco=19.0
  window=False
  window_until=0
  boost=None
  boost_until=None
  adaptive_heating_running=None
  summer=False
  holiday=False
##############################
name=Wohnzimmer Couch
  ain=09995 0523646
  id=17
  productname=FRITZ!DECT 301
  manufacturer=AVM
  present=True
  lock=False
  devicelock=False
  is_group=False
Temperature:
  temperature=20.5
Thermostat:
  battery_low=False
  battery_level=80
  actual=20.5
  target=21.5
  comfort=21.5
  eco=17.5
  window=False
  summer=False
  holiday=False
##############################
name=Wohnzimmer Tisch
  ain=09995 0517495
  id=18
  productname=FRITZ!DECT 301
  manufacturer=AVM
  present=True
  lock=False
  devicelock=False
  is_group=False
Temperature:
  temperature=21.0
Thermostat:
  battery_low=False
  battery_level=80
  actual=21.0
  target=21.5
  comfort=21.5
  eco=17.5
  window=False
  summer=False
  holiday=False
##############################
name=Schalter WC Heizung
  ain=08761 0402392
  id=21
  productname=FRITZ!DECT 200
  manufacturer=AVM
  present=True
  lock=True
  devicelock=False
  is_group=False
 Switch:
  switch_state=False
 Powermeter:
  power=0
  energy=436529
  voltage=231.0
 Temperature:
  temperature=22
  offset=3
##############################
name=Wohnzimmer
  ain=grp303E4F-3F7D9BE07
  id=900
  productname=
  manufacturer=AVM
  present=True
  lock=False
  devicelock=False
  is_group=True
  group_members=['17', '18']
Thermostat:
  battery_low=None
  battery_level=None
  actual=None
  target=21.5
  comfort=21.5
  eco=17.5
  window=None
  summer=None
  holiday=None

Fritzbox User

Add a new user: System -> FRITZ!Box-Benutzer

image

image

References

python-fritzhome's People

Contributors

anhi avatar c-logic avatar cmeissner avatar crasu avatar dl6er avatar flabbamann avatar gezzo42 avatar hthiery avatar mib1185 avatar mithomas avatar mjklemm avatar parliament119 avatar refinedcranberry avatar sebuer avatar shadoxxhd avatar sisamiwe avatar smpj avatar snake-soft avatar syssi avatar tobixx avatar xarbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-fritzhome's Issues

please do release 0.6.6

Hi @hthiery
may I ask to do a new release (0.6.6)?
I would to go further with some open tasks for the Fritz!Smarthome integration in home-assistant.
thanks in advanced.
Regards,
Michael

Support non-standard ports

I had to configure my Fritz!Box to a TCP port different from 443. Can you provide a parameter to specify the port?

I am not using python-fritzhome directly, but through home assistant, where I have also opened a related issue:

home-assistant/core#36903

No switches detected for Fritz!DECT 440

My Fritz!DECT 440 is only detectet as sensor for temperature.
The four switch buttons can not be used.

##############################
name=Taster Schlafzimmer
ain=nnnnn nnnnnnn
id=16
productname=FRITZ!DECT 440
manufacturer=AVM
present=True
lock=None
devicelock=None
Temperature:
temperature=23.0
offset=0.0
##############################
name=Taster Wohnzimmer
ain=nnnnn nnnnnnn
id=17
productname=FRITZ!DECT 440
manufacturer=AVM
present=True
lock=None
devicelock=None
Temperature:
temperature=23.0
offset=0.0

See output from http://fritz.box/webservices/homeautoswitch.lua?switchcmd=getdevicelistinfos&sid=
with button tags:
homeautoswitch.zip

Comet Dect does not return values for temperature clesius and temperature offset

After an unspecified time the DOM element for temperature celsisus and offset are empty.

<device functionbitmask="320" fwversion="03.54" id="22" identifier="11960 0071472" manufacturer="AVM" productname="Comet DECT">
	<present>1</present>
	<name>Thermostat Wohnzimmer Seite</name>
	<temperature>
		<celsius/>
		<offset/>
	</temperature>
	<hkr>
		<tist>44</tist>
		<tsoll>42</tsoll>
		<absenk>36</absenk>
		<komfort>42</komfort>
		<lock>0</lock>
		<devicelock>0</devicelock>
		<errorcode>5</errorcode>
		<batterylow>0</batterylow>
		<nextchange>
			<endperiod>1519160400</endperiod>
			<tchange>36</tchange>
		</nextchange>
	</hkr>
</device>

Integrate "T SmartHome Wandtaster"

I have the above mentioned new button device. It's detected in home assistant but does not show up as device.
Is it possible to integrate it?

These are the debug infos:

<device identifier="11934 0142125" id="408" functionbitmask="1" fwversion="31.20"
    manufacturer="0x0feb" productname="HAN-FUN">
    <present>1</present>
    <txbusy>0</txbusy>
    <name>HAN-FUN #3</name>
</device>
<device identifier="11934 0142125-2" id="2004" functionbitmask="8200" fwversion="0.0"
    manufacturer="0x0feb" productname="HAN-FUN">
    <present>1</present>
    <txbusy>0</txbusy>
    <name>HAN-FUN #3 - F2</name>
    <etsiunitinfo>
        <etsideviceid>408</etsideviceid>
        <unittype>273</unittype>
        <interfaces>772</interfaces>
    </etsiunitinfo>
    <button>
        <lastpressedtimestamp>1675603423</lastpressedtimestamp>
    </button>
</device>
<device identifier="11934 0142125-1" id="2005" functionbitmask="8200" fwversion="0.0"
    manufacturer="0x0feb" productname="HAN-FUN">
    <present>1</present>
    <txbusy>0</txbusy>
    <name>HAN-FUN #3 - F1</name>
    <etsiunitinfo>
        <etsideviceid>408</etsideviceid>
        <unittype>273</unittype>
        <interfaces>772</interfaces>
    </etsiunitinfo>
    <button>
        <lastpressedtimestamp>1675603422</lastpressedtimestamp>
    </button>
</device>

Exception: GOTOBLAS_MAIN_FREE

As requested by @escoand, I'm opening a issue for this problem of the library:

2020-05-31 23:15:20 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.xxx.1 for fritzbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/__init__.py", line 79, in async_setup_entry
    await hass.async_add_executor_job(fritz.login)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/pyfritzhome/fritzhome.py", line 115, in login
    secret=secret)
  File "/usr/local/lib/python3.7/site-packages/pyfritzhome/fritzhome.py", line 62, in _login_request
    plain = self._request(url, params)
  File "/usr/local/lib/python3.7/site-packages/pyfritzhome/fritzhome.py", line 49, in _request
    rsp = self._session.get(url, params=params, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 521, in request
    prep.url, proxies, stream, verify, cert
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 697, in merge_environment_settings
    env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
  File "/usr/local/lib/python3.7/site-packages/requests/utils.py", line 769, in get_environ_proxies
    return getproxies()
  File "/usr/local/lib/python3.7/urllib/request.py", line 2480, in getproxies_environment
    for name, value in os.environ.items():
  File "/usr/local/lib/python3.7/_collections_abc.py", line 744, in __iter__
    yield (key, self._mapping[key])
  File "/usr/local/lib/python3.7/os.py", line 681, in __getitem__
    raise KeyError(key) from None
KeyError: 'GOTOBLAS_MAIN_FREE'

Simone

Please release a new version to PyPi that includes template support

There are a number of changes since the last release in June, most notably template support. It would be great to be able to install the latest code from PyPi to be able to properly reference it in other projects, maybe you can find the time to release a new version at some point.

Error due to IP address switch

I recently changed my Homeassistant hardware. Afterwards I was not able to use the FRITZ!SmartHome integration. I got the following error:
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://fritz.box/webservices/homeautoswitch.lua?switchcmd=gettemplatelistinfos&sid=88a3e4bb76d62fe0
The Fritz!Box reports an failed log in. Tests with the CLI results in the same error, but not on my normal PC. It seems to be similar to the problem of the following report.
Further investigation using wireshard revealed the problem:
grafik
The used IPv6 address changed between the different request and the address needs to be the same, otherwise the request failes.
My first idea was to get the source IP address of the first request and set it for further connections. But getting the source address is tricky and did not work with the Fritz!Box (further information).
I came up with the following quick and dirty solution in fritzhome.py:

import requests
requests.packages.urllib3.util.connection.HAS_IPV6 = False

Do you have an idea for a better solution? Especially for integration into pyfritzhome.

Some background on the environment: Raspberry Pi OS Lite 64 based on Debian 12 with the IP addresses assigned via DHCP.

HTTPS not supported

It would be a great thing to access the Dect 200 over the internet but of course not over the hardcoded unencrypted plain http.

I tried with replacing every

'http://' + self._host

with

self.get_prefixed_url(self._host)

and adding the following method:

def get_prefixed_url(self, host):
    """Choose the correct protocol prefix for the host. 
    Supports three input formats:
    - https://<host> (requests use strict certificate validation by default)
    - http://<host> (unecrypted)
    - <host> (unencrypted)
    """
    protocol_url = host
    if host.startswith('https://') or host.startswith('http://'):
        return host
    else:
        return 'http://' + host

PS: It also works with custom ports.

Template support raises error for FB running with firmware < 7

Templates were introduced in Fritz OS 7, so every older device now hits a Traceback due to not checking the existent of the templates:

File "/usr/src/homeassistant/homeassistant/components/fritzbox/coordinator.py", line 48, in _update_fritz_devices
    self.fritz.update_templates()
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 357, in update_templates
    for element in self.get_template_elements():
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 371, in get_template_elements
    return self._get_listinfo_elements("template")
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 144, in _get_listinfo_elements
    dom = ElementTree.fromstring(plain)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1343, in XML
    return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0

(shorter TB without homeassistant stack in front)

The result of fritz._aha_request("gettemplateinfos") is an empty string in this case.

New feature request - set holiday dates

I have a dozen thermostats at home that I want to set the holidays by one command (in the fritz user interface I would have to set the same holiday a dozen times i.e. for each thermostat).
Thought I could do that with a fritzhome template but with fritzhome -f fritz.box -u xxx -p yyy template list I get nothing (though holidays exist).

Issues with umlauts and probably other unicode characters

Fritzbox with FritzOS 7
The program crashes when a smarthome device has an umlaut in its name.

Traceback (most recent call last):
File "/usr/bin/fritzhome", line 11, in
load_entry_point('pyfritzhome==0.4.0', 'console_scripts', 'fritzhome')()
File "/usr/lib/python2.7/site-packages/pyfritzhome/cli.py", line 187, in main
args.func(fritzbox, args)
File "/usr/lib/python2.7/site-packages/pyfritzhome/cli.py", line 20, in list_all
devices = fritz.get_devices()
File "/usr/lib/python2.7/site-packages/pyfritzhome/fritzhome.py", line 146, in get_devices
for element in self.get_device_elements():
File "/usr/lib/python2.7/site-packages/pyfritzhome/fritzhome.py", line 130, in get_device_elements
plain = self._aha_request('getdevicelistinfos')
File "/usr/lib/python2.7/site-packages/pyfritzhome/fritzhome.py", line 106, in _aha_request
return rf(plain)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 624: ordinal not in range(128)

Sensor name does not support umlaut

Traceback (most recent call last):
File "cli.py", line 160, in
main()
File "cli.py", line 153, in main
args.func(fritzbox, args)
File "cli.py", line 12, in list_all
devices = fritz.get_devices()
File "/home/hthiery/sources/python-fritzhome/pyfritzhome/fritzhome.py", line 132, in get_devices
for element in self.get_device_elements():
File "/home/hthiery/sources/python-fritzhome/pyfritzhome/fritzhome.py", line 119, in get_device_elements
dom = xml.dom.minidom.parseString(plain)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
return expatbuilder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 2583: ordinal not in range(128)

How to ... (control thermostats)

Hello hthiery,

I really like the idea of the project and would like to use it for control of my FRITZ DECT 301 thermostats.
As I didn't find any documentation of how to put your code into practice, I cloned the repository and searched line for line through the code for hints on how it works and how to apply it. After 4 hours of work I was finally able to switch my DECT 200 on and off using CLI.
Another hour later I still don't have any idea how I can set temperatures on my thermostats...
Can you please give a hint, how to use your code to achieve this? Also it would be great if you could add some documentation to make the application of your great project a little bit more user friendly.

Thank you very much!

Functionality to check for AHA support

I'm currently working on the HomeAssistant integration of fritzhome. The project maintainers try to avoid protocol specific implementations and just want to rely on external libraries. So it would be nice if fritzhome would have a function to test if the device is able to handle the AHA requests.

At least one user has a FRITZ!Repeater device which seems to be able to handle the login/logout requests, but fails when calling get_devices with a 404 error. Would be nice you could check this before. So I would be able to filter such devices out before the user tries to configure it within HomeAssistant.

Not sure what's the best way to do so, as I don't own such a device.

Several HAN-FUN devices are not correctly identified

I connected two Telekom HAN-FUN devices to my FRITZ!Box 7590 and they did not appear in Home Assistant. I did some research and I feel like the function bits provided by the AHA HTTP Interface are not interpreted the correct way by pyfritzhome.

Devices:
Telekom E27 warm white bulb (no white spectrum, just dimmable)
https://www.smarthome.de/geraete/smarthome-wlan-led-lampe-e27-weiss
Telekom Smart Plug Outdoor
https://www.smarthome.de/geraete/smarthome-zwischenstecker-aussen-schwarz

API discussion:
If I read your code correctly, I think the interpretation of the following function bits is not correct:
0x0200 aka SWITCH => just the AVM plugs (eg. 200, 210)
0x8000 aka SWITCHABLE => onoff available, meaning the unit accepts "on/off" commands
0x10000 aka DIMMABLE => level control available, meaning the unit accepts "set level to x" commands
0x20000 aka LIGHTBULB => color control available, meaning at least one type of color can be set (temperature or hue/saturation), identified by the bitmap in supported_modes

This means a lightbulb is only identified as lightbulb if it has color control (white spectrum, hue/saturation, ...) and a plug works only for FRITZ!DECT 200 and 210.

To correctly identify a HAN-FUN device one could use the HAN-FUN bit (0x2000) and then check etsiunitinfo->unittype from the XML. It contains the actual device type according to the AHA HTTP Interface. Eg.:

...
262 = AC_OUTLET
263 = AC_OUTLET_SIMPLE_POWER_METERING
...

AVM devices are apparently no HAN-FUN devices (except the DECT 500) and can be identified via the other function bits.

Some debug infos:

fritzhome list output:

##############################
name=Telekom White Dimmable Bulb
  ain=12701 0071939
  id=407
  productname=HAN-FUN
  manufacturer=0x319d
  present=True
  lock=None
  devicelock=None
##############################
name=Telekom White Dimmable Bulb
  ain=12701 0071939-1
  id=2009
  productname=HAN-FUN
  manufacturer=0x319d
  present=True
  lock=None
  devicelock=None
##############################
name=Telekom Plug
  ain=11324 0717699
  id=408
  productname=HAN-FUN
  manufacturer=0x2c3c
  present=True
  lock=None
  devicelock=None
##############################
name=Telekom Plug
  ain=11324 0717699-1
  id=2010
  productname=HAN-FUN
  manufacturer=0x2c3c
  present=True
  lock=None
  devicelock=None

fritzhome device stats output:
<devicestats></devicestats>

fritzhome switch on/off:
works correctly

Output of homeautoswitch.lua:
homeautoswitch_output.xml.txt

Provide perameter for skipping ssl verification

As any fritzbox is delivered with self-signed certificates it will be useful to have an option to skip certificate verification in login method.

Currently fritzhome -f https://fritz.box -u \<user> -p \<pass> list leads to the following error:

...
requests.exceptions.SSLError: HTTPSConnectionPool(host='fritz.box', port=443): Max retries exceeded with url: /login_sid.lua?security%3Acommand%2Flogout=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))

Using http is not a really secure option as the login data can be sniffed in that case.

Switch device does not have devicelock entry

fritz 6490 Cable and OS version 6.51

DEBUG:pyfritzhome.fritzhome:<device functionbitmask="896" fwversion="03.59" id="16" identifier="08761 0373130" manufacturer="AVM" productname="FRITZ!DECT 200">
        <present>1</present>
        <name>FRITZ!DECT 200 #1</name>
        <switch>
                <state>1</state>
                <mode>manuell</mode>
                <lock>1</lock>
        </switch>
        <powermeter>
                <power>114580</power>
                <energy>87830</energy>
        </powermeter>
        <temperature>
                <celsius>220</celsius>
                <offset>0</offset>
        </temperature>
</device>

INFO:pyfritzhome.fritzhome:logout
Traceback (most recent call last):
  File "/usr/bin/fritzhome", line 11, in <module>
    load_entry_point('pyfritzhome==0.3.3', 'console_scripts', 'fritzhome')()
  File "/usr/lib/python3.6/site-packages/pyfritzhome/cli.py", line 153, in main
    args.func(fritzbox, args)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/cli.py", line 12, in list_all
    devices = fritz.get_devices()
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 133, in get_devices
    device = FritzhomeDevice(self, node=element)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 239, in __init__
    self._update_from_node(node)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 272, in _update_from_node
    self.device_lock = bool(get_node_value(n, 'devicelock'))
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 28, in get_node_value
    return get_text(node.getElementsByTagName(name)[0].childNodes)
IndexError: list index out of range

Thermostat Offset

Is / Would it be possible to control the thermostat offset value?
This would enable users to use cheaper sensors to calibrate their AVM thermostats.

image

Please release a new version to PyPi that includes the HTTPS support

Thank you for for creating and sharing this library, I am using it to control my thermostats 👍

There are a number of changes since the last release in February, most noticeably HTTPS support (#19). It would be great to be able to install the latest code from PyPi that includes the HTTPS support, maybe you can find the time to release a new version at some point.

Will install from Github directly until then, no worries. Thanks for your time!

Login does not work

I've created a user like this:

bildschirmfoto 2017-11-20 um 20 17 38

It'll end up with the following error:

[matze@server ~]$ fritzhome -u smarthome -p ****** -f 192.168.178.1 list
WARNING:pyfritzhome.fritzhome:login failed 0000000000000000
Traceback (most recent call last):
  File "/usr/bin/fritzhome", line 11, in <module>
    load_entry_point('pyfritzhome==0.3.5', 'console_scripts', 'fritzhome')()
  File "/usr/lib/python2.7/site-packages/pyfritzhome/cli.py", line 162, in main
    fritzbox.login()
  File "/usr/lib/python2.7/site-packages/pyfritzhome/fritzhome.py", line 103, in login
    raise LoginError(self._user)
pyfritzhome.errors.LoginError: login for user="smarthome" failed

Password was replaced.

Tried with both Python2 and 3. What could be the problem?

Bump Home Assistant dependency of python-fritzhome to version 0.6.0 to allow the support for FRITZ DECT 440 and 550

To allow the support for the FRITZ DECT 440 switch and the FRITZ DECT 500 light bulb, the HA dependency to python-fritzhome has to be bumped to version 0.6.0.

Link to current version of python-fritzhome: https://github.com/hthiery/python-fritzhome/tree/0.6.0

Inititial discussion: https://community.home-assistant.io/t/support-for-avm-fritz-dect-switch-440-and-light-bulb-500/224433/13

Support for smarthome templates?

With FritzOS 7 the functionality of smarthome templates (German: "Vorlagen") became available both in the UI as well as in the AHA-HTTP-Interface with the commands gettemplatelistinfos and applytemplate.

Would you accept a PR which would implement this for this library?

Looking at the straightforward structure I'd probably go for two new methods for Fritzhome. Wrt gettemplatelistinfos I'd probably simply return a map of template names by string (although the info about the relevant devices might have its merit). What do you think?

I also guess that an extension of the cli would also be in order - for this one a dedicated call to gettemplatelistinfos which simply passes though the output (similar to get_device_statistics) could be useful.

For easier development I could imagine that merging #49 first is highly beneficial :-)

Is there a reason for voltage/1000 while power and energy is not /1000?

In fritzhomedevicepowermeter.py you define
self.power = int(val.findtext("power")) (---> gives value 25123 for real 25.123 W)
self.energy = int(val.findtext("energy")) (---> gives value 999123 for real 999.123 kWh)
but voltage is /1000 (---> gives value 230.123 for real 230.123 V)

self.voltage = float(int(val.findtext("voltage")) / 1000)

Is there a reason for that? I would expect real float values (230.123 V) for all or int values (230123 V) for all, but not mixed.

Enable firmware version readout

Hey,
currently the read out of the device' firmware version is not fully implemented.
Please enable the firmware version readout.
Thank you.

Random error: login failed

Sometimes I get this log entry:

2020-07-29 01:27:47 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry FRITZ!Box 7590 for fritzbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 219, in async_setup
    result = await component.async_setup_entry(  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/__init__.py", line 79, in async_setup_entry
    await hass.async_add_executor_job(fritz.login)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/pyfritzhome/fritzhome.py", line 118, in login
    raise LoginError(self._user)
pyfritzhome.errors.LoginError: login for user="admin" failed

Usually to recover it's enough to just wait for a new polling cycle, sometimes instead a restart of HA is needed.

Simone

Flooding the homeassistant log

Hi,

I'm using pyfritzhome as homeassistant extension and while debugging some other stuff I noticed that it floods the log with messages that don't have a lot of actual value.
I guess it's about the Fritzbox API accesses or something like that.
(5 log lines per minute, which would correlate with the 5 Comet-DECT thermostats that I currently have in my setup)
Looks to me like something that should be logged as DEBUG is logged as INFO.
Or is it intended like this?

Thanks

Feb 15 18:31:59 raspberrypi hass[10160]: 2019-02-15 18:31:59 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacbeff48>
Feb 15 18:32:00 raspberrypi hass[10160]: 2019-02-15 18:32:00 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacbc0880>
Feb 15 18:32:00 raspberrypi hass[10160]: 2019-02-15 18:32:00 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccd0b20>
Feb 15 18:32:00 raspberrypi hass[10160]: 2019-02-15 18:32:00 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccd0c00>
Feb 15 18:32:01 raspberrypi hass[10160]: 2019-02-15 18:32:01 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacbb3848>
Feb 15 18:32:59 raspberrypi hass[10160]: 2019-02-15 18:32:59 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad5323b0>
Feb 15 18:32:59 raspberrypi hass[10160]: 2019-02-15 18:32:59 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc71e30>
Feb 15 18:33:00 raspberrypi hass[10160]: 2019-02-15 18:33:00 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad049df8>
Feb 15 17:29:12 raspberrypi hass[10160]: 2019-02-15 17:29:12 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacdabc00>
Feb 15 17:29:13 raspberrypi hass[10160]: 2019-02-15 17:29:13 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacdabc00>
Feb 15 17:29:13 raspberrypi hass[10160]: 2019-02-15 17:29:13 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc71458>
Feb 15 17:29:13 raspberrypi hass[10160]: 2019-02-15 17:29:13 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc71260>
Feb 15 17:30:13 raspberrypi hass[10160]: 2019-02-15 17:30:13 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc71260>
Feb 15 17:30:13 raspberrypi hass[10160]: 2019-02-15 17:30:13 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceff2d0>
Feb 15 17:30:14 raspberrypi hass[10160]: 2019-02-15 17:30:14 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb060a110>
Feb 15 17:30:14 raspberrypi hass[10160]: 2019-02-15 17:30:14 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccacca8>
Feb 15 17:30:14 raspberrypi hass[10160]: 2019-02-15 17:30:14 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccaca78>
Feb 15 17:31:14 raspberrypi hass[10160]: 2019-02-15 17:31:14 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb04f7768>
Feb 15 17:31:14 raspberrypi hass[10160]: 2019-02-15 17:31:14 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb04f7570>
Feb 15 17:31:15 raspberrypi hass[10160]: 2019-02-15 17:31:15 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacf8ced8>
Feb 15 17:31:15 raspberrypi hass[10160]: 2019-02-15 17:31:15 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xa9aec538>
Feb 15 17:31:16 raspberrypi hass[10160]: 2019-02-15 17:31:16 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xa9aec0a0>
Feb 15 17:32:15 raspberrypi hass[10160]: 2019-02-15 17:32:15 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xab620ca8>
Feb 15 17:32:15 raspberrypi hass[10160]: 2019-02-15 17:32:15 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacfbd0a0>
Feb 15 17:32:16 raspberrypi hass[10160]: 2019-02-15 17:32:16 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xab6304c8>
Feb 15 17:32:16 raspberrypi hass[10160]: 2019-02-15 17:32:16 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc676c0>
Feb 15 17:32:17 raspberrypi hass[10160]: 2019-02-15 17:32:17 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacfbdf80>
Feb 15 17:33:16 raspberrypi hass[10160]: 2019-02-15 17:33:16 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xab620ab0>
Feb 15 17:33:17 raspberrypi hass[10160]: 2019-02-15 17:33:17 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xab620618>
Feb 15 17:33:17 raspberrypi hass[10160]: 2019-02-15 17:33:17 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacd74928>
Feb 15 17:33:18 raspberrypi hass[10160]: 2019-02-15 17:33:18 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacca7a40>
Feb 15 17:33:19 raspberrypi hass[10160]: 2019-02-15 17:33:19 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacd74490>
Feb 15 17:34:17 raspberrypi hass[10160]: 2019-02-15 17:34:17 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad049068>
Feb 15 17:34:18 raspberrypi hass[10160]: 2019-02-15 17:34:18 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad08d148>
Feb 15 17:34:18 raspberrypi hass[10160]: 2019-02-15 17:34:18 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb63175e0>
Feb 15 17:34:19 raspberrypi hass[10160]: 2019-02-15 17:34:19 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceffea0>
Feb 15 17:34:19 raspberrypi hass[10160]: 2019-02-15 17:34:19 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceff960>
Feb 15 17:35:18 raspberrypi hass[10160]: 2019-02-15 17:35:18 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb08c9260>
Feb 15 17:35:19 raspberrypi hass[10160]: 2019-02-15 17:35:19 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc4a490>
Feb 15 17:35:19 raspberrypi hass[10160]: 2019-02-15 17:35:19 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceff4c8>
Feb 15 17:35:20 raspberrypi hass[10160]: 2019-02-15 17:35:20 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc4a5e0>
Feb 15 17:35:20 raspberrypi hass[10160]: 2019-02-15 17:35:20 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceff928>
Feb 15 17:36:18 raspberrypi hass[10160]: 2019-02-15 17:36:18 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc713e8>
Feb 15 17:36:19 raspberrypi hass[10160]: 2019-02-15 17:36:19 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xa3b71ae8>
Feb 15 17:36:19 raspberrypi hass[10160]: 2019-02-15 17:36:19 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad0a17a0>
Feb 15 17:36:20 raspberrypi hass[10160]: 2019-02-15 17:36:20 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad0a13e8>
Feb 15 17:36:20 raspberrypi hass[10160]: 2019-02-15 17:36:20 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xacc71148>
Feb 15 17:37:18 raspberrypi hass[10160]: 2019-02-15 17:37:18 INFO (Thread-3) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb08b2458>
Feb 15 17:37:19 raspberrypi hass[10160]: 2019-02-15 17:37:19 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccac730>
Feb 15 17:37:19 raspberrypi hass[10160]: 2019-02-15 17:37:19 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb04f7768>
Feb 15 17:37:20 raspberrypi hass[10160]: 2019-02-15 17:37:20 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad1565a8>
Feb 15 17:37:20 raspberrypi hass[10160]: 2019-02-15 17:37:20 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xad156420>
Feb 15 17:38:19 raspberrypi hass[10160]: 2019-02-15 17:38:19 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xab606768>
Feb 15 17:38:20 raspberrypi hass[10160]: 2019-02-15 17:38:20 INFO (Thread-2) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xb04f7768>
Feb 15 17:38:20 raspberrypi hass[10160]: 2019-02-15 17:38:20 INFO (Thread-6) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceb5f48>
Feb 15 17:38:20 raspberrypi hass[10160]: 2019-02-15 17:38:20 INFO (Thread-5) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaceb5f48>
Feb 15 17:38:21 raspberrypi hass[10160]: 2019-02-15 17:38:21 INFO (Thread-4) [pyfritzhome.fritzhome] <xml.dom.minidom.Document object at 0xaccac5e0>

Version 0.3.4 and Fritz 6490 Cable with 6.51

Hi,

I have testet your new version and both devices are listed correctly, but afterwards I get this error:

DEBUG:pyfritzhome.fritzhome:<device functionbitmask="896" fwversion="03.59" id="16" identifier="08761 0373130" manufacturer="AVM" productname="FRITZ!DECT 200">
	<present>1</present>
	<name>FRITZ!DECT 200 #1</name>
	<switch>
		<state>1</state>
		<mode>manuell</mode>
		<lock>1</lock>
	</switch>
	<powermeter>
		<power>99560</power>
		<energy>116972</energy>
	</powermeter>
	<temperature>
		<celsius>220</celsius>
		<offset>0</offset>
	</temperature>
</device>

DEBUG:pyfritzhome.fritzhome:<device functionbitmask="320" fwversion="03.50" id="17" identifier="11959 0812272" manufacturer="AVM" productname="Comet DECT">
	<present>1</present>
	<name>Comet DECT #2</name>
	<temperature>
		<celsius>230</celsius>
		<offset>-10</offset>
	</temperature>
	<hkr>
		<tist>46</tist>
		<tsoll>45</tsoll>
		<absenk>32</absenk>
		<komfort>45</komfort>
	</hkr>
</device>

INFO:pyfritzhome.fritzhome:logout
Traceback (most recent call last):
  File "/usr/bin/fritzhome", line 11, in <module>
    load_entry_point('pyfritzhome==0.3.4', 'console_scripts', 'fritzhome')()
  File "/usr/lib/python3.6/site-packages/pyfritzhome/cli.py", line 163, in main
    args.func(fritzbox, args)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/cli.py", line 19, in list_all
    devices = fritz.get_devices()
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 127, in get_devices
    device = FritzhomeDevice(self, node=element)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 231, in __init__
    self._update_from_node(node)
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 254, in _update_from_node
    self.lock = bool(int(get_node_value(n, 'lock')))
  File "/usr/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 22, in get_node_value
    return get_text(node.getElementsByTagName(name)[0].childNodes)
IndexError: list index out of range

6591 Cable unsupported?

Hi guys, I just got a new FB from my provider. Sadly fritzhome doesn´t seem to work with it. I´m using it through HomeAssistant. Already created an issue there and was redirected here :).

Any Idea about this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.