Add entity translations to Modem callerID (#98798)
parent
b885dfa5a8
commit
c025244ac1
|
@ -7,6 +7,7 @@ from homeassistant.components.button import ButtonEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_DEVICE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DATA_KEY_API, DOMAIN
|
||||
|
@ -32,13 +33,15 @@ class PhoneModemButton(ButtonEntity):
|
|||
"""Implementation of USB modem caller ID button."""
|
||||
|
||||
_attr_icon = "mdi:phone-hangup"
|
||||
_attr_name = "Phone Modem Reject"
|
||||
_attr_translation_key = "phone_modem_reject"
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, api: PhoneModem, device: str, server_unique_id: str) -> None:
|
||||
"""Initialize the button."""
|
||||
self.device = device
|
||||
self.api = api
|
||||
self._attr_unique_id = server_unique_id
|
||||
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, server_unique_id)})
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.sensor import SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, STATE_IDLE
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import CID, DATA_KEY_API, DOMAIN, ICON
|
||||
|
@ -21,7 +22,6 @@ async def async_setup_entry(
|
|||
[
|
||||
ModemCalleridSensor(
|
||||
api,
|
||||
entry.title,
|
||||
entry.entry_id,
|
||||
)
|
||||
]
|
||||
|
@ -42,11 +42,12 @@ class ModemCalleridSensor(SensorEntity):
|
|||
|
||||
_attr_icon = ICON
|
||||
_attr_should_poll = False
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, api: PhoneModem, name: str, server_unique_id: str) -> None:
|
||||
def __init__(self, api: PhoneModem, server_unique_id: str) -> None:
|
||||
"""Initialize the sensor."""
|
||||
self.api = api
|
||||
self._attr_name = name
|
||||
self._attr_unique_id = server_unique_id
|
||||
self._attr_native_value = STATE_IDLE
|
||||
self._attr_extra_state_attributes = {
|
||||
|
@ -54,6 +55,7 @@ class ModemCalleridSensor(SensorEntity):
|
|||
CID.CID_NUMBER: "",
|
||||
CID.CID_NAME: "",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, server_unique_id)})
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call when the modem sensor is added to Home Assistant."""
|
||||
|
|
|
@ -20,5 +20,12 @@
|
|||
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||
"no_devices_found": "No remaining devices found"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"button": {
|
||||
"phone_modem_reject": {
|
||||
"name": "Phone modem reject"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue