I have been chasing down issues with z-wave, only to find out that the nodes were “dead” according to my controller, so the events were not being issued and the state was wrong. I would like to make a change to HA to show dead nodes. I’ve found where the controller is notifying that the node is dead. I have also added an attribute to the ZWaveDeviceEntity which correctly shows if the node is dead. Now… how do I get the UI to update with this information? The attribute never changes on the web page. It always shows the initial state (not dead). Is using an attribute the wrong way to do this?
Isn’t the state of the sensor showing as undefined for you if it disconnects?
No, it is set to whatever the last recorded value was.
ok… I have it working, but being a novice to Python, I’m not sure what to do here.
class ZWaveDeviceEntity:
"""Representation of a Z-Wave node entity."""
def __init__(self, value, domain):
"""Initialize the z-Wave device."""
from pydispatch import dispatcher
from openzwave.network import ZWaveNetwork
self._value = value
self.entity_id = "{}.{}".format(domain, self._object_id())
dispatcher.connect(
self.node_notification, ZWaveNetwork.SIGNAL_NOTIFICATION)
def node_notification(self, args):
_LOGGER.info("dwknode2 notication - " + self.name + " " + PrettyPrinter().pformat(args))
_LOGGER.info("dwknode3 notication - " + str(args['nodeId']) + " " + str(self._value.node.node_id))
if args['nodeId'] == self._value.node.node_id:
self.update_ha_state(True)
So, this basically fixes it, once I added the necessary attributes. However, update_ha_state is a function of entity.py, which ZWaveDeviceEntity does not inherit from. However, all instantiated objects end up being inherited from entity due to multiple inheritance, so it does work, but it isn’t correct. How do you “correctly” use a function that I know will be available, but isn’t part of this class?
In reading around, it looks like there isn’t much I can do besides hide the warning.
Now… to figure out how to submit my change…