Opower: add date sensors (#122138)

opower: Add diagnostic date sensors
This commit is contained in:
b3nj1 2024-07-18 23:07:09 -07:00 committed by GitHub
parent a0a5f640dc
commit 243c16d194
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfEnergy, UnitOfVolume from homeassistant.const import EntityCategory, UnitOfEnergy, UnitOfVolume
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -91,6 +91,22 @@ ELEC_SENSORS: tuple[OpowerEntityDescription, ...] = (
suggested_display_precision=0, suggested_display_precision=0,
value_fn=lambda data: data.typical_cost, value_fn=lambda data: data.typical_cost,
), ),
OpowerEntityDescription(
key="elec_start_date",
name="Current bill electric start date",
device_class=SensorDeviceClass.DATE,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
value_fn=lambda data: data.start_date,
),
OpowerEntityDescription(
key="elec_end_date",
name="Current bill electric end date",
device_class=SensorDeviceClass.DATE,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
value_fn=lambda data: data.end_date,
),
) )
GAS_SENSORS: tuple[OpowerEntityDescription, ...] = ( GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
OpowerEntityDescription( OpowerEntityDescription(
@ -147,6 +163,22 @@ GAS_SENSORS: tuple[OpowerEntityDescription, ...] = (
suggested_display_precision=0, suggested_display_precision=0,
value_fn=lambda data: data.typical_cost, value_fn=lambda data: data.typical_cost,
), ),
OpowerEntityDescription(
key="gas_start_date",
name="Current bill gas start date",
device_class=SensorDeviceClass.DATE,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
value_fn=lambda data: data.start_date,
),
OpowerEntityDescription(
key="gas_end_date",
name="Current bill gas end date",
device_class=SensorDeviceClass.DATE,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
value_fn=lambda data: data.end_date,
),
) )