diff --git a/custom_components/mylight_systems/coordinator.py b/custom_components/mylight_systems/coordinator.py index 07a7709..4090a46 100644 --- a/custom_components/mylight_systems/coordinator.py +++ b/custom_components/mylight_systems/coordinator.py @@ -43,7 +43,7 @@ class MyLightSystemsCoordinatorData(NamedTuple): msb_discharge: Measure green_energy: Measure battery_state: Measure - master_relay_state: str + master_relay_state: str | None # https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities diff --git a/custom_components/mylight_systems/switch.py b/custom_components/mylight_systems/switch.py index a00ee09..c3d2df6 100644 --- a/custom_components/mylight_systems/switch.py +++ b/custom_components/mylight_systems/switch.py @@ -38,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e switches: list[MyLightSystemsSwitchEntityDescription] = [] - if entry.data[CONF_MASTER_RELAY_ID] is not None: + if entry.data.get(CONF_MASTER_RELAY_ID, None) is not None: switches.append(master_relay_switch) async_add_entities(