Skip to content

Commit

Permalink
Throttle valve open percentage.
Browse files Browse the repository at this point in the history
Avoids overloading HASS'es db in case of value bounce.
  • Loading branch information
denpamusic committed Dec 13, 2023
1 parent 67906cf commit f689f6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/plum_ecomax/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ class RegdataSensorEntityDescription(EcomaxSensorEntityDescription):
RegdataSensorEntityDescription(
key=134,
translation_key="mixer_valve_opening_percentage",
filter_fn=lambda x: throttle(on_change(x), seconds=UPDATE_INTERVAL),
native_unit_of_measurement=PERCENTAGE,
product_models={ProductModel.ECOMAX_860P6_O},
state_class=SensorStateClass.MEASUREMENT,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,7 @@ async def test_mixer_valve_opening_percentage_sensor_ecomax_860p6_o(
connection: EcomaxConnection,
config_entry: MockConfigEntry,
setup_integration,
frozen_time,
) -> None:
"""Test mixer valve opening percentage sensor for ecoMAX 860P6-O."""
await setup_integration(hass, config_entry)
Expand All @@ -1260,6 +1261,7 @@ async def test_mixer_valve_opening_percentage_sensor_ecomax_860p6_o(
assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT

# Dispatch new value.
frozen_time.move_to("12:00:10")
await connection.device.dispatch(
ATTR_REGDATA, {mixer_valve_opening_percentage_key: 55}
)
Expand Down

0 comments on commit f689f6c

Please sign in to comment.