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
73.52k stars 30.71k forks source link

Octoprint Sensors Read Unavailable when printer is off #59552

Closed DravenSA closed 1 year ago

DravenSA commented 2 years ago

The problem

Before OctoPrint was an Integration you could set the tool and the bed this way even if the printer was off you would not receive an "Entity is currently unavailable"

Please can this be fixed.

What version of Home Assistant Core has the issue?

core-2021.11.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

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

Example YAML snippet

octoprint:
  host: 192.168.0.XX
  api_key: XXXXXXXXX
  name: Ender 3V2
  number_of_tools: 1
  bed: 1

Anything in the logs that might be useful for us?

No response

Additional information

When it was YAML configured number of tools and bed could be configured as well as the name of the printer

probot-home-assistant[bot] commented 2 years ago

octoprint documentation octoprint source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

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

rfleming71 commented 2 years ago

Not sure this is a bug, if the printer is turned off, the entity has no meaning and is thus unavailable. Seems like the old version of the integration having not marked the entity as unavailable was the bug.

As for the name of the printer, the device/entity can be renamed via the UI.

DravenSA commented 2 years ago

Well i disagree that the old way was the bug

In the Old Octoprint documentation page it actually stated that if the following was in your config.yamal file

octoprint:   host: 192.168.0.xx   api_key: XXXXXXXXXXXXXXXXXXX

Would would basically activate all the sensor, BUT, if you wanted your printer to NOT be on all the time and you didnt want an "Unavailable" entity you could do it by specifying the bed/number_or_tools like follows

octoprint:   host: 192.168.0.XX   api_key: XXXXXXXXXXXXXXXXXX   number_of_tools: 1   bed: 1

Wither this made the entity not show as unavailable or if it just allowed the front end to have a "Zero" value i dont know, but what i do know is that my frontend gauge showed as a Gauge with a zero reading instead of the unsightly  error that show up on my frontend when the printer is off.

and should you only want specific sensors you could select from the following option in the config

octoprint:   host: 192.168.0.XX   api_key: XXXXXXXXXXXXXXXXXXX   name: Printer Name   number_of_tools: 1   bed: 1   sensors:     monitored_conditions:       - 'Current State'       - 'Temperatures'       - 'Time Elapsed'       - 'Time Remaining'       - 'Job Percentage'

I am no intergeneration code writer, but i do write in php so from what i can see is you could have a config for your integration with simple checkboxes for the sensors you want to show and a number value box for the number of tool and bed.

Hope this helps to make the necessary changes, I know other might not notice this if they are new to the octoprint integration, but for those of us that have used it in the past, you might find we also miss the "Time Remaining and the "Time elapsed"

On 2021/11/14 06:04, Ryan Fleming wrote:

Not sure this is a bug, if the printer is turned off, the entity has no meaning and is thus unavailable. Seems like the old version of the integration having not marked the entity as unavailable was the bug.

As for the name of the printer, the device/entity can be renamed via the UI.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/59552#issuecomment-968202009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGEIOCU5KE2MGQXMNJFY5ITUL4YMPANCNFSM5H25EV5A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mvdwetering commented 2 years ago

"Time Remaining and the "Time elapsed" have been replaced by "Start time" and "Estimated Finish Time" timestamp sensors (HA is moving away from time sensors that update every second). If you really need the the original ones you can re-build those with template sensors.

If you don't want to see some sensor entities you can just disable them through the HA UI (like any entity). Just go to the Configuration section, look for Octoprint integration, click entities then click an entitiy and then you can disable it with the toggle switch. Or in the list with entities you can select multiple and then choose "Disable selected"

DravenSA commented 2 years ago

I think the point has been missed.

On the front end is shows like this

With the old config .yaml you could set bed and number of tools to 1 like this octoprint:   host: 192.168.0.XX   api_key: XXXXXXXXXXXXXXXXXX   number_of_tools: 1   bed: 1 this would eliminate the error showing on the front end and it would just look like a "0" value

but now with the new integration these values cannot be set and thus it shows and unavailable when the printer is off. I dont understand why this would be a problem to fix, surely it can written to say " if bed is unavailable set value to ZERO, " same for the number of tools, this would improve the frontend look.

Regards

On 2021/11/17 17:33, Michel van de Wetering wrote:

"Time Remaining and the "Time elapsed" have been replaced by "Start time" and "Estimated Finish Time" timestamp sensors (HA is moving away from time sensors that update every second). If you /really/ need the the original ones you can re-build those with template sensors.

