Merge pull request #1222 from turbokongen/verisure-mouse

Support for Mousedetectors connected in Verisure systems
This commit is contained in:
Paulus Schoutsen committed 2016-02-13 00:22:34 -08:00
commit 6d6cf886f3
2 files changed
+50 -2

No files matched your search

@@ -39,6 +39,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hasattr(value, 'humidity') and value.humidity
])
sensors.extend([
VerisureMouseDetection(value)
for value in verisure.MOUSEDETECTION_STATUS.values()
if verisure.SHOW_MOUSEDETECTION and
hasattr(value, 'amountText') and value.amountText
])
add_devices(sensors)
@@ -98,3 +105,31 @@ class VerisureHygrometer(Entity):
def update(self):
""" update sensor """
verisure.update_climate()
class VerisureMouseDetection(Entity):
""" represents a Verisure mousedetector within home assistant. """
def __init__(self, mousedetection_status):
self._id = mousedetection_status.deviceLabel
@property
def name(self):
""" Returns the name of the device. """
return '{} {}'.format(
verisure.MOUSEDETECTION_STATUS[self._id].location,
"Mouse")
@property
def state(self):
""" Returns the state of the device. """
return verisure.MOUSEDETECTION_STATUS[self._id].count
@property
def unit_of_measurement(self):
""" Unit of measurement of this entity """
return "Mice"
def update(self):
""" update sensor """
verisure.update_mousedetection()