diff --git a/__init__.py b/__init__.py index 4f1f260..f629de6 100644 --- a/__init__.py +++ b/__init__.py @@ -35,8 +35,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): "coordinator": coordinator, "session": session } - await hass.config_entries.async_forward_entry_setup(entry, "sensor") - await hass.config_entries.async_forward_entry_setup(entry, "binary_sensor") + await hass.config_entries.async_forward_entry_setups(entry, ["sensor","binary_sensor"]) # hass.async_create_task( # hass.config_entries.async_forward_entry_setup(entry, "sensor") # ) @@ -45,5 +44,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): await hass.data[DOMAIN][entry.entry_id]["session"].close() - await hass.config_entries.async_forward_entry_unload(entry, "sensor") - return await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor") + return await hass.config_entries.async_unload_platforms(entry, ["binary_sensor","sensor"]) diff --git a/binary_sensor.py b/binary_sensor.py index 57acfc5..f466ca6 100644 --- a/binary_sensor.py +++ b/binary_sensor.py @@ -75,7 +75,7 @@ async def async_setup_entry(hass, entry, async_add_entities): )) - async_add_entities(sensors) + async_add_entities(sensors, update_before_add=True) class Sensor(CoordinatorEntity, BinarySensorEntity): def __init__(self, coordinator, deviceinfo, entry_id, id, family_key, device_key, name, device_class, state_class, native_unit_of_measurement, subkey=None): diff --git a/sensor.py b/sensor.py index a1ed767..6b99cf2 100644 --- a/sensor.py +++ b/sensor.py @@ -279,7 +279,7 @@ async def async_setup_entry(hass, entry, async_add_entities): )) - async_add_entities(sensors) + async_add_entities(sensors, update_before_add=True) class Sensor(CoordinatorEntity, SensorEntity): def __init__(self, coordinator, deviceinfo, entry_id, id, family_key, device_key, name, device_class, state_class, native_unit_of_measurement, subkey=None):