If you don't want to see some sensor entities you can just disable them through the HA UI (like any entity). Just go to the Configuration section, look for Octoprint integration, click entities then click an entitiy and then you can disable it with the toggle switch. Or in the list with entities you can select multiple and then choose "Disable selected"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/59552#issuecomment-971695187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGEIOCVZCZCOKDPN447SJLLUMPDNPANCNFSM5H25EV5A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rfleming71 commented 2 years ago

I understand what you are asking for, I just disagree with it. If the server cannot be be access for due to it being off or a networking issue, the whole integration is offline. The sensor has no meaning when the server cannot be accessed. 0 would not be an accurate value to report as we don't actually know what the value is.

DravenSA commented 2 years ago

So is there a way i can go back to the original config.Yamal settings, as this integration is taking over and supplying an ugly look to the front end. Agree or disagree with me all you want, but but being forced into using something that is ugly is not an option. At least make something that you can code into the display of a gauge like Offline, or Unavailable, but to leave it as that ERROR, is unsightly.

On 2021/11/18 14:20, Ryan Fleming wrote:

I understand what you are asking for, I just disagree with it. If the server cannot be be access for due to it being off or a networking issue, the whole integration is offline. The sensor has no meaning when the server cannot be accessed. 0 would not be an accurate value to report as we don't actually know what the value is.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/59552#issuecomment-972815846, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGEIOCVYMXBH76JOQWMK3Z3UMTVP5ANCNFSM5H25EV5A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

FreshJonte commented 2 years ago

I'm finding this an issue myself.

If the OctoPrint server is online and available but the printer is off, I would much rather have the current state as "Offline" or "Disconnected" instead of "Unavailable". It does not look nice and is quite confusing since "Unavailable" usually implies that the server is offline, which it is not.

cavamora commented 2 years ago
yogoo commented 2 years ago

@rfleming71: There is a confusion between the state of Octoprint and that of the printer.

Case 1: Printer = off ; Octoprint = reachable Case 2: Octoprint = unreachable

I took a quick look at the sensors from the integration. They are all focused on the printer and the print job. How about adding a sensor that would reflect the reachability of Octoprint's server? Something like "server_current_state" ? States could be "reachable, unreachable, unavailable". Unavailable would be for when there's an error with the integration (like all other integrations), "unreachable" for when the integration works but there's no response from Octoprint, and "reachable" for, well... when we're riding on awesomeness and everything works 💪🏻 🎉

Thoughts?

KitKat31337 commented 2 years ago

I show everything unavailable when octoprint is actually online and reachable, the printer is just off. I ultimately plan to control the printer power through octoprint, so I would think this is not a desirable to have everything unavailable.

rfleming71 commented 2 years ago

So the octoprint API throws errors when the print is disconnected from the actual server, so we don't have an idea of if the sensor even exists at that point. When the print connects back, it could be connected to a different print with more or less sensors (The more part should be handled, the less is the problem) Reporting a bed temp of 0.0 when the printer is offline is kinda odd as that implies the bed is frozen in ice when we really want to say we don't know if the sensor is there.

Some of the other sensors could likely get updated to report Unknown (Printer state, time remaining, etc) as they will always exist.

More sensors getting added that help with the automations around this/other use cases is always a good thing(more command/services/info about the server)

KitKat31337 commented 2 years ago

Was just peeking at the API, and the printer state returned has a bool that returns true if disconnected (flags.ClosedOrError). There is an api endpoint to try to connect as well, and the printer profile should shed some light on what sensors would be there. Though I believe capturing a map of the sensors from the last time the printer was connected and assuming using that to show what is available seems reasonable as well. And showing sensors as disconnected when the connection is off in octoprint.

The current reporting oc my octorpint device 'Current State' as unavailable is simply inaccurate. It would seem everything exists in the api to confidently display a status of Printer Disconnected. tool temps and bed temps etc, being unavailable is accurate, but I do believe the state could be more effectively communicated considering all of the above.

al-jimenez commented 2 years ago

I also have this issue and wish that it could be resolved. Thanks @yogoo for the clear definitions.

Something that may help in the interim with UI issues: I currently use a "conditional card" in lovelace dashboard to not show printer status until it is ON and OctoPrint is ACTIVE. But the issue still rears its ugly head when you look at the many log entries that things are not available when turned off. There has got to be a better way...

issue-triage-workflows[bot] commented 1 year 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.