Skip to content

Commit

Permalink
feat(sensor): Added current rating sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Jul 23, 2022
1 parent 8dfdf34 commit 0893adf
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 743 deletions.
6 changes: 3 additions & 3 deletions custom_components/carbon_intensity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ async def async_setup_entry(hass, entry):
setup_dependencies(hass, entry.data)

# Forward our entry to setup our default sensors
# hass.async_create_task(
# hass.config_entries.async_forward_entry_setup(entry, "sensor")
# )
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "sensor")
)
elif CONFIG_TARGET_NAME in entry.data:
# Forward our entry to setup our target rate sensors
hass.async_create_task(
Expand Down
4 changes: 3 additions & 1 deletion custom_components/carbon_intensity/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ async def async_setup_target_sensors(hass, entry, async_add_entities):

coordinator = hass.data[DOMAIN][DATA_RATES_COORDINATOR]

async_add_entities([CarbonIntensityTargetRate(coordinator, config)], True)
entities = [CarbonIntensityTargetRate(coordinator, config)]

async_add_entities(entities, True)

class CarbonIntensityTargetRate(CoordinatorEntity, BinarySensorEntity):
"""Sensor for calculating when a target should be turned on or off."""
Expand Down
Loading

0 comments on commit 0893adf

Please sign in to comment.