Add GoodWe async_update support to number/select entities (#116739)

This commit is contained in:
mletenay 2024-06-22 12:27:32 +02:00 committed by GitHub
parent 0feead385a
commit f676760ab1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -131,6 +131,11 @@ class InverterNumberEntity(NumberEntity):
self._attr_native_value = float(current_value)
self._inverter: Inverter = inverter
async def async_update(self) -> None:
"""Get the current value from inverter."""
value = await self.entity_description.getter(self._inverter)
self._attr_native_value = float(value)
async def async_set_native_value(self, value: float) -> None:
"""Set new value."""
await self.entity_description.setter(self._inverter, int(value))

View File

@ -89,6 +89,11 @@ class InverterOperationModeEntity(SelectEntity):
self._attr_current_option = current_mode
self._inverter: Inverter = inverter
async def async_update(self) -> None:
"""Get the current value from inverter."""
value = await self._inverter.get_operation_mode()
self._attr_current_option = _MODE_TO_OPTION[value]
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self._inverter.set_operation_mode(_OPTION_TO_MODE[option])