Point updates (#64748)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Fredrik Erlandsson 2022-01-24 13:57:29 +01:00 committed by GitHub
parent 73fd19d4e2
commit f23af3455e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 16 deletions

View file

@ -1,4 +1,6 @@
"""Support for Minut Point binary sensors."""
from __future__ import annotations
import logging
from pypoint import EVENTS
@ -74,7 +76,6 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorEntity):
self._device_name = device_name
self._async_unsub_hook_dispatcher_connect = None
self._events = EVENTS[device_name]
self._is_on = None
async def async_added_to_hass(self):
"""Call when entity is added to HOme Assistant."""
@ -93,10 +94,11 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorEntity):
"""Update the value of the sensor."""
if not self.is_updated:
return
if self._events[0] in self.device.ongoing_events:
self._is_on = True
if self.device_class == BinarySensorDeviceClass.CONNECTIVITY:
# connectivity is the other way around.
self._attr_is_on = not (self._events[0] in self.device.ongoing_events)
else:
self._is_on = None
self._attr_is_on = self._events[0] in self.device.ongoing_events
self.async_write_ha_state()
@callback
@ -110,18 +112,18 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorEntity):
return
_LOGGER.debug("Received webhook: %s", _type)
if _type == self._events[0]:
self._is_on = True
if _type == self._events[1]:
self._is_on = None
self.async_write_ha_state()
_is_on = True
elif _type == self._events[1]:
_is_on = False
else:
return
@property
def is_on(self):
"""Return the state of the binary sensor."""
if self.device_class == BinarySensorDeviceClass.CONNECTIVITY:
# connectivity is the other way around.
return not self._is_on
return self._is_on
self._attr_is_on = not _is_on
else:
self._attr_is_on = _is_on
self.async_write_ha_state()
@property
def name(self):

View file

@ -3,7 +3,7 @@
"name": "Minut Point",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/point",
"requirements": ["pypoint==2.2.1"],
"requirements": ["pypoint==2.3.0"],
"dependencies": ["webhook", "http"],
"codeowners": ["@fredrike"],
"quality_scale": "gold",

View file

@ -1767,7 +1767,7 @@ pypjlink2==1.2.1
pyplaato==0.0.15
# homeassistant.components.point
pypoint==2.2.1
pypoint==2.3.0
# homeassistant.components.profiler
pyprof2calltree==1.4.5

View file

@ -1121,7 +1121,7 @@ pypck==0.7.13
pyplaato==0.0.15
# homeassistant.components.point
pypoint==2.2.1
pypoint==2.3.0
# homeassistant.components.profiler
pyprof2calltree==1.4.5