code reveiw
This commit is contained in:
1 parent
f20be1e7f8
commit
ad327b64ed
5 files changed
+64
-21
No files matched your search
@@ -11,7 +11,7 @@ from homeassistant.helpers.entity import ToggleEntity
|
||||
|
||||
from homeassistant.const import (
|
||||
STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID)
|
||||
from homeassistant.components import group, discovery, wink, isy994
|
||||
from homeassistant.components import group, discovery, wink, isy994, verisure
|
||||
|
||||
DOMAIN = 'switch'
|
||||
DEPENDENCIES = []
|
||||
@@ -32,6 +32,7 @@ DISCOVERY_PLATFORMS = {
|
||||
discovery.SERVICE_WEMO: 'wemo',
|
||||
wink.DISCOVER_SWITCHES: 'wink',
|
||||
isy994.DISCOVER_SWITCHES: 'isy994',
|
||||
verisure.DISCOVER_SWITCHES: 'verisure'
|
||||
}
|
||||
|
||||
PROP_TO_ATTR = {
|
||||
|
||||
@@ -42,6 +42,8 @@ class VerisureSmartplug(SwitchDevice):
|
||||
""" Represents a Verisure smartplug. """
|
||||
def __init__(self, smartplug_status):
|
||||
self._id = smartplug_status.id
|
||||
self.STATUS_ON = verisure.MY_PAGES.SMARTPLUG_ON
|
||||
self.STATUS_OFF = verisure.MY_PAGES.SMARTPLUG_OFF
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -52,16 +54,19 @@ class VerisureSmartplug(SwitchDevice):
|
||||
def is_on(self):
|
||||
""" Returns True if on """
|
||||
plug_status = verisure.get_smartplug_status()[self._id].status
|
||||
return plug_status == verisure.MY_PAGES.SMARTPLUG_ON
|
||||
return plug_status == self.STATUS_ON
|
||||
|
||||
def turn_on(self):
|
||||
""" Set smartplug status on """
|
||||
verisure.MY_PAGES.set_smartplug_status(
|
||||
self._id,
|
||||
verisure.MY_PAGES.SMARTPLUG_ON)
|
||||
self.STATUS_ON)
|
||||
|
||||
def turn_off(self):
|
||||
""" Set smartplug status off. """
|
||||
verisure.MY_PAGES.set_smartplug_status(
|
||||
self._id,
|
||||
verisure.MY_PAGES.SMARTPLUG_OFF)
|
||||
self.STATUS_OFF)
|
||||
|
||||
def update(self):
|
||||
verisure.update()
|
||||
Reference in new issue
Block a user