mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix mode_callerid attributes (#57774)
* Allow mode_callerid to display number only * alphabetize * tweak * only include attr if there is data
This commit is contained in:
parent
85c6942f55
commit
f5e2960a92
@ -106,18 +106,13 @@ class ModemCalleridSensor(SensorEntity):
|
||||
@callback
|
||||
def _async_incoming_call(self, new_state) -> None:
|
||||
"""Handle new states."""
|
||||
if new_state == PhoneModem.STATE_RING:
|
||||
if self.native_value == PhoneModem.STATE_IDLE:
|
||||
self._attr_extra_state_attributes = {
|
||||
CID.CID_NUMBER: "",
|
||||
CID.CID_NAME: "",
|
||||
}
|
||||
elif new_state == PhoneModem.STATE_CALLERID:
|
||||
self._attr_extra_state_attributes = {
|
||||
CID.CID_NUMBER: self.api.cid_number,
|
||||
CID.CID_NAME: self.api.cid_name,
|
||||
}
|
||||
self._attr_extra_state_attributes[CID.CID_TIME] = self.api.cid_time
|
||||
self._attr_extra_state_attributes = {}
|
||||
if self.api.cid_name:
|
||||
self._attr_extra_state_attributes[CID.CID_NAME] = self.api.cid_name
|
||||
if self.api.cid_number:
|
||||
self._attr_extra_state_attributes[CID.CID_NUMBER] = self.api.cid_number
|
||||
if self.api.cid_time:
|
||||
self._attr_extra_state_attributes[CID.CID_TIME] = self.api.cid_time
|
||||
self._attr_native_value = self.api.state
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user