mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +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,17 +106,12 @@ class ModemCalleridSensor(SensorEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _async_incoming_call(self, new_state) -> None:
|
def _async_incoming_call(self, new_state) -> None:
|
||||||
"""Handle new states."""
|
"""Handle new states."""
|
||||||
if new_state == PhoneModem.STATE_RING:
|
self._attr_extra_state_attributes = {}
|
||||||
if self.native_value == PhoneModem.STATE_IDLE:
|
if self.api.cid_name:
|
||||||
self._attr_extra_state_attributes = {
|
self._attr_extra_state_attributes[CID.CID_NAME] = self.api.cid_name
|
||||||
CID.CID_NUMBER: "",
|
if self.api.cid_number:
|
||||||
CID.CID_NAME: "",
|
self._attr_extra_state_attributes[CID.CID_NUMBER] = self.api.cid_number
|
||||||
}
|
if self.api.cid_time:
|
||||||
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[CID.CID_TIME] = self.api.cid_time
|
||||||
self._attr_native_value = self.api.state
|
self._attr_native_value = self.api.state
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user