mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
commit
22c01b956f
@ -68,7 +68,8 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
if self._state in (STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY) and \
|
if self._state in (STATE_ALARM_ARMED_HOME,
|
||||||
|
STATE_ALARM_ARMED_AWAY) and \
|
||||||
self._pending_time and self._state_ts + self._pending_time > \
|
self._pending_time and self._state_ts + self._pending_time > \
|
||||||
dt_util.utcnow():
|
dt_util.utcnow():
|
||||||
return STATE_ALARM_PENDING
|
return STATE_ALARM_PENDING
|
||||||
|
@ -6,6 +6,7 @@ Offers numeric state listening automation rules.
|
|||||||
For more details about this automation rule, please refer to the documentation
|
For more details about this automation rule, please refer to the documentation
|
||||||
at https://home-assistant.io/components/automation/#numeric-state-trigger
|
at https://home-assistant.io/components/automation/#numeric-state-trigger
|
||||||
"""
|
"""
|
||||||
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.const import CONF_VALUE_TEMPLATE
|
from homeassistant.const import CONF_VALUE_TEMPLATE
|
||||||
@ -20,6 +21,14 @@ CONF_ABOVE = "above"
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _renderer(hass, value_template, state):
|
||||||
|
"""Render state value."""
|
||||||
|
if value_template is None:
|
||||||
|
return state.state
|
||||||
|
|
||||||
|
return template.render(hass, value_template, {'state': state})
|
||||||
|
|
||||||
|
|
||||||
def trigger(hass, config, action):
|
def trigger(hass, config, action):
|
||||||
""" Listen for state changes based on `config`. """
|
""" Listen for state changes based on `config`. """
|
||||||
entity_id = config.get(CONF_ENTITY_ID)
|
entity_id = config.get(CONF_ENTITY_ID)
|
||||||
@ -38,12 +47,7 @@ def trigger(hass, config, action):
|
|||||||
CONF_BELOW, CONF_ABOVE)
|
CONF_BELOW, CONF_ABOVE)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if value_template is not None:
|
renderer = partial(_renderer, hass, value_template)
|
||||||
renderer = lambda value: template.render(hass,
|
|
||||||
value_template,
|
|
||||||
{'state': value})
|
|
||||||
else:
|
|
||||||
renderer = lambda value: value.state
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def state_automation_listener(entity, from_s, to_s):
|
def state_automation_listener(entity, from_s, to_s):
|
||||||
@ -79,12 +83,7 @@ def if_action(hass, config):
|
|||||||
CONF_BELOW, CONF_ABOVE)
|
CONF_BELOW, CONF_ABOVE)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if value_template is not None:
|
renderer = partial(_renderer, hass, value_template)
|
||||||
renderer = lambda value: template.render(hass,
|
|
||||||
value_template,
|
|
||||||
{'state': value})
|
|
||||||
else:
|
|
||||||
renderer = lambda value: value.state
|
|
||||||
|
|
||||||
def if_numeric_state():
|
def if_numeric_state():
|
||||||
""" Test numeric state condition. """
|
""" Test numeric state condition. """
|
||||||
|
@ -80,18 +80,30 @@ def if_action(hass, config):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if before is None:
|
if before is None:
|
||||||
before_func = lambda: None
|
def before_func():
|
||||||
|
"""Return no point in time."""
|
||||||
|
return None
|
||||||
elif before == EVENT_SUNRISE:
|
elif before == EVENT_SUNRISE:
|
||||||
before_func = lambda: sun.next_rising(hass) + before_offset
|
def before_func():
|
||||||
|
"""Return time before sunrise."""
|
||||||
|
return sun.next_rising(hass) + before_offset
|
||||||
else:
|
else:
|
||||||
before_func = lambda: sun.next_setting(hass) + before_offset
|
def before_func():
|
||||||
|
"""Return time before sunset."""
|
||||||
|
return sun.next_setting(hass) + before_offset
|
||||||
|
|
||||||
if after is None:
|
if after is None:
|
||||||
after_func = lambda: None
|
def after_func():
|
||||||
|
"""Return no point in time."""
|
||||||
|
return None
|
||||||
elif after == EVENT_SUNRISE:
|
elif after == EVENT_SUNRISE:
|
||||||
after_func = lambda: sun.next_rising(hass) + after_offset
|
def after_func():
|
||||||
|
"""Return time after sunrise."""
|
||||||
|
return sun.next_rising(hass) + after_offset
|
||||||
else:
|
else:
|
||||||
after_func = lambda: sun.next_setting(hass) + after_offset
|
def after_func():
|
||||||
|
"""Return time after sunset."""
|
||||||
|
return sun.next_setting(hass) + after_offset
|
||||||
|
|
||||||
def time_if():
|
def time_if():
|
||||||
""" Validate time based if-condition """
|
""" Validate time based if-condition """
|
||||||
|
@ -32,8 +32,8 @@ def trigger(hass, config, action):
|
|||||||
_error_time(config[CONF_AFTER], CONF_AFTER)
|
_error_time(config[CONF_AFTER], CONF_AFTER)
|
||||||
return False
|
return False
|
||||||
hours, minutes, seconds = after.hour, after.minute, after.second
|
hours, minutes, seconds = after.hour, after.minute, after.second
|
||||||
elif (CONF_HOURS in config or CONF_MINUTES in config
|
elif (CONF_HOURS in config or CONF_MINUTES in config or
|
||||||
or CONF_SECONDS in config):
|
CONF_SECONDS in config):
|
||||||
hours = convert(config.get(CONF_HOURS), int)
|
hours = convert(config.get(CONF_HOURS), int)
|
||||||
minutes = convert(config.get(CONF_MINUTES), int)
|
minutes = convert(config.get(CONF_MINUTES), int)
|
||||||
seconds = convert(config.get(CONF_SECONDS), int)
|
seconds = convert(config.get(CONF_SECONDS), int)
|
||||||
|
@ -105,8 +105,7 @@ class SnmpScanner(object):
|
|||||||
return
|
return
|
||||||
if errstatus:
|
if errstatus:
|
||||||
_LOGGER.error('SNMP error: %s at %s', errstatus.prettyPrint(),
|
_LOGGER.error('SNMP error: %s at %s', errstatus.prettyPrint(),
|
||||||
errindex and restable[-1][int(errindex)-1]
|
errindex and restable[-1][int(errindex)-1] or '?')
|
||||||
or '?')
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for resrow in restable:
|
for resrow in restable:
|
||||||
|
@ -242,8 +242,8 @@ class Tplink3DeviceScanner(TplinkDeviceScanner):
|
|||||||
|
|
||||||
_LOGGER.info("Loading wireless clients...")
|
_LOGGER.info("Loading wireless clients...")
|
||||||
|
|
||||||
url = 'http://{}/cgi-bin/luci/;stok={}/admin/wireless?form=statistics' \
|
url = ('http://{}/cgi-bin/luci/;stok={}/admin/wireless?'
|
||||||
.format(self.host, self.stok)
|
'form=statistics').format(self.host, self.stok)
|
||||||
referer = 'http://{}/webpages/index.html'.format(self.host)
|
referer = 'http://{}/webpages/index.html'.format(self.host)
|
||||||
|
|
||||||
response = requests.post(url,
|
response = requests.post(url,
|
||||||
|
@ -198,12 +198,12 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
|||||||
"Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY)
|
"Error parsing JSON", HTTP_UNPROCESSABLE_ENTITY)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.authenticated = (self.server.api_password is None
|
self.authenticated = (self.server.api_password is None or
|
||||||
or self.headers.get(HTTP_HEADER_HA_AUTH) ==
|
self.headers.get(HTTP_HEADER_HA_AUTH) ==
|
||||||
self.server.api_password
|
self.server.api_password or
|
||||||
or data.get(DATA_API_PASSWORD) ==
|
data.get(DATA_API_PASSWORD) ==
|
||||||
self.server.api_password
|
self.server.api_password or
|
||||||
or self.verify_session())
|
self.verify_session())
|
||||||
|
|
||||||
if '_METHOD' in data:
|
if '_METHOD' in data:
|
||||||
method = data.pop('_METHOD')
|
method = data.pop('_METHOD')
|
||||||
|
@ -13,8 +13,9 @@ from homeassistant.components.light import Light
|
|||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.components.rfxtrx import ATTR_STATE, ATTR_FIREEVENT, ATTR_PACKETID, \
|
from homeassistant.components.rfxtrx import (
|
||||||
ATTR_NAME, EVENT_BUTTON_PRESSED
|
ATTR_STATE, ATTR_FIREEVENT, ATTR_PACKETID,
|
||||||
|
ATTR_NAME, EVENT_BUTTON_PRESSED)
|
||||||
|
|
||||||
|
|
||||||
DEPENDENCIES = ['rfxtrx']
|
DEPENDENCIES = ['rfxtrx']
|
||||||
|
@ -22,9 +22,9 @@ from homeassistant.const import (
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SUPPORT_SQUEEZEBOX = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE |\
|
SUPPORT_SQUEEZEBOX = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | \
|
||||||
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK |\
|
SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
|
||||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF
|
SUPPORT_SEEK | SUPPORT_TURN_ON | SUPPORT_TURN_OFF
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -202,9 +202,8 @@ class SqueezeBoxDevice(MediaPlayerDevice):
|
|||||||
""" Image url of current playing media. """
|
""" Image url of current playing media. """
|
||||||
if 'artwork_url' in self._status:
|
if 'artwork_url' in self._status:
|
||||||
return self._status['artwork_url']
|
return self._status['artwork_url']
|
||||||
return 'http://{server}:{port}/music/current/cover.jpg?player={player}'\
|
return ('http://{server}:{port}/music/current/cover.jpg?'
|
||||||
.format(
|
'player={player}').format(server=self._lms.host,
|
||||||
server=self._lms.host,
|
|
||||||
port=self._lms.http_port,
|
port=self._lms.http_port,
|
||||||
player=self._id)
|
player=self._id)
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import logging
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, \
|
from homeassistant.const import (ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE,
|
||||||
DEVICE_DEFAULT_NAME
|
DEVICE_DEFAULT_NAME)
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import template, Throttle
|
from homeassistant.util import template, Throttle
|
||||||
|
@ -13,8 +13,9 @@ from homeassistant.components.switch import SwitchDevice
|
|||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.components.rfxtrx import ATTR_STATE, ATTR_FIREEVENT, ATTR_PACKETID, \
|
from homeassistant.components.rfxtrx import (
|
||||||
ATTR_NAME, EVENT_BUTTON_PRESSED
|
ATTR_STATE, ATTR_FIREEVENT, ATTR_PACKETID,
|
||||||
|
ATTR_NAME, EVENT_BUTTON_PRESSED)
|
||||||
|
|
||||||
|
|
||||||
DEPENDENCIES = ['rfxtrx']
|
DEPENDENCIES = ['rfxtrx']
|
||||||
|
@ -46,8 +46,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
return
|
return
|
||||||
data = ecobee.NETWORK
|
data = ecobee.NETWORK
|
||||||
hold_temp = discovery_info['hold_temp']
|
hold_temp = discovery_info['hold_temp']
|
||||||
_LOGGER.info("Loading ecobee thermostat component with hold_temp set to "
|
_LOGGER.info(
|
||||||
+ str(hold_temp))
|
"Loading ecobee thermostat component with hold_temp set to %s",
|
||||||
|
hold_temp)
|
||||||
add_devices(Thermostat(data, index, hold_temp)
|
add_devices(Thermostat(data, index, hold_temp)
|
||||||
for index in range(len(data.ecobee.thermostats)))
|
for index in range(len(data.ecobee.thermostats)))
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
flake8>=2.5.0
|
flake8>=2.5.1
|
||||||
pylint>=1.5.1
|
pylint>=1.5.3
|
||||||
coveralls>=1.1
|
coveralls>=1.1
|
||||||
pytest>=2.6.4
|
pytest>=2.6.4
|
||||||
pytest-cov>=2.2.0
|
pytest-cov>=2.2.0
|
||||||
|
@ -11,10 +11,10 @@ from unittest.mock import patch
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from homeassistant import bootstrap, const
|
from homeassistant import bootstrap, const
|
||||||
import homeassistant.core as ha
|
|
||||||
import homeassistant.components.device_tracker as device_tracker
|
import homeassistant.components.device_tracker as device_tracker
|
||||||
import homeassistant.components.http as http
|
import homeassistant.components.http as http
|
||||||
import homeassistant.components.zone as zone
|
|
||||||
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
SERVER_PORT = 8126
|
SERVER_PORT = 8126
|
||||||
HTTP_BASE_URL = "http://127.0.0.1:{}".format(SERVER_PORT)
|
HTTP_BASE_URL = "http://127.0.0.1:{}".format(SERVER_PORT)
|
||||||
@ -34,7 +34,7 @@ def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
|||||||
""" Initalizes a Home Assistant server. """
|
""" Initalizes a Home Assistant server. """
|
||||||
global hass
|
global hass
|
||||||
|
|
||||||
hass = ha.HomeAssistant()
|
hass = get_test_home_assistant()
|
||||||
|
|
||||||
# Set up server
|
# Set up server
|
||||||
bootstrap.setup_component(hass, http.DOMAIN, {
|
bootstrap.setup_component(hass, http.DOMAIN, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user