OctoPrint-HomeAssistant
OctoPrint-HomeAssistant copied to clipboard
Connect/Disconnect not working with OctoPrint 1.9.0
The current version sends "off" and "on" to "octoPrint/hassControl/connect" topic. This does not work anymore.
But: Currently sending: to topic "octoPrint/hassControl/connect" -> "True", connects and "False" disconnects.
Can this be fixed. Thank you.
I've managed to fix the issue by updating "homeassistant/switch/XXXXXX_CONNECT/config" to
{ "pl_off": "False", "pl_on": "True", }
formerly is was on and off.
Could you please guide me on how to update the information? I am experiencing the same issue and I am a bit unfamiliar with custom configurations. Where can I find the 'homeassistant/switch/XXXXXX_CONNECT/config'? Is it located in the config editor? Additionally, where should I insert the following information? { "pl_off": "False", "pl_on": "True" } Apologies for all the questions, but I'm trying to resolve the same problem. Thank you for your assistance.
The answer I gave was related to mqtt config. You have to use a program like MQTT-Explorer and find the related message and compile a message as written above. But that solution turned out to be temporary.
The real solution is this: you have to login to your pi.
cd ./oprint/lib/python3.7/site-packages/octoprint_homeassistant (this depends on your python version, you can use find octoprint_homeassistant)
nano __init__.py press ctrl+w and type: "pl_off": "off" check that this is inside switch change it to "pl_off": "False", "pl_on": "True",
ctrl+x and save.
Now you are good to go. Hopefully someone updates the code and this takes place.
This method worked like a charm. First, navigate to the directory in question. For me, the version was Python 3.9, so I used the following command to reach the directory:
"cd ./oprint/lib/python3.9/site-packages/octoprint_homeassistant"
Afterward, I utilized the command "nano init.py" and conducted a search. In my particular scenario, the file appeared as shown in the image below after I made modifications to the values:
Subsequently, I executed a system reboot using the "sudo reboot" command. Upon trying the buttons in Home Assistant, everything functioned properly. I truly appreciate the time and knowledge you've shared to explain this process.
Just to confirm, this wasn't an issue in OctoPrint 1.8.7 but became a problem with 1.9.0? I have a potential PR ready to go with these changes in a version compatible method that won't break it for older versions if users haven't upgraded OctoPrint yet.
This might also be a problem related solely depending on changes related to homeassistant. Both my updates were done on similar dates so I can't point out which one caused the issue.
I think (but this also needs confirmation) the changes will be compatible, it is just the way homeassistant handles switches. "off" was working before now they need "False".
Ah, so it's a home assistant change that broke it, so my octoprint version matching is unneeded. Not sure if there is a way to check HA versioning and then react accordingly.
I am not certain but this change should not be affecting older versions of hass. If people with problem can write which version they have, we can pinpoint the culprit.
This fix definitely works in Home Assistant 2023.6.2, just tested my PR with the version compatibility stuff taken out.
I meant up from which version is this fix needed. Somewhere around 2023.5 I think. Or octoprint 1.9.0 and above.
You're right, it does appear that it is an OctoPrint 1.9.0 issue maybe. I installed the original un-patched version in 1.8.7 and it works fine. My patch has been adjusted to take version into account and should be able to work for everybody.
Actually, I think this issue may have been introduced with the latest version of this plugin. The changes merged in this PR seems to have changed the logic.
Great find, thanks for clearing things out.
Will close when your pr is merged :)