(self, event_entity_id: str)
return device
Serialize entity for a notification.
Serialize entity for a notification.
Serialize entity for a notification .
def notification_serialize(self, event_entity_id: str) -> dict[str, Any]:
        """Serialize entity for a notification."""
        if self.state.state == STATE_UNAVAILABLE:
            return {'id': self.state.entity_id, 'error_code': ERR_DEVICE_UNREACHABLE}

        device = {
            'id': self.entity_id,
            'capabilities': [],
            'properties': [],
        }

        for item in [c for c in self.capabilities() if c.reportable]:
            state = item.get_state()
            if state is not None:
                device['capabilities'].append(state)

        for item in [c for c in self.properties() if c.reportable]:
            if isinstance(item, CustomEntityProperty):
                if item.property_entity_id != event_entity_id:
                    continue
            elif item.state.entity_id != event_entity_id:
                continue

            state = item.get_state()
            if state is not None:
                device['properties'].append(state)

        return device
def notification_serialize ( self , event_entity_id : str ) -> dict [ str , Any ] : if self . state . state == STATE_UNAVAILABLE : return { 'id' : self . state . entity_id , 'error_code' : ERR_DEVICE_UNREACHABLE } device = { 'id' : self . entity_id , 'capabilities' : [ ] , 'properties' : [ ] , } for item in [ c for c in self . capabilities ( ) if c . reportable ] : state = item . get_state ( ) if state is not None : device [ 'capabilities' ] . append ( state ) for item in [ c for c in self . properties ( ) if c . reportable ] : if isinstance ( item , CustomEntityProperty ) : if item . property_entity_id != event_entity_id : continue elif item . state . entity_id != event_entity_id : continue state = item . get_state ( ) if state is not None : device [ 'properties' ] . append ( state ) return device