Skip to content

Commit

Permalink
Fix renamed sensors since 4.0.0.100
Browse files Browse the repository at this point in the history
  • Loading branch information
dupondje committed Aug 23, 2024
1 parent 481593b commit af069f1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions custom_components/nrgkick/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class NRGKickSensorEntityDescription(SensorEntityDescription, NRGKickMixin):
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
suggested_display_precision=2,
value_fn=lambda data: data["info"]["connector"]["max_current:"],
value_fn=lambda data: data["info"]["connector"]["max_current"]
if "max_current" in data["info"]["connector"]
else data["info"]["connector"]["max_current:"],
),
NRGKickSensorEntityDescription(
key="connector_type",
Expand All @@ -91,7 +93,9 @@ class NRGKickSensorEntityDescription(SensorEntityDescription, NRGKickMixin):
device_class=SensorDeviceClass.FREQUENCY,
native_unit_of_measurement=UnitOfFrequency.HERTZ,
suggested_display_precision=2,
value_fn=lambda data: data["info"]["grid"]["frequency:"],
value_fn=lambda data: data["info"]["grid"]["frequency"]
if "frequency" in data["info"]["grid"]
else data["info"]["grid"]["frequency:"],
),
NRGKickSensorEntityDescription(
key="grid_phases",
Expand Down Expand Up @@ -271,7 +275,9 @@ class NRGKickSensorEntityDescription(SensorEntityDescription, NRGKickMixin):
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
suggested_display_precision=2,
value_fn=lambda data: data["values"]["powerflow"]["l1"]["voltage:"],
value_fn=lambda data: data["values"]["powerflow"]["l1"]["voltage"]
if "voltage" in data["values"]["powerflow"]["l1"]
else data["values"]["powerflow"]["l1"]["voltage:"],
),
NRGKickSensorEntityDescription(
key="powerflow_l1_current",
Expand Down Expand Up @@ -316,7 +322,9 @@ class NRGKickSensorEntityDescription(SensorEntityDescription, NRGKickMixin):
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
suggested_display_precision=2,
value_fn=lambda data: data["values"]["powerflow"]["l2"]["voltage:"],
value_fn=lambda data: data["values"]["powerflow"]["l2"]["voltage"]
if "voltage" in data["values"]["powerflow"]["l2"]
else data["values"]["powerflow"]["l2"]["voltage:"],
),
NRGKickSensorEntityDescription(
key="powerflow_l2_current",
Expand Down Expand Up @@ -361,7 +369,9 @@ class NRGKickSensorEntityDescription(SensorEntityDescription, NRGKickMixin):
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
suggested_display_precision=2,
value_fn=lambda data: data["values"]["powerflow"]["l3"]["voltage:"],
value_fn=lambda data: data["values"]["powerflow"]["l3"]["voltage"]
if "voltage" in data["values"]["powerflow"]["l3"]
else data["values"]["powerflow"]["l3"]["voltage:"],
),
NRGKickSensorEntityDescription(
key="powerflow_l3_current",
Expand Down

0 comments on commit af069f1

Please sign in to comment.