Access other devices from a python plugin

Python and python framework

Moderator: leecollings

Post Reply
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Access other devices from a python plugin

Post by ycahome »

Hi,

am trying to find any info regarding access (read/update) existing devices from a python plugin without success.
Has anyone any clue about that?

thanks
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Access other devices from a python plugin

Post by emme »

I think you cannot....

Python plugins has granted access to a restricted sets of devices: theirs! :P
and some settings option :)

The reason is simple: by design, interaction between devices form different hardware MUST be performed by the server, not by hardware (or plugins)

If you want to interact between different hardward devices, use an external script... or LUA
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Access other devices from a python plugin

Post by ycahome »

Hello emme.

Although, what you said seems reasonable, I can now interact with the rest of the hardware via API calls. But, If I do that, what's the difference from a plugin? Both can cause the problems you mentioned.
+ would be better to use internal functions than unmanaged API http calls.

My intention was to build a plugin that will time when a switch device is on (and give day, week , month, year usage), something that is missing from native code.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Access other devices from a python plugin

Post by Dnpwwo »

@ycahome,

I believe that would be done much easier in Lua. You can write a script that is notified of all device events which sounds perfect for what you want to do.

As emme has said, the plugin framework is designed for interfacing external hardware to Domoticz. Plugins only see their own devices as a control to stop bugs impacting other devices and trashing a user's system
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: Bing [Bot], boum and 1 guest