Closed Musashi178 closed 3 years ago
Hi,
i have a similar setup Raspi 4 / Hassos 5.11 / core-2021.2.3. with 5 Raumfeld systems fw 2.12.5. The system stops working as described after entering the IP of my Raumfeld expand.
If there is anything i may do to help debugging please let me know.
THX a lot for sharing this Integration Olaf
Hi there! My attempts to get a test environment quikcly up and running based on Home Assistant OS failed due to lack of EFI support. As soon as I have a RPi for testing, I'll try to reproduce. Currently I guess the root cause is in hassfeld to find. Can you please apply the attached patch and try it again?
[nobody@example.com teufel_raumfeld]$ pwd
/path/to/custom_components/teufel_raumfeld
[nobody@example.com teufel_raumfeld]$ ls -l
total 64
-rw-rw-r--. 1 nobody nobody 2091 Feb 13 15:39 config_flow.py
-rw-rw-r--. 1 nobody nobody 1673 Feb 14 23:49 const.py
-rw-r--r--. 1 nobody nobody 11765 Feb 14 23:49 __init__.py
-rw-rw-r--. 1 nobody nobody 389 Feb 15 23:13 manifest.json
-rw-rw-r--. 1 nobody nobody 18335 Feb 13 17:29 media_player.py
-rw-rw-r--. 1 nobody nobody 4154 Feb 13 15:44 sensor.py
-rw-rw-r--. 1 nobody nobody 1001 Feb 13 15:38 services.yaml
-rw-r--r--. 1 nobody nobody 618 Jan 31 23:14 strings.json
drwxr-xr-x. 2 nobody nobody 4096 Jan 31 11:39 translations
[nobody@example.com teufel_raumfeld]$ patch -p0 < /tmp/no_update_thread.patch.txt
patching file __init__.py
[nobody@example.com teufel_raumfeld]$
It just disables the command to start the thread responsible for interaction with the Raumfeld host's web service. The patch can easily be reverted by:
[nobody@example.com teufel_raumfeld]$ patch -p0 -R < /tmp/no_update_thread.patch.txt
patching file __init__.py
[nobody@example.com teufel_raumfeld]$
Hi and thx again,
i've commented out the line raumfeld.start_update_thread()
now the Integration gets installed and HA is working. There are no raumfeld devices detected. But I assume this is the expected behaviour without the interaction to the host - right?
Bye
Olaf
Hi again,
i may set up a spare pi3 with HASS and give you access to it ... so we may see if this issue is a raspi4, or maybe a problem with other integrations installed.
CU Olaf
Thanks for the feedback @olafjansen! This was indeed the expected behavior. If you could already try to reproduce on the pi3 from your side, this would be appreciated.
@Musashi178 or @olafjansen,
In the meantime, it would also be interesting to see to what extent the following code works on the RPi4 (remember to replace teufel-host.example.com
accordingly):
python3 << EOF
import asyncio
import hassfeld
raumfeld_host = "teufel-host.example.com"
raumfeld = hassfeld.RaumfeldHost(raumfeld_host)
raumfeld.start_update_thread()
valid_host = asyncio.run(raumfeld.async_host_is_valid())
print(f"Is a Raumfeld-Host: {valid_host}")
rooms = raumfeld.get_rooms()
print(f"Rooms: {rooms}")
zones = raumfeld.get_zones()
print(f"Zones: {zones}")
EOF
Hi, i'm afraid this is the problem with hass OS the python interpreter isn't (at least for me) accessible in the terminal. I thought the pip install steps needed were triggered by the requirements in the manifest.json. In hass OS the direct interaction with python is not needed(/possible?). Same on hass OS on the pi3. Perhaps i should give hassbian a try on the pi3 this weekend. The pi4 with hass os is productiv with a bunch of integrations...(PV/Wallbox/FritzDect stuff/volumio/ ...)
Or is there any way (i don't know up to now) to call python within hass os or at least a way to check the installed python modules.
CU Olaf
Hi again,
in the meantime i finished a clean install of hass os on the pi3. The result after activating hacs and installing the raumfeld integration is exactly the same as on the pi4. With "raumfeld.start_update_thread()" commented out the integration gets loaded without any entities. Is this an interesting way to go or should i try hassbian on this machine. There seems to exist some hass os ways to install python stuff to the custom_components. The easiest one with simply copying the hassfeld components there i've already tried without success :-(.
Any ideas where i may help ?
CU Olaf
Thanks for testing on the pi3! From your feedback it seems to be an issue in combination with Home Assistant OS. Since there are no error resp. log messages and no custom code can be run, I guess I'll have to see about reproducing it myself.
Hi, i've put hassfeld to my Laptop (Ubuntu) and run there your testcode. Seems that hassfeld finds no systems in my network. From the same machine i reach the IP of my base on port 47365. The single urls which i've tried to put in some print statements in the init.py in python are functional in the browser. The test code never returns from "raumfeld.start_update_thread()".
http://192.168.0.70:47365/getHostInfo - wait=300 http://192.168.0.70:47365/getZones - wait=300 http://192.168.0.70:47365/listDevices - wait=300 http://192.168.0.70:47365/SystemStateChannel - wait=300
so this seems to be a problem with my raumfeld and hassfeld :-(
CU Olaf
That's interesting. What do you get when you browse these URIs via the Internet Browser from your laptop?
Hi Marc,
i'll paste the 4 xlms here since i'm not sure which information may help you. I'm afraid my problem is related to the old raumfeld expand which is the base for my system. At the end of this post you may find the information in some local variables in hassfeld which i got from some print-statements in init.py. Which are representing my setup within hassfeld. Interesting is that within the endless loop
while True: ....
before
await asyncio.sleep(DELAY_FAST_UPDATE_CHECKS)
the changes i trigger from the raumfeld app on my handy are recognized. eg. if i put the "Bad" in the same zone as "Schlafzimmer" the testcode delivers new values for "getzones" and "gethostinfo" This loop is triggered every
PREFERRED_TIMEOUT_LONG_POLLING = 300
seconds when nothing is changed in the system. But never left
Debug print frominit.py:
Sorry for the long post...
THX Olaf
Sorry the xml gets filtered 2nd try for
gethostinfo:
`<?xml version='1.0' encoding='UTF-8'?>
`
getZones:
<?xml version='1.0' encoding='UTF-8'?>
<zoneConfig spotifyMode='singleRoom' numRooms='5'>
<zones>
<zone udn='uuid:3993debb-49bc-4eaf-aae0-31d2da74cc02'>
<room udn='uuid:80a9c56b-d20e-41a1-9025-ac70b5bfe5d6' name='Rayka'>
<renderer name='Connector Rayka #2' udn='uuid:eb163fa5-a28e-42ed-bf3e-d77c1c9e6f8f'></renderer>
</room>
</zone>
<zone udn='uuid:4e48721a-d38c-4828-af14-3e73c6f9293c'>
<room udn='uuid:08028273-3eda-415f-bc9b-d2c93dfbad60' name='Thyra'>
<renderer name='Speaker Thyra #2' udn='uuid:28f5fae4-b222-4c75-bdd8-4def3b29ff97'></renderer>
</room>
</zone>
<zone udn='uuid:a85cc6af-bf16-4913-89a2-b17f05f6f813'>
<room udn='uuid:4bcbe283-e265-42ca-a672-92f53dd491f8' name='Wohnzimmer'>
<renderer name='Speaker Wohnzimmer #2' udn='uuid:8187beac-2a2f-47ba-821b-e97a4ad5bf67'></renderer>
</room>
</zone>
<zone udn='uuid:ffffffff-f104-640b-ffff-fffff104640b'>
<room udn='uuid:07046f4d-f80b-4611-bd72-b9212feb6461' name='Schlafzimmer'>
<renderer name='Speaker Schlafzimmer #2' udn='uuid:1c6dd890-02a8-4d3e-a879-6c38c549f707'></renderer>
</room>
</zone>
</zones>
<unassignedRooms>
<room udn='uuid:1f9389d9-284a-49b3-adae-9ee7b79ec97c' name='Bad'>
<renderer name='Speaker Bad' udn='uuid:8aff5c16-bf41-42f9-8351-8692ba81cc93'></renderer>
</room>
</unassignedRooms>
</zoneConfig>
pls let me know which information i may provide to help. i may even give you ssh access to my test laptop if you send me your public ssh-key.
bye Olaf
Thanks again @olafjansen!
At a first glance it looks good. However, the devil is sometimes in the detail.
What you described about the loop in https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues/1#issuecomment-782896988 is expected behavior. This endless loop is running in a dedicated thread and should therefore not be the cause. The web service interfaces of the Raumfeld host feed data back to hassfeld, whenever data changes resp. at the latest after expiration of PREFERRED_TIMEOUT_LONG_POLLING
.
Have you run the test code exactly as described in https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues/1#issuecomment-780733802? (except replacing the value for raumfeld_host
)
The expected output, if everything works well, should look similar to this:
Is a Raumfeld-Host: True
Rooms: ['Rayka', 'Thyra', 'Wohnzimmer', 'Bad', 'Schlafzimmer' ]
Zones: [['Bad', 'Schlafzimmer'], ['Rayka', 'Wohnzimmer']]
PS: I took the liberty to edit some of your comments to reformat the included code blocks for better readability.
Hi again,
I've created a file "testhf.py" on my machine with the following content:
which i call with python3 testhf.py
. My raumfeld expand has the ip 192.168.0.70 and seems never recognized as valid host. The only output i get is:
vor update_thread
even if i let the code run for several hours. If i stop the execution via ctrl-C
i get:
^CTraceback (most recent call last):
File "hftest.py", line 8, in <module>
raumfeld.start_update_thread()
File "/home/olaf/.local/lib/python3.8/site-packages/hassfeld/__init__.py", line 104, in start_update_thread
sleep(DELAY_FAST_UPDATE_CHECKS)
KeyboardInterrupt
the code never (or at least not in serveral hours) comes back from raumfeld.start_update_thread()
in my setup.
& thx for updating my comment to be readable. I'm new to github
Bye Olaf
Hi,
I am not sure if it helps, but the behavior @olafjansen describes is the same as in my environment, although I have a much simpler "setup" of just one single Teufel Raumfeld One S speaker.
Running the testhf.py resulted in printing "vor update_thread" and that's it. I just noticed, that the first time I ran it, I used the wrong IP (the one of @olafjansen ;)) and received the same result. No error or something like that.
Here are the xml results when browsing to speaker's service endpoints: xml-results.zip
I just debugged the hassfeld library. At least on my site, the issue was that 'getZones' did not return any 'zones', but only 'unassignedRooms'. I just created a pull request in hassfeld for it.
Unfortunatly, this most likely will not fix the issue on @olafjansen site, as there are 'zones' in his 'getZones' result. Maybe that is a connection error or something like that, as this caused the same problem.
@Musashi178, Thanks again for finding and fixing the bug!
@olafjansen, Can you please run the code of https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues/1#issuecomment-780733802 again but this time with hassfeld version 0.2.0a7 and report back whether you get some error messages printed?
Hi,
with "hassfeld 0.2.0a7" i get
Long-polling failed with error: <class 'KeyError'>'@powerState'
THX Olaf
As a simple 1st test i commented out the powerState related stuff in __init__.py
then the testcode delivers:
Is a Raumfeld-Host: True
Rooms: ['Thyra', 'Schlafzimmer', 'Bad', 'Wohnzimmer']
Zones: [['Thyra'], ['Bad', 'Schlafzimmer']]
in the next step i'll try to put this to the pi3 with hass os:
I directly edited __init__.py
in the docker overlay file on the sd card on my laptop and booted this (dirty) hacked hassfeld version on the pi.
so i was able to get my rooms and zones visible in hass os.
There are entities generated which i can manipulate through homeassistant (browse my Music, play/pause, ...) the management of zones and the generated new entities are somehow irritating now. I'll try to find out which component in my system has the problem with powerState.
in __update_zone_config(self, content_xml):
try:
self.resolve["roomudn_to_powerstate"][room_udn] = room_itm[ "@powerState" ]
except:
self.resolve["roomudn_to_powerstate"][room_udn] = 'On'
exc_info = f"%s%s - for %s" % (sys.exc_info()[0], sys.exc_info()[1],room_name)
log_critical("Assignment failed with error: %s" % exc_info)
gives:
Assignment failed with error: <class 'KeyError'>'@powerState' - for Wohnzimmer
Assignment failed with error: <class 'KeyError'>'@powerState' - for Bad
Assignment failed with error: <class 'KeyError'>'@powerState' - for Schlafzimmer
Assignment failed with error: <class 'KeyError'>'@powerState' - for Thyra
Is a Raumfeld-Host: True
Rooms: ['Wohnzimmer', 'Bad', 'Schlafzimmer', 'Thyra']
Zones: [['Wohnzimmer'], ['Bad'], ['Schlafzimmer'], ['Thyra']]
Olaf
P.S.: sorry I never coded a line of python before
I just commited the necessary changes in hassfeld: https://github.com/B5r1oJ0A9G/hassfeld/commit/6a4bec17f2b66e3475e1b719331d2d72db6208ca
It's not packaged yet though. It's packaged in release 0.2.0-a8 of hassfeld.
There is also some more validation and logging implemented in teufel_raumfeld with f5bf305 (0.0.6-alpha). The new version of hassfeld is used/downloaded there resp. with it too. Please let me know, if it is working for you or your still facing any issues with it.
Hi @B5r1oJ0A9G,
thx a lot for your patience - and of course for sharing this integration! On my side stuff is working now on Hassos installed on my pi4 (and on the test pi3)
By Olaf
@Musashi178 and @olafjansen,
Thank you both for sharing the issues and helping to resolve them!
Hi,
first of all thank you for doing the integration, I already started to look for alternatives to my Teufel Speaker but will stick with it for a little longer now.
I tried to setup the integration twice now, and it always puts my HomeAssistant instance in a state where it will not respond at all. I have to reboot the rasperry in order to get it working again.
Setup
Raspi 4 Home Assistant OS 5.11 core-2021.2.3
Teufel Integration 9c35a4d and 9c4d8df (installed using HACS)
Raumfeld One S v1.28.102057
How to reproduce it:
1) Go to Configuration -> Integration 2) Click "Add new Integration" and select Teufel Raumfeld 3) Enter IP of Raumfeld One S as Host 4) Click "Submit"
=> The system will not respond any more.
I have check the logs, but they seem to be wiped after the restart. If I can help you in anyway pinpoint that problem, let me know.
Thanks, Marco