Skip to content

Commit

Permalink
Added sensor for inverter temperature.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanU committed Jun 6, 2024
1 parent 4ccf117 commit 7f4bc51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions custom_components/talent_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DATE,
),
SensorEntityDescription(
key="inverterTemp",
translation_key="talentmonitor_inverter_temp",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
),
)

SENSORS = {desc.key: desc for desc in SENSOR_TYPES}
Expand Down Expand Up @@ -169,10 +175,13 @@ def native_value(self):
@property
def native_unit_of_measurement(self) -> str | None:
"""Return the unit of measurement."""
_LOGGER.debug('native_unit_of_measurement for %s', self.entity_description.key)
key_for_value_with_unit = self.entity_description.key + "Named"

if (key_for_value_with_unit in self._inverter.data and self._inverter.data[key_for_value_with_unit]):
value_split = self._inverter.data[key_for_value_with_unit].split(" ")

_LOGGER.debug('native_unit_of_measurement for %s', self._inverter.data[key_for_value_with_unit])
if (value_split and len(value_split) == 2):
unit = value_split[1]
return SENSOR_UNIT_MAPPING[unit]
Expand Down
3 changes: 3 additions & 0 deletions custom_components/talent_monitor/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
},
"talentmonitor_powerstation_rated_power": {
"name": "Nennleistung"
},
"talentmonitor_inverter_temp": {
"name": "Temperatur"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/talent_monitor/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
},
"talentmonitor_powerstation_rated_power": {
"name": "Rated Power"
},
"talentmonitor_inverter_temp": {
"name": "Temperature"
}
}
}
Expand Down

0 comments on commit 7f4bc51

Please sign in to comment.