Skip to content

Commit

Permalink
Avoid key_error in modbus climate with non-defined fan_mode. (#110017)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored and frenck committed Feb 9, 2024
1 parent 7ff2f37 commit 4a18f59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion homeassistant/components/modbus/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ async def async_update(self, now: datetime | None = None) -> None:

# 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
Expand Down

0 comments on commit 4a18f59

Please sign in to comment.