Page 1 of 1
Help needed: Stopping a python plugin from its own source
Posted: Friday 12 September 2025 15:39
by jorknu
Hi,
I am currently developing a python plugin to read out some information from a WeHeat heatpump.
The plugin is based client library provided by WeHeat.
During the onStart procedure the plugin logs into the WeHeat backend using user credentials and starts using access and refresh tokens from this point onwards.
In case the initial login does not work, for example when the user enters invalid credentials (or changes them),
I would like to stop the plugin from this procedure so that it doesn't needlessly consume CPU cycles.
Currently I programmed a boolean member so it does not perform any work (throwing more exceptions since we are not logged in).
But this still requires the program to do "nothing" every 30 seconds.
So is there a way to completely stop the plugin from inside its source?
Re: Help needed: Stopping a python plugin from its own source
Posted: Monday 29 September 2025 16:03
by freekdk
Try ending the function with:
return False
Re: Help needed: Stopping a python plugin from its own source
Posted: Monday 29 September 2025 16:43
by pipiche
The way I'm doing is to use the /json.htm?type=command¶m=updatehardware" API
You can then Stop by seting "enabled" to False or Restart by setting "enabled" to True
note Use the complete set of parms that you find when entering the disable command on the GUI because if not completely entered it will remove data from the parms. Test on a test system first !!
Re: Help needed: Stopping a python plugin from its own source
Posted: Sunday 05 October 2025 10:20
by jorknu
@pipiche thanks for the suggestion I will try that.
Do you know if there is a reliable way to retrieve the address and port domoticz is running on?
I could try using localhost (or 127.0.0.1) as an address. But the port can be anything (in my case its 80, in the default its 8080, with HTTPs its usually 443)
Other question:
How can I list the plugin on the wiki so that other people can find it?
Re: Help needed: Stopping a python plugin from its own source
Posted: Sunday 05 October 2025 11:23
by gizmocuz
One way of doing this is requesting this information via mDNS (try the bonjour browser as example)
This reveals the IP address and port
Re: Help needed: Stopping a python plugin from its own source
Posted: Sunday 05 October 2025 16:22
by waltervl
jorknu wrote: Sunday 05 October 2025 10:20
@pipiche thanks for the suggestion I will try that.
Do you know if there is a reliable way to retrieve the address and port domoticz is running on?
I could try using localhost (or 127.0.0.1) as an address. But the port can be anything (in my case its 80, in the default its 8080, with HTTPs its usually 443)
Have the people fill in the Domoticz IP and Port in the plugin configuration.
jorknu wrote: Sunday 05 October 2025 10:20
Other question:
How can I list the plugin on the wiki so that other people can find it?
Announce it in a new forum topic and then I will add it to the wiki plugin list.
Re: Help needed: Stopping a python plugin from its own source
Posted: Monday 27 October 2025 20:39
by jorknu
waltervl wrote: Sunday 05 October 2025 16:22
Announce it in a new forum topic and then I will add it to the wiki plugin list.
Created a forum page, awaiting moderator approval.
waltervl wrote: Sunday 05 October 2025 16:22
Have the people fill in the Domoticz IP and Port in the plugin configuration.
Thanks for the suggestion I am trying to not expose this information via static variables.
It will break fairly quickly with for example DHCP for the address.
I am also trying to make it easy in use for the end user.
I think I will try the suggestion from pipiche and the suggestion from gizmocuz to lookup via zeroconf, mDns, bonjour (whatever you like to call it).
Maybe the AsyncZeroconf can help, aiohomekit uses it and I have been fiddling around with that library for the Tado maddness