Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -16,9 +16,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
|
||||
hub.update_overview()
|
||||
switches = []
|
||||
switches.extend([
|
||||
VerisureSmartplug(device_label)
|
||||
for device_label in hub.get('$.smartPlugs[*].deviceLabel')])
|
||||
switches.extend(
|
||||
[
|
||||
VerisureSmartplug(device_label)
|
||||
for device_label in hub.get("$.smartPlugs[*].deviceLabel")
|
||||
]
|
||||
)
|
||||
add_entities(switches)
|
||||
|
||||
|
||||
@@ -35,25 +38,30 @@ class VerisureSmartplug(SwitchDevice):
|
||||
def name(self):
|
||||
"""Return the name or location of the smartplug."""
|
||||
return hub.get_first(
|
||||
"$.smartPlugs[?(@.deviceLabel == '%s')].area",
|
||||
self._device_label)
|
||||
"$.smartPlugs[?(@.deviceLabel == '%s')].area", self._device_label
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if on."""
|
||||
if time() - self._change_timestamp < 10:
|
||||
return self._state
|
||||
self._state = hub.get_first(
|
||||
"$.smartPlugs[?(@.deviceLabel == '%s')].currentState",
|
||||
self._device_label) == "ON"
|
||||
self._state = (
|
||||
hub.get_first(
|
||||
"$.smartPlugs[?(@.deviceLabel == '%s')].currentState",
|
||||
self._device_label,
|
||||
)
|
||||
== "ON"
|
||||
)
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if entity is available."""
|
||||
return hub.get_first(
|
||||
"$.smartPlugs[?(@.deviceLabel == '%s')]",
|
||||
self._device_label) is not None
|
||||
return (
|
||||
hub.get_first("$.smartPlugs[?(@.deviceLabel == '%s')]", self._device_label)
|
||||
is not None
|
||||
)
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Set smartplug status on."""
|
||||
|
||||
Reference in new issue
Block a user