I am trying to add support for a currently unsupported class of device. It includes lights and switches. I can easily control the lights and switches using one of the existing platforms. Using REST, for example, allows me to send commands to these devices by implementing a web server (to handle the REST calls), which in turn sends commands to a node.js based driver for the devices.
But I have two issues:
- How to get “events” from these devices back to HA (i.e. when someone physically turns on a switch, HA needs to know, so it can update its internal status for that switch). Note that I don’t want to poll for status updates.
- I’d like to eliminate the separate web server and node.js code, instead moving to a python-based driver with “tighter” integration with HA (porting the driver to python isn’t the problem).
For (#2), it’s my understanding (from https://home-assistant.io/developers/add_new_platform) that what’s needed is a new “platform” script. I think starting with something like https://github.com/home-assistant/home-assistant/tree/master/homeassistant/components/switch or /light is what’s needed for the control part (right?).
But what about “events” (#1)? It does not appear to me that these “platform” scripts handle this “event” feedback. So does that mean I also need to write a platform script here (https://github.com/home-assistant/home-assistant/tree/master/homeassistant/components/sensor)? Or do the switch and light scripts handle the “events” (if so, what’s a good/clean example of one that does this)?
I’ve read just about everything I could find that relates to HA and platforms, but I’m just not clear on exactly what needs to be written. A switch and light scripts, and a sensor script? Or something else entirely?