Add verisure ethernet status (#28656)

This commit is contained in:
Thomas Germain authored and Martin Hjelmare committed 2019-11-13 14:12:36 +01:00
1 parent 8f390d099a
commit ec45e72bea
3 files changed
+109 -4

No files matched your search

@@ -1,7 +1,10 @@
"""Support for Verisure binary sensors."""
import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import (
BinarySensorDevice,
DEVICE_CLASS_CONNECTIVITY,
)
from . import CONF_DOOR_WINDOW, HUB as hub
@@ -22,6 +25,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
)
]
)
sensors.extend([VerisureEthernetStatus()])
add_entities(sensors)
@@ -66,3 +71,32 @@ class VerisureDoorWindowSensor(BinarySensorDevice):
def update(self):
"""Update the state of the sensor."""
hub.update_overview()
class VerisureEthernetStatus(BinarySensorDevice):
"""Representation of a Verisure VBOX internet status."""
@property
def name(self):
"""Return the name of the binary sensor."""
return "Verisure Ethernet status"
@property
def is_on(self):
"""Return the state of the sensor."""
return hub.get_first("$.ethernetConnectedNow")
@property
def available(self):
"""Return True if entity is available."""
return hub.get_first("$.ethernetConnectedNow") is not None
# pylint: disable=no-self-use
def update(self):
"""Update the state of the sensor."""
hub.update_overview()
@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY