Page 1 of 1

Gettign the value from a temperature device in a python plugin

Posted: Saturday 15 May 2021 15:20
by akamming
Hi,

i am trying to write a python plugin which derives the needed boiler temp from an outside temperature device

however i cannot find a way how to get access to a temperature sensor which was not created by the pluing (e.g. i have a idx number from the temperature sensor, how can i get the value of that sensor in a python plugin)

Does someone have some sample code i can use?

Re: Gettign the value from a temperature device in a python plugin

Posted: Saturday 15 May 2021 20:56
by pipiche
A plugin can only see its own devices. Is really a plugin you need ? Or a python/lua/dzVent script would be better ?

Otherwise you can use jsonnAPI inside the plugin ( which I don’t think is great)


Envoyé de mon iPhone en utilisant Tapatalk

Re: Gettign the value from a temperature device in a python plugin

Posted: Sunday 16 May 2021 20:59
by akamming
pipiche wrote: Saturday 15 May 2021 20:56 A plugin can only see its own devices. Is really a plugin you need ? Or a python/lua/dzVent script would be better ?

Otherwise you can use jsonnAPI inside the plugin ( which I don’t think is great)
Tx. i could fix with a python/lua/dzvents script, but i really like the fact that the plugin creates and manages it's own devices. Saves a lot of manual work creating the virtual devices.

I already used the json API as a workaround. It works, but requires that the plugin know the IP Adress and port from the domoticz instance. It is now a configurable parameter in the plugin, but it would be better if this could be retrieved from the domoticz config within the python code. Does anyone know how?

Re: Gettign the value from a temperature device in a python plugin

Posted: Sunday 16 May 2021 21:33
by waaren

akamming wrote: Saves a lot of manual work creating the virtual devices.
A lot of work?
Takes about 20 seconds per device (if you type as slow as me) Image





Re: Gettign the value from a temperature device in a python plugin

Posted: Monday 17 May 2021 7:13
by akamming
waaren wrote: Sunday 16 May 2021 21:33 A lot of work?
Takes about 20 seconds per device (if you type as slow as me) Image
and multiply that by 25 virtual devices :D

besides now i don't get error's on this script if i accidentally delete a device, it is recreated by the plugin.

Re: Gettign the value from a temperature device in a python plugin

Posted: Wednesday 25 August 2021 14:36
by Masure
I had the same concern and created a topic : viewtopic.php?f=65&t=35121

Getting access to other devices state with read only access from a plugin would be very useful.

Re: Gettign the value from a temperature device in a python plugin

Posted: Wednesday 25 August 2021 15:39
by waltervl
Masure wrote: Wednesday 25 August 2021 14:36 I had the same concern and created a topic : viewtopic.php?f=65&t=35121

Getting access to other devices state with read only access from a plugin would be very useful.
A plugin is only to be used to create and control the related hardware. Of you want to control/modify devices based on other devices you need scripting like Blockly, Lua, DzVents etc who have a view over all Domoticz devices.
If you accidentally would like to use one then the http API way of working would do.
It is the same for C++ Hardware plugins I presume.