Rename [blueprint|Blueprint] -> [integration_blueprint|Integration blueprint] (#47)
This commit is contained in:
28
custom_components/integration_blueprint/sensor.py
Normal file
28
custom_components/integration_blueprint/sensor.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""Sensor platform for integration_blueprint."""
|
||||
from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
|
||||
from .entity import IntegrationBlueprintEntity
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry, async_add_devices):
|
||||
"""Setup sensor platform."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_devices([IntegrationBlueprintSensor(coordinator, entry)])
|
||||
|
||||
|
||||
class IntegrationBlueprintSensor(IntegrationBlueprintEntity):
|
||||
"""integration_blueprint Sensor class."""
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return f"{DEFAULT_NAME}_{SENSOR}"
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self.coordinator.data.get("body")
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the sensor."""
|
||||
return ICON
|
Reference in New Issue
Block a user