From 907ef6ef6752b04134148659343f29e99d172f0f Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Sat, 5 Feb 2022 09:15:14 +0100 Subject: [PATCH] Add SensorEntity as mixin (#69) --- custom_components/integration_blueprint/sensor.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/integration_blueprint/sensor.py b/custom_components/integration_blueprint/sensor.py index e5152da..9457312 100644 --- a/custom_components/integration_blueprint/sensor.py +++ b/custom_components/integration_blueprint/sensor.py @@ -1,4 +1,6 @@ """Sensor platform for integration_blueprint.""" +from homeassistant.components.sensor import SensorEntity + from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR from .entity import IntegrationBlueprintEntity @@ -9,7 +11,7 @@ async def async_setup_entry(hass, entry, async_add_devices): async_add_devices([IntegrationBlueprintSensor(coordinator, entry)]) -class IntegrationBlueprintSensor(IntegrationBlueprintEntity): +class IntegrationBlueprintSensor(IntegrationBlueprintEntity, SensorEntity): """integration_blueprint Sensor class.""" @property @@ -18,8 +20,8 @@ def name(self): return f"{DEFAULT_NAME}_{SENSOR}" @property - def state(self): - """Return the state of the sensor.""" + def native_value(self): + """Return the native value of the sensor.""" return self.coordinator.data.get("body") @property