Point fix for multiple devices (#18959)

* fix for multiple devices closes, #18956

* Point API finally supports "all" events
This commit is contained in:
Fredrik Erlandsson authored and Paulus Schoutsen committed 2018-12-03 16:50:05 +01:00
1 parent d028236bf2
commit 111a3254fb
4 files changed
+57 -26

No files matched your search

+13 -6
View File
@@ -6,13 +6,15 @@ https://home-assistant.io/components/sensor.point/
"""
import logging
from homeassistant.components.point import MinutPointEntity
from homeassistant.components.point import (
DOMAIN as PARENT_DOMAIN, MinutPointEntity)
from homeassistant.components.point.const import (
DOMAIN as POINT_DOMAIN, NEW_DEVICE)
DOMAIN as POINT_DOMAIN, POINT_DISCOVERY_NEW)
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE,
TEMP_CELSIUS)
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.util.dt import parse_datetime
_LOGGER = logging.getLogger(__name__)
@@ -29,10 +31,15 @@ SENSOR_TYPES = {
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a Point's sensors based on a config entry."""
device_id = config_entry.data[NEW_DEVICE]
client = hass.data[POINT_DOMAIN][config_entry.entry_id]
async_add_entities((MinutPointSensor(client, device_id, sensor_type)
for sensor_type in SENSOR_TYPES), True)
async def async_discover_sensor(device_id):
"""Discover and add a discovered sensor."""
client = hass.data[POINT_DOMAIN][config_entry.entry_id]
async_add_entities((MinutPointSensor(client, device_id, sensor_type)
for sensor_type in SENSOR_TYPES), True)
async_dispatcher_connect(
hass, POINT_DISCOVERY_NEW.format(PARENT_DOMAIN, POINT_DOMAIN),
async_discover_sensor)
class MinutPointSensor(MinutPointEntity):