Skip to content

Commit

Permalink
Fix energy_sensor_id sensors correctly included in group (#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Mar 23, 2024
1 parent 4183e0c commit 2006116
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/powercalc/sensor.py
Expand Up @@ -768,7 +768,7 @@ async def create_individual_sensors(
return EntitiesBucket()

# Create energy sensor which integrates the power sensor
if sensor_config.get(CONF_CREATE_ENERGY_SENSOR):
if sensor_config.get(CONF_CREATE_ENERGY_SENSOR) or CONF_ENERGY_SENSOR_ID in sensor_config:
energy_sensor = await create_energy_sensor(
hass,
sensor_config,
Expand Down
6 changes: 6 additions & 0 deletions tests/sensors/test_group.py
Expand Up @@ -38,6 +38,7 @@
ATTR_ENTITIES,
ATTR_IS_GROUP,
CONF_CREATE_ENERGY_SENSOR,
CONF_CREATE_ENERGY_SENSORS,
CONF_CREATE_GROUP,
CONF_CREATE_UTILITY_METERS,
CONF_DISABLE_EXTENDED_ATTRIBUTES,
Expand Down Expand Up @@ -1453,10 +1454,12 @@ async def test_additional_energy_sensors(hass: HomeAssistant) -> None:
{
CONF_CREATE_GROUP: "TestGroup",
CONF_IGNORE_UNAVAILABLE_STATE: True,
CONF_CREATE_ENERGY_SENSOR: True,
CONF_ENTITIES: [
{
CONF_ENTITY_ID: "fan.ceiling_fan",
CONF_FIXED: {CONF_POWER: 50},
CONF_CREATE_ENERGY_SENSOR: True,
},
{
CONF_POWER_SENSOR_ID: "sensor.furnace_power",
Expand All @@ -1465,6 +1468,9 @@ async def test_additional_energy_sensors(hass: HomeAssistant) -> None:
],
},
],
{
CONF_CREATE_ENERGY_SENSORS: False,
},
)

power_state = hass.states.get("sensor.testgroup_power")
Expand Down

0 comments on commit 2006116

Please sign in to comment.