Help needed: Stopping a python plugin from its own source

Python and python framework

Moderator: leecollings

Post Reply
jorknu
Posts: 5
Joined: Friday 12 September 2025 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.2
Location: NL
Contact:

Help needed: Stopping a python plugin from its own source

Post 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?
freekdk
Posts: 33
Joined: Monday 01 February 2021 16:33
Target OS: Linux
Domoticz version: V2025.1
Location: Netherlands
Contact:

Re: Help needed: Stopping a python plugin from its own source

Post by freekdk »

Try ending the function with:

return False
pipiche
Posts: 2027
Joined: Monday 02 April 2018 20:33
Target OS: Linux
Domoticz version:

Re: Help needed: Stopping a python plugin from its own source

Post by pipiche »

The way I'm doing is to use the /json.htm?type=command&param=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 !!
jorknu
Posts: 5
Joined: Friday 12 September 2025 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.2
Location: NL
Contact:

Re: Help needed: Stopping a python plugin from its own source

Post 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?
User avatar
gizmocuz
Posts: 2707
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Help needed: Stopping a python plugin from its own source

Post 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
Quality outlives Quantity!
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Help needed: Stopping a python plugin from its own source

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jorknu
Posts: 5
Joined: Friday 12 September 2025 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.2
Location: NL
Contact:

Re: Help needed: Stopping a python plugin from its own source

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest