OctoPrint-HomeAssistant icon indicating copy to clipboard operation
OctoPrint-HomeAssistant copied to clipboard

Connect/Disconnect not working with OctoPrint 1.9.0

Open sendorm opened this issue 1 year ago • 14 comments

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.

sendorm avatar Jun 11 '23 22:06 sendorm

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.

sendorm avatar Jun 11 '23 22:06 sendorm

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.

elbotanico avatar Jun 15 '23 20:06 elbotanico

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.

sendorm avatar Jun 16 '23 14:06 sendorm

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:

consola

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.

elbotanico avatar Jun 16 '23 18:06 elbotanico

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.

jneilliii avatar Jun 18 '23 04:06 jneilliii

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".

sendorm avatar Jun 18 '23 06:06 sendorm

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.

jneilliii avatar Jun 18 '23 15:06 jneilliii

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.

sendorm avatar Jun 18 '23 16:06 sendorm

This fix definitely works in Home Assistant 2023.6.2, just tested my PR with the version compatibility stuff taken out.

jneilliii avatar Jun 18 '23 20:06 jneilliii

I meant up from which version is this fix needed. Somewhere around 2023.5 I think. Or octoprint 1.9.0 and above.

sendorm avatar Jun 18 '23 20:06 sendorm

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.

jneilliii avatar Jun 18 '23 21:06 jneilliii

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.

jneilliii avatar Jun 19 '23 03:06 jneilliii

Great find, thanks for clearing things out.

sendorm avatar Jun 19 '23 07:06 sendorm

Will close when your pr is merged :)

sendorm avatar Jun 19 '23 08:06 sendorm