Add more sensors for users with Tibber Pulse (#66201)

* Tibber, Add stats and sensors for homes with real time meter

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Tibber stats

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Monthly peak hour
This commit is contained in:
Daniel Hjelseth Høyer 2022-02-10 08:47:34 +01:00 committed by GitHub
parent 72acda81a7
commit 3733aa9494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -3,7 +3,7 @@
"domain": "tibber", "domain": "tibber",
"name": "Tibber", "name": "Tibber",
"documentation": "https://www.home-assistant.io/integrations/tibber", "documentation": "https://www.home-assistant.io/integrations/tibber",
"requirements": ["pyTibber==0.21.7"], "requirements": ["pyTibber==0.22.1"],
"codeowners": ["@danielhiversen"], "codeowners": ["@danielhiversen"],
"quality_scale": "silver", "quality_scale": "silver",
"config_flow": true, "config_flow": true,

View File

@ -210,7 +210,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key="peak_hour", key="peak_hour",
name="Month peak hour consumption", name="Monthly peak hour consumption",
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
), ),
@ -253,17 +253,17 @@ async def async_setup_entry(
if home.has_active_subscription: if home.has_active_subscription:
entities.append(TibberSensorElPrice(home)) entities.append(TibberSensorElPrice(home))
if coordinator is None:
coordinator = TibberDataCoordinator(hass, tibber_connection)
for entity_description in SENSORS:
entities.append(TibberDataSensor(home, coordinator, entity_description))
if home.has_real_time_consumption: if home.has_real_time_consumption:
await home.rt_subscribe( await home.rt_subscribe(
TibberRtDataCoordinator( TibberRtDataCoordinator(
async_add_entities, home, hass async_add_entities, home, hass
).async_set_updated_data ).async_set_updated_data
) )
if home.has_active_subscription and not home.has_real_time_consumption:
if coordinator is None:
coordinator = TibberDataCoordinator(hass, tibber_connection)
for entity_description in SENSORS:
entities.append(TibberDataSensor(home, coordinator, entity_description))
# migrate # migrate
old_id = home.info["viewer"]["home"]["meteringPointData"]["consumptionEan"] old_id = home.info["viewer"]["home"]["meteringPointData"]["consumptionEan"]
@ -547,7 +547,7 @@ class TibberDataCoordinator(update_coordinator.DataUpdateCoordinator):
hass, hass,
_LOGGER, _LOGGER,
name=f"Tibber {tibber_connection.name}", name=f"Tibber {tibber_connection.name}",
update_interval=timedelta(hours=1), update_interval=timedelta(minutes=20),
) )
self._tibber_connection = tibber_connection self._tibber_connection = tibber_connection

View File

@ -1362,7 +1362,7 @@ pyRFXtrx==0.27.1
# pySwitchmate==0.4.6 # pySwitchmate==0.4.6
# homeassistant.components.tibber # homeassistant.components.tibber
pyTibber==0.21.7 pyTibber==0.22.1
# homeassistant.components.dlink # homeassistant.components.dlink
pyW215==0.7.0 pyW215==0.7.0

View File

@ -854,7 +854,7 @@ pyMetno==0.9.0
pyRFXtrx==0.27.1 pyRFXtrx==0.27.1
# homeassistant.components.tibber # homeassistant.components.tibber
pyTibber==0.21.7 pyTibber==0.22.1
# homeassistant.components.nextbus # homeassistant.components.nextbus
py_nextbusnext==0.1.5 py_nextbusnext==0.1.5