Add unique_id to modbus entities (#64634)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>pull/64961/head
parent
4f8831f8f6
commit
16e5d7abe1
|
@ -42,6 +42,7 @@ from homeassistant.const import (
|
|||
CONF_TEMPERATURE_UNIT,
|
||||
CONF_TIMEOUT,
|
||||
CONF_TYPE,
|
||||
CONF_UNIQUE_ID,
|
||||
CONF_UNIT_OF_MEASUREMENT,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -122,6 +123,7 @@ BASE_COMPONENT_SCHEMA = vol.Schema(
|
|||
CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL
|
||||
): cv.positive_int,
|
||||
vol.Optional(CONF_LAZY_ERROR, default=0): cv.positive_int,
|
||||
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||
CONF_SCAN_INTERVAL,
|
||||
CONF_SLAVE,
|
||||
CONF_STRUCTURE,
|
||||
CONF_UNIQUE_ID,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -82,6 +83,7 @@ class BasePlatform(Entity):
|
|||
self._cancel_timer: Callable[[], None] | None = None
|
||||
self._cancel_call: Callable[[], None] | None = None
|
||||
|
||||
self._attr_unique_id = entry.get(CONF_UNIQUE_ID)
|
||||
self._attr_name = entry[CONF_NAME]
|
||||
self._attr_should_poll = False
|
||||
self._attr_device_class = entry.get(CONF_DEVICE_CLASS)
|
||||
|
|
Loading…
Reference in New Issue