Skip to content

Commit

Permalink
fix: relay (#107)
Browse files Browse the repository at this point in the history
* fix: relay

* fix: relay
  • Loading branch information
acesyde authored Feb 16, 2024
1 parent af310bf commit 226aa89
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/mylight_systems/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NAME = "MyLight Systems"
DOMAIN = "mylight_systems"
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
VERSION = "0.1.0"
VERSION = "0.1.1"
COORDINATOR = "coordinator"
ATTRIBUTION = "Data provided by https://www.mylight-systems.com/"
SCAN_INTERVAL_IN_MINUTES = 15
Expand Down
14 changes: 7 additions & 7 deletions custom_components/mylight_systems/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,9 +78,7 @@ async def _async_update_data(self) -> MyLightSystemsCoordinatorData:
virtual_battery_id = self.config_entry.data[
CONF_VIRTUAL_BATTERY_ID
]
master_relay_id = self.config_entry.data[
CONF_MASTER_RELAY_ID
]
master_relay_id = self.config_entry.data.get(CONF_MASTER_RELAY_ID, None)

await self.authenticate_user(email, password)

Expand All @@ -92,9 +90,11 @@ async def _async_update_data(self) -> MyLightSystemsCoordinatorData:
self.__auth_token, virtual_battery_id
)

master_relay_state = await self.client.async_get_relay_state(
self.__auth_token, master_relay_id
)
master_relay_state = None
if master_relay_id is not None:
master_relay_state = await self.client.async_get_relay_state(
self.__auth_token, master_relay_id
)

data = MyLightSystemsCoordinatorData(
produced_energy=self.find_measure_by_type(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/mylight_systems/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"documentation": "https://github.com/acesyde/hassio_mylight_integration",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/acesyde/hassio_mylight_integration/issues",
"version": "0.1.0"
"version": "0.1.1"
}
2 changes: 1 addition & 1 deletion custom_components/mylight_systems/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mylight_systems"
version = "0.1.0"
version = "0.1.1"
description = "MyLight Systems integration for Home Assistant"
authors = ["Pierre-Emmanuel Mercier <acesyde@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit 226aa89

Please sign in to comment.