mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix lint issues (#3492)
This commit is contained in:
parent
2ecbcac2b1
commit
ad2dea939b
@ -114,8 +114,8 @@ class MqttLight(Light):
|
|||||||
self._supported_features |= (
|
self._supported_features |= (
|
||||||
topic[CONF_RGB_STATE_TOPIC] is not None and SUPPORT_RGB_COLOR)
|
topic[CONF_RGB_STATE_TOPIC] is not None and SUPPORT_RGB_COLOR)
|
||||||
self._supported_features |= (
|
self._supported_features |= (
|
||||||
topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None
|
topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None and
|
||||||
and SUPPORT_BRIGHTNESS)
|
SUPPORT_BRIGHTNESS)
|
||||||
|
|
||||||
templates = {key: ((lambda value: value) if tpl is None else
|
templates = {key: ((lambda value: value) if tpl is None else
|
||||||
partial(render_with_possible_json_value, hass, tpl))
|
partial(render_with_possible_json_value, hass, tpl))
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
Support for bom.gov.au current condition weather service.
|
Support for Australian BOM (Bureau of Meteorology) weather service.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.bom_weather_current/
|
https://home-assistant.io/components/sensor.bom/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
@ -28,7 +27,6 @@ CONF_WMO_ID = 'wmo_id'
|
|||||||
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=60)
|
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=60)
|
||||||
LAST_UPDATE = 0
|
LAST_UPDATE = 0
|
||||||
|
|
||||||
|
|
||||||
# Sensor types are defined like: Name, units
|
# Sensor types are defined like: Name, units
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
'wmo': ['wmo', None],
|
'wmo': ['wmo', None],
|
||||||
@ -78,13 +76,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the BOM sensor."""
|
"""Setup the BOM sensor."""
|
||||||
rest = BOMCurrentData(hass, config.get(CONF_ZONE_ID),
|
rest = BOMCurrentData(
|
||||||
config.get(CONF_WMO_ID))
|
hass, config.get(CONF_ZONE_ID), config.get(CONF_WMO_ID))
|
||||||
|
|
||||||
sensors = []
|
sensors = []
|
||||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||||
sensors.append(BOMCurrentSensor(rest,
|
sensors.append(BOMCurrentSensor(
|
||||||
variable,
|
rest, variable, config.get(CONF_NAME)))
|
||||||
config.get(CONF_NAME)))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rest.update()
|
rest.update()
|
||||||
@ -110,10 +108,10 @@ class BOMCurrentSensor(Entity):
|
|||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
if self.stationname is None:
|
if self.stationname is None:
|
||||||
return "BOM {}".format(SENSOR_TYPES[self._condition][0])
|
return 'BOM {}'.format(SENSOR_TYPES[self._condition][0])
|
||||||
else:
|
else:
|
||||||
return "BOM {} {}".format(self.stationname,
|
return 'BOM {} {}'.format(
|
||||||
SENSOR_TYPES[self._condition][0])
|
self.stationname, SENSOR_TYPES[self._condition][0])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
@ -165,9 +163,9 @@ class BOMCurrentData(object):
|
|||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from BOM."""
|
"""Get the latest data from BOM."""
|
||||||
if ((self._lastupdate != 0)
|
if self._lastupdate != 0 and \
|
||||||
and ((datetime.datetime.now() - self._lastupdate)) <
|
((datetime.datetime.now() - self._lastupdate) <
|
||||||
datetime.timedelta(minutes=35)):
|
datetime.timedelta(minutes=35)):
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"BOM was updated %s minutes ago, skipping update as"
|
"BOM was updated %s minutes ago, skipping update as"
|
||||||
" < 35 minutes", (datetime.datetime.now() - self._lastupdate))
|
" < 35 minutes", (datetime.datetime.now() - self._lastupdate))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user