forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Withings webhooks (home-assistant#34447)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
- Loading branch information
1 parent
29df13a
commit a6a6a7b
Showing
16 changed files
with
2,204 additions
and
1,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Sensors flow for Withings.""" | ||
from typing import Callable, List | ||
|
||
from homeassistant.components.binary_sensor import ( | ||
DEVICE_CLASS_PRESENCE, | ||
DOMAIN as BINARY_SENSOR_DOMAIN, | ||
BinarySensorDevice, | ||
) | ||
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, WithingsHealthBinarySensor, BINARY_SENSOR_DOMAIN | ||
) | ||
|
||
async_add_entities(entities, True) | ||
|
||
|
||
class WithingsHealthBinarySensor(BaseWithingsSensor, BinarySensorDevice): | ||
"""Implementation of a Withings sensor.""" | ||
|
||
@property | ||
def is_on(self) -> bool: | ||
"""Return true if the binary sensor is on.""" | ||
return self._state_data | ||
|
||
@property | ||
def device_class(self) -> str: | ||
"""Provide the device class.""" | ||
return DEVICE_CLASS_PRESENCE |
Oops, something went wrong.