Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -3,11 +3,10 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.components.streamlabswater import (
|
||||
DOMAIN as STREAMLABSWATER_DOMAIN)
|
||||
from homeassistant.components.streamlabswater import DOMAIN as STREAMLABSWATER_DOMAIN
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
DEPENDS = ['streamlabswater']
|
||||
DEPENDS = ["streamlabswater"]
|
||||
|
||||
MIN_TIME_BETWEEN_LOCATION_UPDATES = timedelta(seconds=60)
|
||||
|
||||
@@ -17,16 +16,14 @@ NAME_AWAY_MODE = "Water Away Mode"
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the StreamLabsWater mode sensor."""
|
||||
client = hass.data[STREAMLABSWATER_DOMAIN]['client']
|
||||
location_id = hass.data[STREAMLABSWATER_DOMAIN]['location_id']
|
||||
location_name = hass.data[STREAMLABSWATER_DOMAIN]['location_name']
|
||||
client = hass.data[STREAMLABSWATER_DOMAIN]["client"]
|
||||
location_id = hass.data[STREAMLABSWATER_DOMAIN]["location_id"]
|
||||
location_name = hass.data[STREAMLABSWATER_DOMAIN]["location_name"]
|
||||
|
||||
streamlabs_location_data = StreamlabsLocationData(location_id, client)
|
||||
streamlabs_location_data.update()
|
||||
|
||||
add_devices([
|
||||
StreamlabsAwayMode(location_name, streamlabs_location_data)
|
||||
])
|
||||
add_devices([StreamlabsAwayMode(location_name, streamlabs_location_data)])
|
||||
|
||||
|
||||
class StreamlabsLocationData:
|
||||
@@ -42,7 +39,7 @@ class StreamlabsLocationData:
|
||||
def update(self):
|
||||
"""Query and store location data."""
|
||||
location = self._client.get_location(self._location_id)
|
||||
self._is_away = location['homeAway'] == 'away'
|
||||
self._is_away = location["homeAway"] == "away"
|
||||
|
||||
def is_away(self):
|
||||
"""Return whether away more is enabled."""
|
||||
|
||||
Reference in new issue
Block a user