-
-
Notifications
You must be signed in to change notification settings - Fork 28.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSU Switch needed for remote shutdown the 3d printer #88142
Comments
Hey there @rfleming71, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) octoprint documentation |
Are you using a plugin to expose the power switch? I don't see anything on the octoprint API that exposes this functionality. I think there is a shutdown command, but that is for the OS and not the physical switch. |
Hi I am refering to add control to PSU control plugin for Octoprint. |
@VikeHsu I assume you might have resolved your problem already, but still this might be helpful to you and/or others: Using the PSU control HomeAssistant sub-plugin you can actually do the exact opposite: Define which switch in HomeAssistant should be toggled by Octopi when turning the PSU Control toggle on or off. So instead of home assistant calling an API within Octopi, this makes Octopi call the API of HomeAssistant (and will use polling to make sure that if if you toggle the switch from within HomeAssistant, the PSU state within Octopi is shown properly). It has been working great so far for me! |
@Didel and @VikeHsu As far as I can see, that only works for an external switch, ie. a powerplug where the printer is plugged in? |
This is of course also relevant to know for the code owner @rfleming71 :-) |
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. |
Hi, I’m also interested in having this functionality enabled in the integration (i.e. control the power state of the printer via API calls to OctoPrint, made available via the PSU Control plugin linked to by @VikeHsu). This scenario is the primary reason I want to have the OctoPrint integration in HA, so not supporting this yet is a bit of a bummer. |
Given the plugin supplies an API, this should be pretty straight forward to add. However, my instances of Octoprint at not supported given how I run them, so I am unable to test against a working instance. PRs are always welcome 😄 |
As much as I'd love to implement this myself, I just don't have time to learn the Home Assistant dev platform right now. 🙁 From what I can tell, I'm guessing adding this support would require adding an additional "switch" entity, where hitting the PSU Control API controls the switch's on/off state. There doesn't appear to be a great way to retrieve updated state if controlled outside HA (other than polling), but maybe a PR could add an option to PSU Control to POST to a custom endpoint when power is controlled? Just thinking out loud. If someone else can add the functionality, I may be able to help test it, and I could probably do some amount of debugging if something doesn't quite work. |
I could possibly (hopefully) add a bug fix too, if necessary. |
But isn't that exactly what is provided by the PSU control HomeAssistant sub-plugin ? To quote my earlier reply:
It works 2 ways: controlling the configured switch in home assistant will also toggle PSU control if needed, and enabling PSU control will toggle the switch in HA if needed. In my opinion, it should be up to Octoprint / PSU-control to make sure the correct plugin will be triggered to actually supply power, the HA plugin should only communicate an on/off state to a switch in HA (as it currently does) |
Thanks @Didel, but as @fribse noted above, this seems to only work when the power is controlled by an external device. The plugin's "sensing method" must be set to "plugin" for the integration to work, but when the power is controlled via a relay (controlled via GPIO on a raspberry pi, for example) the sensing method has to be set to GPIO or Internal. So for @fribse and me, that plugin won't do the job, and we're back to needing an integration that can invoke the API endpoints exposed by PSU Control directly. |
Hhm. @JohnathonMohr I think I get the problem. But then I don't think that this should be solved within Home Assistant. Instead, I think that the right place to solve this would be in the OctoPrint PSU Control plugin . There are 3 different things that need to happen:
In my opinion, the problem is that when using the Home Assistant PSU Control plugin, all three of those change to 'Home Assistant'. However, you are running in to the problem that you want to e.g. read and write using GPIO, but still want to have that exposed to Home Assistant (e.g. showing the current state, derived from GPIO, in HA, and being able to toggle the power via HA which will trigger PSU Control to send the correct signal over to GPIO). I think that should require a change in the setup of the PSU Control plugin for Octoprint, and not in the Octoprint plugin for Home Assistant. Edit: By the way, I also feel I should state that I am by no means associated with neither Home Assistant nor Octoprint (or any of its plug-ins). I'm just a fanatic user of both, and I happen to be a software developer myself with a 'strong' opinion on some topics. If one of the maintainers decides on another path, then I'll follow along 🙂 Edit 2: It also feels fair to hear @edekeijzer (developer of the PSU Control Home assistant plugin for Octoprint) about their opinion on the matter. |
Thanks @Didel for your thoughts! I had also looked into how this plugin worked, and took a look at the Octoprint package it was relying on (pyoctoprintapi), and the more I understood, the more I was coming to the same conclusion - having the integration here wasn't the best logical choice (even if it was the place of least effort). Instead, I decided to work around this manually using a combination of the REST Command integration, an automation with a helper toggle for a trigger, and a web hook trigger called from OctoPrint on Connecting and Disconnected events (in my case, the power being on and OctoPrint being connected are always correlated) so I can keep everything in sync. Not the most elegant, but it solves my use case. |
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. |
|
The problem
PSU Switch needed for remote shutdown the 3d printer
What version of Home Assistant Core has the issue?
2023.2.4
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
Octoprint
Link to integration documentation on our website
https://www.home-assistant.io/integrations/octoprint/
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
The text was updated successfully, but these errors were encountered: