Skip to content
This repository was archived by the owner on Apr 30, 2022. It is now read-only.

Commit 1ca3602

Browse files
committed
Determine sensor availability at runtime
attempts to fix #46
1 parent e0ad1fe commit 1ca3602

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

custom_components/hildebrandglow/sensor.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
SensorEntityDescription(
3030
key="gas_consumption",
3131
name="Gas Consumption",
32-
entity_registry_enabled_default=False,
3332
native_unit_of_measurement=VOLUME_CUBIC_METERS,
3433
device_class=DEVICE_CLASS_GAS,
3534
state_class=STATE_CLASS_TOTAL_INCREASING,
@@ -100,6 +99,11 @@ def on_message(self, message: Any) -> None:
10099
"""Receive callback for incoming MQTT payloads."""
101100
self.hass.add_job(self.async_write_ha_state)
102101

102+
@property
103+
def available(self) -> bool:
104+
"""Return the sensor's availability."""
105+
return getattr(self.glow.data, self.entity_description.key) is not None
106+
103107
@property
104108
def native_value(self) -> StateType:
105109
"""Return the state of the sensor."""

0 commit comments

Comments
 (0)