Open
Description
Hello and thanks for the awesome project. I've been hacking NodeManager to run nicely with HomeAssistant, but ran into a few problems that required altering the some of the core API and concepts of the NodeManager. So far I've fixed SensorDimmer and SensorNeopixel to play nicely with hass. Before opening a pull request I wanted to ask if these changes are okay, and what branch I should file them against. Here's the stuff I've put together so far:
- Sensors are made in a way that children always have a unique child id. Currently SensorDimmer exports 2 children for each dimmer. One with V_LEVEL, one with V_STATUS. HomeAssistant treats them as separate entities and expects a single child to accept and report both V_PERCENTAGE and V_STATUS for the light to show up.
To implement this I added a
Child* Sensor::getChild(uint8_t child_id, uint8_t ctype);
method to Sensor.cpp and made some changes so that it is called in a few parts of NodeManager to make use of the new variant of call. This allowed a sensor to have children with same IDs.
- HomeAssistant requires nodes to report their initial states to the controller before they can show up. For this to play nicely I added a special hack that reports all the states of the switches of the nodes at the very start. It is done on the very first iteration of the loop. Ideally, I want to make an option, so that the node requests initial states from the controller, and after receiving whatever states are available, reports everything once to the gateway.
Other minor fixes:
- SensorDimmer does dimming synchronous, with wait(). Receiving a few dimmer commands during actual fading results in a node crash, I've changed that for async operation.
- I've implemented a SensorParent sensor that exposes the node's current parent node. Having this sensors allows building nice topology charts (See one attached below)
Well, that's all.