Fix errors in changing settings
This commit is contained in:
parent
e777fe1ec9
commit
9a65eaba77
3 changed files with 17 additions and 15 deletions
|
@ -206,10 +206,10 @@ class HonNumberEntity(HonEntity, NumberEntity):
|
||||||
isinstance(setting, HonParameter) or isinstance(setting, HonParameterFixed)
|
isinstance(setting, HonParameter) or isinstance(setting, HonParameterFixed)
|
||||||
):
|
):
|
||||||
setting.value = value
|
setting.value = value
|
||||||
if "settings." in self.entity_description:
|
if "settings." in self.entity_description.key:
|
||||||
self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
elif self._device.appliance_type in ["AC"]:
|
elif self._device.appliance_type in ["AC"]:
|
||||||
self._device.commands["startProgram"].send()
|
await self._device.commands["startProgram"].send()
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -165,10 +165,12 @@ class HonSelectEntity(HonEntity, SelectEntity):
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
self._attr_unique_id = f"{super().unique_id}{description.key}"
|
||||||
|
|
||||||
if not isinstance(self._device.settings[description.key], HonParameterFixed):
|
if not (setting := self._device.settings.get(description.key)):
|
||||||
self._attr_options: list[str] = device.settings[description.key].values
|
self._attr_options: list[str] = []
|
||||||
|
elif not isinstance(setting, HonParameterFixed):
|
||||||
|
self._attr_options: list[str] = setting.value
|
||||||
else:
|
else:
|
||||||
self._attr_options: list[str] = [device.settings[description.key].value]
|
self._attr_options: list[str] = [setting.value]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_option(self) -> str | None:
|
def current_option(self) -> str | None:
|
||||||
|
@ -179,10 +181,10 @@ class HonSelectEntity(HonEntity, SelectEntity):
|
||||||
|
|
||||||
async def async_select_option(self, option: str) -> None:
|
async def async_select_option(self, option: str) -> None:
|
||||||
self._device.settings[self.entity_description.key].value = option
|
self._device.settings[self.entity_description.key].value = option
|
||||||
if "settings." in self.entity_description:
|
if "settings." in self.entity_description.key:
|
||||||
self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
elif self._device.appliance_type in ["AC"]:
|
elif self._device.appliance_type in ["AC"]:
|
||||||
self._device.commands["startProgram"].send()
|
await self._device.commands["startProgram"].send()
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -392,10 +392,10 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
|
||||||
setting.max if isinstance(setting, HonParameterRange) else "1"
|
setting.max if isinstance(setting, HonParameterRange) else "1"
|
||||||
)
|
)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
if "settings." in self.entity_description:
|
if "settings." in self.entity_description.key:
|
||||||
self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
elif self._device.appliance_type in ["AC"]:
|
elif self._device.appliance_type in ["AC"]:
|
||||||
self._device.commands["startProgram"].send()
|
await self._device.commands["startProgram"].send()
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
else:
|
else:
|
||||||
await self._device.commands[self.entity_description.turn_on_key].send()
|
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"
|
setting.min if isinstance(setting, HonParameterRange) else "0"
|
||||||
)
|
)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
if "settings." in self.entity_description:
|
if "settings." in self.entity_description.key:
|
||||||
self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
elif self._device.appliance_type in ["AC"]:
|
elif self._device.appliance_type in ["AC"]:
|
||||||
self._device.commands["startProgram"].send()
|
await self._device.commands["startProgram"].send()
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
else:
|
else:
|
||||||
await self._device.commands[self.entity_description.turn_off_key].send()
|
await self._device.commands[self.entity_description.turn_off_key].send()
|
||||||
|
|
Loading…
Reference in a new issue