Page 1 of 1

Webserver within plugin? - For receiving external events

Posted: Sunday 26 March 2017 11:02
by swevm
Hi,

Have just started to explore what can be done with the Python plugin capabilities. An awesome thing if you ask me as it open up much more ways to integrate stuff and in a way that is simpler due to Python vs C++.

I have a device from Teracom that is basically a ethernet connected IO device with relays, 1-wire and digital inputs together with rudimentary automation. For example a relay can be triggered if a temperature is reached on a 1-wire sensor or if a digital input state is changed etc.

The plugin I am planning to write will leverage these capabilities to configure an autonomous control system for a pool heater integrated with heatpump (water-water variant, a type very common the Nordics). Doing the actual configuration should not be the hard part as the device have defined APIs to control pretty much anything in it. The harder part which causes headache for me is to handle events coming from the Teracom unit in the form of SNMP traps or state data sent to an arbitrary URL.

My question is what is the best way to capture state change information coming in from external devices with Domoticz. The optimal way (at least how I think about it) would be to have a tiny webserver running within the plugin that the unit can post changes to and then data is immediately captured by plugin and processed. Not sure what issues this may cause with threading and lockups and before I start looking at I´m interested in hearing about ideas from the community here.

/Magnus

Re: Webserver within plugin? - For receiving external events

Posted: Wednesday 29 March 2017 13:35
by Dnpwwo
@swevm,

Adding the ability to 'Listen' for incoming connections is on the enhancement list but not there yet, as is UDP.

The current framework would probably not work with you embedding a web server, async and threading operations will have unknown effects (like, no idea what that would do, probably bad things).

A full blown web server might be a little tricky to add, SNMP support via UDP would be easier.

Re: Webserver within plugin? - For receiving external events

Posted: Wednesday 29 March 2017 14:09
by jorgh
@Dnpwwo,

If UDP is on the enhancement list, could you also take into account to send and receive network broadcasts? As a lot of IP based devices have a discovery protocol based on UDP broadcasts, this will allow auto configuration of plugins (I now wrote this myself on the Onkyo plugin). Also nice on networks where DHCP might issue changing IP's.

Regards,

Jorg