Skip to content

Commit

Permalink
Fix unknown error when update sensor config
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldotnl committed Apr 5, 2024
1 parent 3267d25 commit d0e1a35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/measureit/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ async def validate_sensor_edit(
# Standard behavior is to merge the result with the options.
# In this case, we want to add a sub-item so we update the options directly.
idx: int = handler.flow_state["_idx"]
if handler.options[SENSOR_DOMAIN][idx][CONF_UNIT_OF_MEASUREMENT] != user_input.get(CONF_UNIT_OF_MEASUREMENT):
if handler.options[SENSOR_DOMAIN][idx][CONF_DEVICE_CLASS] and user_input.get(CONF_DEVICE_CLASS) is not None:
if handler.options[SENSOR_DOMAIN][idx].get(CONF_UNIT_OF_MEASUREMENT) != user_input.get(CONF_UNIT_OF_MEASUREMENT):
if handler.options[SENSOR_DOMAIN][idx].get(CONF_DEVICE_CLASS) and user_input.get(CONF_DEVICE_CLASS) is not None:
raise SchemaFlowError("uom_with_device_class_update")
handler.options[SENSOR_DOMAIN][idx].update(user_input)
for key in DATA_SCHEMA_EDIT_SENSOR.schema:
Expand Down

0 comments on commit d0e1a35

Please sign in to comment.