diff --git a/custom_components/teslemetry/binary_sensor.py b/custom_components/teslemetry/binary_sensor.py index e2c255c..3204a08 100644 --- a/custom_components/teslemetry/binary_sensor.py +++ b/custom_components/teslemetry/binary_sensor.py @@ -271,12 +271,14 @@ async def async_setup_entry( for energysite in entry.runtime_data.energysites for description in ENERGY_LIVE_DESCRIPTIONS if energysite.info_coordinator.data.get("components_battery") + if description.key in energysite.live_coordinator.data ), ( # Energy Site Info TeslemetryEnergyInfoBinarySensorEntity(energysite, description) for energysite in entry.runtime_data.energysites for description in ENERGY_INFO_DESCRIPTIONS if energysite.info_coordinator.data.get("components_battery") + if description.key in energysite.info_coordinator.data ), ) ) diff --git a/custom_components/teslemetry/sensor.py b/custom_components/teslemetry/sensor.py index b85a202..04a70c7 100644 --- a/custom_components/teslemetry/sensor.py +++ b/custom_components/teslemetry/sensor.py @@ -926,6 +926,9 @@ class TeslemetryEnergySensorEntityDescription(SensorEntityDescription): value_fn: Callable[[StateType], StateType | datetime] = lambda x: x ENERGY_LIVE_DESCRIPTIONS: tuple[TeslemetryEnergySensorEntityDescription, ...] = ( + TeslemetryEnergySensorEntityDescription( + key="grid_status", + ), TeslemetryEnergySensorEntityDescription( key="solar_power", state_class=SensorStateClass.MEASUREMENT, @@ -1060,6 +1063,7 @@ class TeslemetryEnergySensorEntityDescription(SensorEntityDescription): device_class=SensorDeviceClass.ENERGY, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + suggested_display_precision=2, state_class=SensorStateClass.TOTAL_INCREASING, entity_registry_enabled_default=(key.startswith("total") or key=="grid_energy_imported"), value_fn=lambda x: x.get(key, 0), diff --git a/custom_components/teslemetry/translations/en.json b/custom_components/teslemetry/translations/en.json index e95a66d..4b95122 100644 --- a/custom_components/teslemetry/translations/en.json +++ b/custom_components/teslemetry/translations/en.json @@ -476,6 +476,9 @@ "off_grid_unintentional": "Off grid unintentional" } }, + "grid_status": { + "name": "Grid status" + }, "load_power": { "name": "Load power" }, @@ -1161,4 +1164,4 @@ "name": "Set valet mode" } } -} \ No newline at end of file +}