def extra_state_attributes(self) -> dict: """Get the state attributes for the device. The 'aux_properties' in the pyisy Node class are combined with the other attributes which have been picked up from the event stream and the combined result are returned as the device state attributes. """ attr = {} if hasattr(self._node, "aux_properties"): # Cast as list due to RuntimeError if a new property is added while running. for name, value in list(self._node.aux_properties.items()): attr_name = COMMAND_FRIENDLY_NAME.get(name, name) attr[attr_name] = str(value.formatted).lower() # If a Group/Scene, set a property if the entire scene is on/off if hasattr(self._node, "group_all_on"): attr["group_all_on"] = STATE_ON if self._node.group_all_on else STATE_OFF self._attrs.update(attr) return self._attrs
def extra_state_attributes(self) -> dict: """Get the state attributes for the device. The 'aux_properties' in the pyisy Node class are combined with the other attributes which have been picked up from the event stream and the combined result are returned as the device state attributes. """ attr = {} node = self._node # Insteon aux_properties are now their own sensors if ( hasattr(self._node, "aux_properties") and getattr(node, "protocol", None) != PROTO_INSTEON ): for name, value in self._node.aux_properties.items(): attr_name = COMMAND_FRIENDLY_NAME.get(name, name) attr[attr_name] = str(value.formatted).lower() # If a Group/Scene, set a property if the entire scene is on/off if hasattr(self._node, "group_all_on"): attr["group_all_on"] = STATE_ON if self._node.group_all_on else STATE_OFF self._attrs.update(attr) return self._attrs
def valid_isy_commands(value: Any) -> str: """Validate the command is valid.""" value = str(value).upper() if value in COMMAND_FRIENDLY_NAME.keys(): return value raise vol.Invalid("Invalid ISY Command.")
def name(self) -> str: """Get the name of the device and aux sensor.""" base_name = self._name or str(self._node.name) name = COMMAND_FRIENDLY_NAME.get(self._control, self._control) return f"{base_name} {name.replace('_', ' ').title()}"