Skip to content

Commit

Permalink
Add SensorEntity as mixin (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 authored Feb 5, 2022
1 parent 907de1a commit 907ef6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/integration_blueprint/sensor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 907ef6e

Please sign in to comment.