hass-core/homeassistant/components/withings/sensor.py
Robert Van Gorkom a6a6a7b69c
Add Withings webhooks (#34447)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-06-16 20:16:18 +02:00

32 lines
939 B
Python

"""Sensors flow for Withings."""
from typing import Callable, List, Union
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from .common import BaseWithingsSensor, async_create_entities
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
entities = await async_create_entities(
hass, entry, WithingsHealthSensor, SENSOR_DOMAIN,
)
async_add_entities(entities, True)
class WithingsHealthSensor(BaseWithingsSensor):
"""Implementation of a Withings sensor."""
@property
def state(self) -> Union[None, str, int, float]:
"""Return the state of the entity."""
return self._state_data