B5r1oJ0A9G / teufel_raumfeld

Integration for Teufel smart speaker (aka Raumfeld Multiroom) into https://www.home-assistant.io/.
GNU General Public License v3.0
33 stars 7 forks source link

Invalid host #8

Closed Ivanverdonck closed 3 years ago

Ivanverdonck commented 3 years ago

Hi,

After installing teufel_raumfeld (using HACS), the integration works perfectly, but after a restart of homeassistant i get following error:

Logger: custom_components.teufel_raumfeld
Source: custom_components/teufel_raumfeld/__init__.py:105
Integration: Teufel Raumfeld (documentation, issues)
First occurred: 13:43:05 (1 occurrences)
Last logged: 13:43:05

Invalid host: 10.0.1.10:47365

After removing the integration and installing it again the host is discovered correctly.

I am using docker:

System Health

version core-2021.4.6
installation_type Home Assistant Container
dev false
hassio false
docker true
virtualenv false
python_version 3.8.7
os_name Linux
os_version 4.4.59+
arch x86_64
timezone UTC
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4664 Installed Version | 1.12.3 Stage | running Available Repositories | 777 Installed Repositories | 17
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Lovelace dashboards | 14 -- | -- resources | 7 views | 34 mode | storage
alexludwigklein commented 3 years ago

Hi all, I noticed a similar behaviour: starting the integration when the teufel device is off, triggers the error. Best, Alex

B5r1oJ0A9G commented 3 years ago

Hi @Ivanverdonck and @alexludwigklein,

Thanks for filing and pointing out this issue!

In the current implementation the Teufel host is validated during configuation/startup. If the host does not reply within 3 seconds or is not considered as a valid host, the setup fails.

https://github.com/B5r1oJ0A9G/teufel_raumfeld/blob/abf1da1eaa6a330e9bbf7332ad0677a351f46030/custom_components/teufel_raumfeld/__init__.py#L169-L172

I think it would be better, if it only fails during configuration and pauses the setup during startup while polling for availability.

Can you confirm that it works as before, when forcing the validation from above to succeed?

alexludwigklein commented 3 years ago

Hi Marc,

your proposal seem valid, but unfortunately I don't understand what I should confirm and/or test. I just did another test and restarted the server while the teufel device responded to 'http://:47365/getZones' and the integration was sucessfully started.

Best, Alexander

B5r1oJ0A9G commented 3 years ago

Thanks for the feedback @alexludwigklein! Best, Marc

balk77 commented 3 years ago

is there a way to wake up a device so it gets properly detected? if host_is_not_valid --> wake up, wait x seconds, poll again.

B5r1oJ0A9G commented 3 years ago

is there a way to wake up a device so it gets properly detected?

A Raumfeld device configured as host cannot be switched off and will always be on to receive commands. Devices controlled by a host may turn to stand-by or be disabled. Since these devices, resp. speakers are controlled by the host, this does not impact their manageability. The power status of speakers can be managed via teufel_raumfeld.set_power_state. See: https://github.com/B5r1oJ0A9G/teufel_raumfeld/wiki#services

The issue here is rather that the configured Raumfeld host is not running (e.g. unplugged), not reachable or not properly setup as a Host on the device side.

balk77 commented 3 years ago

is there a way to wake up a device so it gets properly detected?

A Raumfeld device configured as host cannot be switched off and will always be on to receive commands. Devices controlled by a host may turn to stand-by or be disabled. Since these devices, resp. speakers are controlled by the host, this does not impact their manageability. The power status of speakers can be managed via teufel_raumfeld.set_power_state. See: https://github.com/B5r1oJ0A9G/teufel_raumfeld/wiki#services

The issue here is rather that the configured Raumfeld host is not running (e.g. unplugged), not reachable or not properly setup as a Host on the device side.

That is great news!

I have a single Raumfeld unit running (Connector 2) that goes asleep after x minutes of inactivity. It wakes when I start my favorite streaming service. I am experiencing exactly what is described in the OP. My thinking is to set the connector to on when restarting Home Assistant. The Teufel integration should then be able to find the Connector.

alias: 'Speakers: Raumfeld on at reboot'
description: ''
trigger:
  - platform: homeassistant
    event: shutdown
condition: []
action:
  - service: teufel_raumfeld.set_power_state
    data:
      entity_id: sensor.room_woonkamer_powerstate
      power_state: 'on'
mode: single

Just tested. Connector pops "on". But still the "Invalid Host" error 👎

B5r1oJ0A9G commented 3 years ago

@Ivanverdonck ,

I created a branch dev-grace-time-host-setup. In the commit 8973495 I implemented a grace time about 30 seconds to wait for the configured Raumfeld host to become ready. Can you please test whether this resolves your issue and report back?

B5r1oJ0A9G commented 3 years ago

@balk77 ,

Just tested. Connector pops "on". But still the "Invalid Host" error -1

Well, I have to admit that I cannot speak for the various possible Raumfeld setups. My setup is a One M as host and multiple One S connected to it. This is the setup teufel_raumfeld was developed around.

The Spotify issue #4 showed me a new and unexpected aspect already. There it was due to the fact that I am using Tidal and not Spotify.

Concernign the Connector I'd have expectd that whatever status the device claims to have, that it would still be available for requests by teufel_raumfeld. However, It could be that the behavior having a single Connector is different.

Could you perhaps test whether teufel_raumfeld is working after reboot, when having the validatoin removed - see https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues/8#issuecomment-835539614?

balk77 commented 3 years ago

Wait, I made a mistake. Do not read this :) (I made a copy of the teufel folder which was found by HA)

Could you perhaps test whether teufel_raumfeld is working after reboot, when having the validatoin removed - see #8 (comment)?

I have commented these 4 lines and tried with the Connector in eco mode (without my pre-shutdown automation) and in on mode. It works:

2021-05-20 20:28:38 WARNING (MainThread) [custom_components.teufel_raumfeld] You are using teufel_raumfeld, which is still in alpha phase and therefore subject to change. This includes, among other things, the addition, redesign or removal of functionality. 
2021-05-20 20:28:38 INFO (MainThread) [homeassistant.setup] Setup of domain teufe_raumfeld took 0.0 seconds 
2021-05-20 20:28:56 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.teufel_raumfeld 
2021-05-20 20:28:59 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.teufel_raumfeld  

The player is found

B5r1oJ0A9G commented 3 years ago

Thanks for the feedback @balk77! Could you then please also give it a try with the grace time mod mentioned in https://github.com/B5r1oJ0A9G/teufel_raumfeld/issues/8#issuecomment-844435997?

balk77 commented 3 years ago

Thanks for the feedback @balk77! Could you then please also give it a try with the grace time mod mentioned in #8 (comment)?

also works 👍 (I had the Connector on when restarting) and also works 👍 (with Connector eco when restarting)

Ivanverdonck commented 3 years ago

@B5r1oJ0A9G : I also tested "dev-grace-time-host-setup" , seems to work OK.

Thanks!

B5r1oJ0A9G commented 3 years ago

Thanks folks! I just merged the changes to the master branch.

alexludwigklein commented 3 years ago

That was fast, just my 50 cents: I have been testing your addition as well without any problems and avoiding any 'invalid host' problems

B5r1oJ0A9G commented 3 years ago

Thanks for the feedback @alexludwigklein! Glad we were able to find a quick solution.

Best, Marc