Avoid key_error in modbus climate with non-defined fan_mode. (#110017)

This commit is contained in:
jan iversen 2024-02-09 08:39:08 +01:00 committed by GitHub
parent d049928be7
commit a0abc27612
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -364,7 +364,9 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
# Translate the value received
if fan_mode is not None:
self._attr_fan_mode = self._fan_mode_mapping_from_modbus[int(fan_mode)]
self._attr_fan_mode = self._fan_mode_mapping_from_modbus.get(
int(fan_mode), self._attr_fan_mode
)
# Read the on/off register if defined. If the value in this
# register is "OFF", it will take precedence over the value