hthiery / homeassistant

HomeAssistant Custom Components
9 stars 0 forks source link

Problem with FRITZ OS 6.51 #1

Closed Dominion0815 closed 6 years ago

Dominion0815 commented 6 years ago

Hi,

I have a problem with fritz 6490 Cable and OS version 6.51, a newer one is not possbile because of provider. Also I'am not able to use a smarthome user, only admin user works with other HomeAssistant components.

Thanks in advanced.

Error Message in Home Assistant:

2017-11-07 20:59:35 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform fritzhome
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/dominion/.homeassistant/custom_components/switch/fritzhome.py", line 27, in setup_platform
    device_list = fritz.get_devices()
  File "/home/dominion/.homeassistant/deps/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 133, in get_devices
    device = FritzhomeDevice(self, node=element)
  File "/home/dominion/.homeassistant/deps/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 239, in __init__
    self._update_from_node(node)
  File "/home/dominion/.homeassistant/deps/lib/python3.6/site-packages/pyfritzhome/fritzhome.py", line 272, in _update_from_node
    self.device_lock = bool(get_node_value(n, 'devicelock'))
  File "/home/dominion/.homeassistant/deps/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

greetz, Dominion

hthiery commented 6 years ago

What DECT devices do you use?

Can you please send the output of the following command from the pyfritzhome module:

frithome -f <YOUR-FRITZ-BOX-IP> -u <YOUR-USERNAME> -p <YOUR-PASSWORD> -v list

and also check your installed version of pyfritzhome with:

pip show fritzhome

hthiery commented 6 years ago

can you please send the output of the following command from the pyfritzhome module:

frithome -f <YOUR-FRITZ-BOX-IP> -u <YOUR-USERNAME> -p <YOUR-PASSWORD> -v list

and also check your installed version of pyfritzhome with:

pip show fritzhome

Dominion0815 commented 6 years ago

my version is 0.3.3 but I used the one in "deps" folder. I tried this workaround and it works for now with Comet DECT

.homeassistant/deps/lib/python3.6/site-packages/pyfritzhome/fritzhome.py

 27 def get_node_value(node, name):
 28     try:
 29         return get_text(node.getElementsByTagName(name)[0].childNodes)
 30     except:
 31         return "0"
hthiery commented 6 years ago

As you mentioned it is a workaround for you. Could you please provide the info I requested above to find a real fix.

Dominion0815 commented 6 years ago
% pip3 show pyfritzhome                                                                                :(
Name: pyfritzhome
Version: 0.3.3
Summary: Fritz!Box Smarthome Python Library
Home-page: http://github.com/hthiery/python-fritzhome
Author: Heiko Thiery
Author-email: heiko.thiery@gmail.com
License: LGPLv2+
Location: /usr/lib/python3.6/site-packages
Requires: requests
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
hthiery commented 6 years ago

Thank you. Now it seems to be a little bit clearer ... I guess that an older firmware of the fritzbox does not show the devicelock state in the device node. So I will do only add this in case of value present. I think about what values are really needed.

    <device identifier="08761 0000434" id="17" functionbitmask="896" fwversion="03.33" manufacturer="AVM" productname="FRITZ!DECT 200">
        <present>1</present>
        <name>Steckdose</name>
        <switch>
            <state>1</state>
            <mode>auto</mode>
            <lock>0</lock>
            <devicelock>0</devicelock>
        </switch>
        <powermeter>
            <power>0</power>
            <energy>707</energy>
        </powermeter>
        <temperature>
            <celsius>285</celsius>
            <offset>0</offset>
        </temperature>
    </device>
hthiery commented 6 years ago

I opened an issue on the pyfritzhome module

https://github.com/hthiery/python-fritzhome/issues/2