home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.79k stars 30.04k forks source link

Hyperion components do not go "unavailable" when service is offline #98674

Open tracestep opened 1 year ago

tracestep commented 1 year ago

The problem

When I shut down my Hyperion service, the main instance light correctly shows "Unavailable". But the instance's switch components stay available, even though switching them do not have any effect. I believe the instance's components should follow the main instance and also be reported as unavailable when the service or server is offline, as do other switches when their device is offline.

What version of Home Assistant Core has the issue?

core-2023.8.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

hyperion

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hyperion

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @dermotduffy, mind taking a look at this issue as it has been labeled with an integration (hyperion) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `hyperion` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign hyperion` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


hyperion documentation hyperion source (message by IssueLinks)

N1c093 commented 1 year ago

@Sab44 Could you check this issue? I saw that you made the latest big changes inside the hyperion integration and introduced the new instance switches.

Thank you in advance.

Sab44 commented 1 year ago

Latest changes only affected the light entity, no changes were made to switches.

Having a quick look at the code it seems both light entity and switch entities have the same definition of the available property so without further investigation I don't know why they behave differently here. Maybe @dermotduffy can shed some light.

dermotduffy commented 1 year ago

When I shut down my Hyperion service

Are you gracefully shutting down Hyperion, or just pulling the plug? There were reports of the socket that HA uses to communicate with Hyperion not being detected as down in the latter case (just pulling the plug). This would impact lights / switches the same though, as @Sab44 said the availability detection is identical for both.

tracestep commented 1 year ago

I am shutting down the server gracefully with "poweroff" on a script run remotely by HA. Not sure if Hyperion itself is properly shut down, but I suppose so. Anyway, "unavailable" should eventually happen no matter what.

myB0B commented 11 months ago

same problem here, i'm using a pctv (windows 10) with hyperion install on it when pctv goes off (sleep mode) and on again when i use it, there is no update inside home assistant (hyperion device and entities are not working any more) I have to reboot home assistant to make it work again.

issue-triage-workflows[bot] commented 8 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

N1c093 commented 8 months ago

Still an active issue.

Is there anything needed to debug this problem?

myB0B commented 8 months ago

I use Node-RED to work around the issue by testing the availability of the PC on the network and sending the appropriate commands to the Hyperion API, as well as resetting the component in Home Assistant when the PC turns on.

koshisan commented 5 months ago

I use Node-RED to work around the issue by testing the availability of the PC on the network and sending the appropriate commands to the Hyperion API, as well as resetting the component in Home Assistant when the PC turns on.

Can you elaborate how? In my case I noticed that reloading just the component does not work - it needs to be the whole integration which does not seem to be possible, since core integrations cannot be reloaded seperately - so basically its a full HA restart every time my desktop PC wakes up after suspending...

myB0B commented 5 months ago

i use this HA automation where 'tv' is a room with hyperion device inside and switch.salon.tv is trigger by nodered ping to the esp8266 with WLED and PCTV with 60s delay

alias: Hyperion restart description: "" trigger:

koshisan commented 5 months ago

@myB0B thanks! However, it doesn't seem to work in my situation. Debug log states:

homeassistant.config_entries.OperationNotAllowed: The config entry 192.168.81.193:19444 (hyperion) with entry_id c206e161fef2f4b67cad83b4fd6a484b cannot be unloaded because it is not in a recoverable state (ConfigEntryState.FAILED_UNLOAD)

Its a bit puzzling how this is so poorly handled, because you would think that especially with a service like Hyperion that is used to sync TV/Monitor lights its pretty much a given that it is not available all the time...

myB0B commented 5 months ago

Sure, it's poorly handled ! Maybe one day it will be better, LOL. In my case, it takes a 60-second delay for all devices to be correctly identified on the LAN and accessible to Node-RED and Home Assistant. Did you wait long enough? Did you use a Room in HA to control Hyperion ? (If I remember correctly, I had to do it that way for it to work.)

koshisan commented 5 months ago

I did move them into a seperate 'room' specificially for this and I did wait several hours. Didn't work :( My problem might also be slightly different: Its not that the lights become unavailable after a Hyperion restart. They do stay online, it's just that they are completely ignoring all commands (which is a bummer, since its the backlight of my monitor I am controlling and I wanted to group it to the room lighting when not in sync-mode). Only when I send a restart command to the hyperion integration the lights become unavailable - and stay this way until a complete HA restart...

dermotduffy commented 5 months ago

From playing around with this briefly before, my suspicion was the underlying library (hyperion-py) was not detecting the socket going dead. If someone here has the time to investigate further -- that's where I'd start. PRs welcome.

ToniCipriani commented 5 months ago

From playing around with this briefly before, my suspicion was the underlying library (hyperion-py) was not detecting the socket going dead. If someone here has the time to investigate further -- that's where I'd start. PRs welcome.

I'm interested to help, if anything I was trying to look at the repo to add the Audio Capture that is now exposed on the API, but don't know where to start. I've cloned the repo and found a few places to modify the code, but don't know how to "build" and test it.

I'm having a similar issue where it randomly goes dead and I have to periodically reload the integration. Could be partly because my HA instance is running on a different VLAN than my Hyperion instance.

dermotduffy commented 5 months ago

I'm interested to help, if anything I was trying to look at the repo to add the Audio Capture that is now exposed on the API, but don't know where to start. I've cloned the repo and found a few places to modify the code, but don't know how to "build" and test it.

If you have installed the requirements_dev.txt dependencies in your environment, simply running poetry run pytest should run the unittests for that library. To build it poetry build. To test a forked instance of the library with a HA instance, it kind of depends on your setup, you could either copy the build artifact manually into (e.g. a test HA instance) and manually install it with pip, or possibly simpler/hackier might be to to just use docker to overlay your local copy of the library into the HA docker container, e.g. something like this:

    volumes:
      [...]
     - "/path/to/my/forked/library:/usr/local/lib/python3.11/site-packages/hyperion"

I am imagining the simplest path here might be find some way to have Python healthcheck the socket connection, or worst case occasionally ping/pong the connection and report when the health check fails.

Good luck!

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

N1c093 commented 2 months ago

This issue is not yet resolved and should stay open.