Skip to content

Commit

Permalink
Made Sensor Wallbox Consumption only available if Wallbox is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
bullitt186 committed Jul 29, 2024
1 parent 241ddd5 commit becd9c6
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions custom_components/e3dc_rscp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,6 @@
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="wallbox-consumption",
translation_key="wallbox-consumption",
icon="mdi:ev-station",
native_unit_of_measurement=UnitOfPower.WATT,
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
suggested_display_precision=2,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="grid-netchange",
translation_key="grid-netchange",
Expand Down Expand Up @@ -532,6 +521,18 @@ async def async_setup_entry(
)
entities.append(E3DCSensor(coordinator, wallbox_soc_description, unique_id, wallbox["deviceInfo"]))

if len(coordinator.wallboxes) > 0:
wallbox_consumption_description = SensorEntityDescription(
key="wallbox-consumption",
translation_key="wallbox-consumption",
icon="mdi:ev-station",
native_unit_of_measurement=UnitOfPower.WATT,
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
suggested_display_precision=2,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
)
entities.append(E3DCSensor(coordinator, wallbox_consumption_description, entry.unique_id))

async_add_entities(entities)

Expand Down

0 comments on commit becd9c6

Please sign in to comment.