Skip to content

Commit

Permalink
Adjust new sensors and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarv committed Jan 18, 2024
1 parent deb3ed4 commit ec33211
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 4 deletions.
16 changes: 14 additions & 2 deletions custom_components/bwt_perla/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,35 @@ async def async_setup_entry(
coordinator,
"day_output",
UnitOfVolume.LITERS,
SensorStateClass.TOTAL_INCREASING,
lambda data: data.treated_day,
),
CalculatedSensor(
coordinator,
"month_output",
UnitOfVolume.LITERS,
SensorStateClass.TOTAL_INCREASING,
lambda data: data.treated_month,
),
CalculatedSensor(
coordinator,
"year_output",
UnitOfVolume.LITERS,
SensorStateClass.TOTAL_INCREASING,
lambda data: data.treated_year,
),
CalculatedSensor(
coordinator,
"capacity_1",
UnitOfVolume.MILLILITERS,
SensorStateClass.MEASUREMENT,
lambda data: data.capacity_1,
),
CalculatedSensor(
coordinator,
"capacity_2",
UnitOfVolume.MILLILITERS,
SensorStateClass.MEASUREMENT,
lambda data: data.capacity_2,
),
]
Expand Down Expand Up @@ -314,16 +319,23 @@ def _handle_coordinator_update(self) -> None:
class CalculatedSensor(CoordinatorEntity[BwtCoordinator], SensorEntity):
"""Sensor calculating blended water from treated water."""

_attr_state_class = SensorStateClass.TOTAL_INCREASING
suggested_display_precision = 0
suggested_unit_of_measurement = UnitOfVolume.LITERS

def __init__(self, coordinator, key: str, unit: UnitOfVolume, extract) -> None:
def __init__(
self,
coordinator,
key: str,
unit: UnitOfVolume,
stateClass: SensorStateClass,
extract,
) -> None:
"""Initialize the sensor with the common coordinator."""
super().__init__(coordinator)
self._attr_translation_key = key
self._attr_unique_id = self._attr_translation_key
self._attr_native_unit_of_measurement = unit
self._attr_state_class = stateClass
self._extract = extract

@callback
Expand Down
15 changes: 15 additions & 0 deletions custom_components/bwt_perla/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@
},
"last_regeneration_2": {
"name": "Last regeneration column 2"
},
"capacity_1": {
"name": "Remaining capacity of column 1"
},
"capacity_2": {
"name": "Remaining capacity of column 1"
},
"day_output": {
"name": "Output of current day"
},
"month_output": {
"name": "Output of current month"
},
"year_output": {
"name": "Output of current year"
}
},
"binary_sensor": {
Expand Down
41 changes: 41 additions & 0 deletions custom_components/bwt_perla/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,51 @@
}
},
"entity": {
"binary_sensor": {
"holiday_mode": {
"name": "Urlaubsmodus"
}
},
"sensor": {
"capacity_1": {
"name": "Verbleibende Kapazität Säule 1"
},
"capacity_2": {
"name": "Verbleibende Kapazität Säule 2"
},
"counter_regeneration_1": {
"name": "Regenerationszähler Säule 1"
},
"counter_regeneration_2": {
"name": "Regenerationszähler Säule 2"
},
"customer_service": {
"name": "Letzter Kunden Service "
},
"day_output": {
"name": "Wasserverbrauch heute"
},
"errors": {
"name": "Aktive Fehlermeldungen"
},
"hardness_in": {
"name": "Wasserhärte vor Gerät"
},
"hardness_out": {
"name": "Wasserhärte nach Gerät"
},
"holiday_mode_start": {
"name": "Zukünftiger Start des Urlaubsmodus"
},
"last_regeneration_1": {
"name": "Letzte Regeneration Säule 1"
},
"last_regeneration_2": {
"name": "Letzte Regeneration Säule 2"
},
"month_output": {
"name": "Wasserverbrauch aktueller Monat"
},
"regenerativ_days": {
"name": "Tage Regenerationsmittel übrig"
},
Expand All @@ -45,6 +80,12 @@
},
"total_output": {
"name": "Gesamter Wasserverbrauch"
},
"warnings": {
"name": "Aktive Warnungen"
},
"year_output": {
"name": "Wasserverbrauch aktuelles Jahr"
}
}
}
Expand Down
45 changes: 43 additions & 2 deletions custom_components/bwt_perla/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,59 @@
}
},
"entity": {
"binary_sensor": {
"holiday_mode": {
"name": ""
}
},
"sensor": {
"capacity_1": {
"name": "Remaining capacity of column 1"
},
"capacity_2": {
"name": "Remaining capacity of column 1"
},
"counter_regeneration_1": {
"name": "Regeneration counter column 1"
},
"counter_regeneration_2": {
"name": "Regeneration counter column 2"
},
"customer_service": {
"name": "Last service by customer"
},
"day_output": {
"name": "Output of current day"
},
"errors": {
"name": "Active errors"
},
"hardness_in": {
"name": "Incoming water hardness"
},
"hardness_out": {
"name": "Outgoing water hardness"
},
"holiday_mode_start": {
"name": "Future start of holiday mode if available"
},
"last_regeneration_1": {
"name": "Last regeneration column 1"
},
"last_regeneration_2": {
"name": "Last regeneration column 2"
},
"month_output": {
"name": "Output of current month"
},
"regenerativ_days": {
"name": "Days left of regeneration salt"
},
"regenerativ_level": {
"name": "Percentage of regeneration salt"
"name": "Precentage of regeneration salt"
},
"regenerativ_mass": {
"name": "Remaining regeneration salt"
"name": "Total regeneration salt ever used"
},
"state": {
"name": "State of the machine"
Expand All @@ -45,6 +80,12 @@
},
"total_output": {
"name": "Total water consumption"
},
"warnings": {
"name": "Active warnings"
},
"year_output": {
"name": "Output of current year"
}
}
}
Expand Down

0 comments on commit ec33211

Please sign in to comment.