Skip to content

Commit

Permalink
feat: add latest_meter_reading_date sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyKh committed Apr 28, 2024
1 parent b1c241e commit bdb1099
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/iec/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def _get_reading_by_date(readings: list[RemoteReading] | None, desired_date: dat
value_fn=lambda data: (data[FUTURE_CONSUMPTIONS_DICT_NAME][data[ATTRIBUTES_DICT_NAME][METER_ID_ATTR_NAME]]
.total_import or 0) if (data[FUTURE_CONSUMPTIONS_DICT_NAME]) else None
),
IecEntityDescription(
key="elec_latest_meter_reading_date",
device_class=SensorDeviceClass.DATE,
value_fn=lambda data: (data[FUTURE_CONSUMPTIONS_DICT_NAME][data[ATTRIBUTES_DICT_NAME][METER_ID_ATTR_NAME]]
.total_import_date or 0) if (data[FUTURE_CONSUMPTIONS_DICT_NAME]) else None
),
)

ELEC_SENSORS: tuple[IecEntityDescription, ...] = (
Expand Down
3 changes: 3 additions & 0 deletions custom_components/iec/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"elec_latest_meter_reading": {
"name": "IEC latest meter reading {multi_contract}"
},
"elec_latest_meter_reading_date": {
"name": "IEC latest meter reading date {multi_contract}"
},
"iec_last_elec_usage": {
"name": "Last IEC bill electric usage to date {multi_contract}"
},
Expand Down
3 changes: 3 additions & 0 deletions custom_components/iec/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"elec_latest_meter_reading": {
"name": "קריאת מונה אחרונה {multi_contract}"
},
"elec_latest_meter_reading": {
"name": "תאריך קריאת מונה אחרונה {multi_contract}"
},
"iec_last_elec_usage": {
"name": "סך צריכת החשמל בחשבונית האחרונה {multi_contract}"
},
Expand Down

0 comments on commit bdb1099

Please sign in to comment.