diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 55890ff..14429f4 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -206,10 +206,10 @@ class HonNumberEntity(HonEntity, NumberEntity): isinstance(setting, HonParameter) or isinstance(setting, HonParameterFixed) ): setting.value = value - if "settings." in self.entity_description: - self._device.commands["settings"].send() + if "settings." in self.entity_description.key: + await self._device.commands["settings"].send() elif self._device.appliance_type in ["AC"]: - self._device.commands["startProgram"].send() + await self._device.commands["startProgram"].send() await self.coordinator.async_refresh() @callback diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 46d077f..e136ccf 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -165,10 +165,12 @@ class HonSelectEntity(HonEntity, SelectEntity): self.entity_description = description self._attr_unique_id = f"{super().unique_id}{description.key}" - if not isinstance(self._device.settings[description.key], HonParameterFixed): - self._attr_options: list[str] = device.settings[description.key].values + if not (setting := self._device.settings.get(description.key)): + self._attr_options: list[str] = [] + elif not isinstance(setting, HonParameterFixed): + self._attr_options: list[str] = setting.value else: - self._attr_options: list[str] = [device.settings[description.key].value] + self._attr_options: list[str] = [setting.value] @property def current_option(self) -> str | None: @@ -179,10 +181,10 @@ class HonSelectEntity(HonEntity, SelectEntity): async def async_select_option(self, option: str) -> None: self._device.settings[self.entity_description.key].value = option - if "settings." in self.entity_description: - self._device.commands["settings"].send() + if "settings." in self.entity_description.key: + await self._device.commands["settings"].send() elif self._device.appliance_type in ["AC"]: - self._device.commands["startProgram"].send() + await self._device.commands["startProgram"].send() await self.coordinator.async_refresh() @callback diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 7e872c9..494d815 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -392,10 +392,10 @@ class HonSwitchEntity(HonEntity, SwitchEntity): setting.max if isinstance(setting, HonParameterRange) else "1" ) self.async_write_ha_state() - if "settings." in self.entity_description: - self._device.commands["settings"].send() + if "settings." in self.entity_description.key: + await self._device.commands["settings"].send() elif self._device.appliance_type in ["AC"]: - self._device.commands["startProgram"].send() + await self._device.commands["startProgram"].send() await self.coordinator.async_refresh() else: await self._device.commands[self.entity_description.turn_on_key].send() @@ -407,10 +407,10 @@ class HonSwitchEntity(HonEntity, SwitchEntity): setting.min if isinstance(setting, HonParameterRange) else "0" ) self.async_write_ha_state() - if "settings." in self.entity_description: - self._device.commands["settings"].send() + if "settings." in self.entity_description.key: + await self._device.commands["settings"].send() elif self._device.appliance_type in ["AC"]: - self._device.commands["startProgram"].send() + await self._device.commands["startProgram"].send() await self.coordinator.async_refresh() else: await self._device.commands[self.entity_description.turn_off_key].send()