DerMitch / fritzbox-smarthome

Client library for querying and controling AVM SmartHome Actors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Listing actors results in Internal Server Error Response

SchulzSt opened this issue · comments

As the title says: Running the actors command results in a 500 Internal Sever Error Response when trying to get the temperature? Note that the temperature displays ok in the Webinterface. FritzOS is on version 7.20. Stacktrace:

> python -m fritzhome --host fritz.box --username xyz --password xyz actors
Keller (AVM FRITZ!DECT 200; AIN 11630 0205972 )
Temp: act 26 target 0.0; battery (low): True
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/stephan/projects/fritzbox-smarthome/fritzhome/__main__.py", line 242, in <module>
    cli()
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/stephan/projects/fritzbox-smarthome/fritzhome/__main__.py", line 61, in actors
    actor.get_target_temperature(),
  File "fritzhome/actor.py", line 130, in get_target_temperature
    value = self.box.homeautoswitch("gethkrtsoll", self.actor_id)
  File "fritzhome/fritz.py", line 137, in homeautoswitch
    response.raise_for_status()
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://fritz.box/webservices/homeautoswitch.lua?ain=11630+0205972&switchcmd=gethkrtsoll&sid=af7f0e2f8b01cc6c

Hi Stephan,

I think the best place to report a "500 Internal Server Error" would normally be AVM, as this is an issue inside the FritzOS.

In this case I assume the problem is that the AIN contains a space, I guess that was added in a later version of FritzOs. A possible fix for this is added in commit 5dbe523. You can install the latest git version using:

pip install git+https://github.com/DerMitch/fritzbox-smarthome.git@master

As I do no longer own any FRITZ!Box, I am not able to test it by myself.

It seems this did not help. The URL changed accordingly though:

[...]
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://fritz.box/webservices/homeautoswitch.lua?switchcmd=gethkrtsoll&sid=1bef10cedea056c1&ain=116300205972

I get this with the github Version.

Traceback (most recent call last):
  File "/usr/local/bin/fritzhome", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fritzhome/__main__.py", line 78, in energy
    (actor.get_power() or 0.0) / 1000,
  File "/usr/local/lib/python3.6/dist-packages/fritzhome/actor.py", line 88, in get_power
    value = self.box.homeautoswitch("getswitchpower", self.actor_id)
  File "/usr/local/lib/python3.6/dist-packages/fritzhome/fritz.py", line 138, in homeautoswitch
    response.raise_for_status()
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://fritz.box/webservices/homeautoswitch.lua?switchcmd=getswitchpower&sid=d52b8ae3e75f8cd8&ain=099950534716

Hope it will be working again in the Future?
Thanks,