mirror of
https://github.com/home-assistant/core.git
synced 2026-01-11 10:08:57 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed3ca2b74f | ||
|
|
91a93b0060 | ||
|
|
6d3167fcd4 | ||
|
|
255607f3a5 | ||
|
|
73ed2ab164 | ||
|
|
d7efe274c1 | ||
|
|
91b7d56aa6 | ||
|
|
1895e03874 | ||
|
|
d80dce31da | ||
|
|
94f24e6d49 | ||
|
|
2e169320a4 | ||
|
|
dce6a9f882 | ||
|
|
5a802c1069 | ||
|
|
602b59aed8 | ||
|
|
6f8ac7f5c9 | ||
|
|
5910161202 | ||
|
|
afc70fda50 |
@@ -49,10 +49,6 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the FFmpeg binary motion sensor."""
|
||||
manager = hass.data[DATA_FFMPEG]
|
||||
|
||||
if not await manager.async_run_test(config.get(CONF_INPUT)):
|
||||
return
|
||||
|
||||
entity = FFmpegMotion(hass, manager, config)
|
||||
async_add_entities([entity])
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the FFmpeg noise binary sensor."""
|
||||
manager = hass.data[DATA_FFMPEG]
|
||||
|
||||
if not await manager.async_run_test(config.get(CONF_INPUT)):
|
||||
return
|
||||
|
||||
entity = FFmpegNoise(hass, manager, config)
|
||||
async_add_entities([entity])
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up a FFmpeg camera."""
|
||||
if not await hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_INPUT)):
|
||||
return
|
||||
async_add_entities([FFmpegCamera(hass, config)])
|
||||
|
||||
|
||||
|
||||
@@ -74,9 +74,6 @@ SERVICE_PTZ_SCHEMA = vol.Schema({
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up a ONVIF camera."""
|
||||
if not hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_HOST)):
|
||||
return
|
||||
|
||||
def handle_ptz(service):
|
||||
"""Handle PTZ service call."""
|
||||
pan = service.data.get(ATTR_PAN, None)
|
||||
@@ -93,8 +90,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
for camera in target_cameras:
|
||||
camera.perform_ptz(pan, tilt, zoom)
|
||||
|
||||
hass.services.async_register(DOMAIN, SERVICE_PTZ, handle_ptz,
|
||||
schema=SERVICE_PTZ_SCHEMA)
|
||||
hass.services.register(DOMAIN, SERVICE_PTZ, handle_ptz,
|
||||
schema=SERVICE_PTZ_SCHEMA)
|
||||
add_entities([ONVIFHassCamera(hass, config)])
|
||||
|
||||
|
||||
|
||||
@@ -40,12 +40,11 @@ CONF_OUTPUT = 'output'
|
||||
CONF_RUN_TEST = 'run_test'
|
||||
|
||||
DEFAULT_BINARY = 'ffmpeg'
|
||||
DEFAULT_RUN_TEST = True
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Optional(CONF_FFMPEG_BIN, default=DEFAULT_BINARY): cv.string,
|
||||
vol.Optional(CONF_RUN_TEST, default=DEFAULT_RUN_TEST): cv.boolean,
|
||||
vol.Optional(CONF_RUN_TEST): cv.boolean,
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
@@ -60,8 +59,7 @@ async def async_setup(hass, config):
|
||||
|
||||
manager = FFmpegManager(
|
||||
hass,
|
||||
conf.get(CONF_FFMPEG_BIN, DEFAULT_BINARY),
|
||||
conf.get(CONF_RUN_TEST, DEFAULT_RUN_TEST)
|
||||
conf.get(CONF_FFMPEG_BIN, DEFAULT_BINARY)
|
||||
)
|
||||
|
||||
# Register service
|
||||
@@ -95,40 +93,17 @@ async def async_setup(hass, config):
|
||||
class FFmpegManager:
|
||||
"""Helper for ha-ffmpeg."""
|
||||
|
||||
def __init__(self, hass, ffmpeg_bin, run_test):
|
||||
def __init__(self, hass, ffmpeg_bin):
|
||||
"""Initialize helper."""
|
||||
self.hass = hass
|
||||
self._cache = {}
|
||||
self._bin = ffmpeg_bin
|
||||
self._run_test = run_test
|
||||
|
||||
@property
|
||||
def binary(self):
|
||||
"""Return ffmpeg binary from config."""
|
||||
return self._bin
|
||||
|
||||
async def async_run_test(self, input_source):
|
||||
"""Run test on this input. TRUE is deactivate or run correct.
|
||||
|
||||
This method must be run in the event loop.
|
||||
"""
|
||||
from haffmpeg import Test
|
||||
|
||||
if self._run_test:
|
||||
# if in cache
|
||||
if input_source in self._cache:
|
||||
return self._cache[input_source]
|
||||
|
||||
# run test
|
||||
ffmpeg_test = Test(self.binary, loop=self.hass.loop)
|
||||
success = await ffmpeg_test.run_test(input_source)
|
||||
if not success:
|
||||
_LOGGER.error("FFmpeg '%s' test fails!", input_source)
|
||||
self._cache[input_source] = False
|
||||
return False
|
||||
self._cache[input_source] = True
|
||||
return True
|
||||
|
||||
|
||||
class FFmpegBase(Entity):
|
||||
"""Interface object for FFmpeg."""
|
||||
|
||||
@@ -24,7 +24,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.translation import async_get_translations
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
REQUIREMENTS = ['home-assistant-frontend==20181026.1']
|
||||
REQUIREMENTS = ['home-assistant-frontend==20181026.4']
|
||||
|
||||
DOMAIN = 'frontend'
|
||||
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log',
|
||||
|
||||
@@ -29,7 +29,7 @@ from .const import (
|
||||
from .util import (
|
||||
show_setup_message, validate_entity_config, validate_media_player_features)
|
||||
|
||||
REQUIREMENTS = ['HAP-python==2.3.0']
|
||||
REQUIREMENTS = ['HAP-python==2.2.2']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
import logging
|
||||
|
||||
from pyhap.const import (
|
||||
CATEGORY_FAUCET, CATEGORY_OUTLET, CATEGORY_SHOWER_HEAD,
|
||||
CATEGORY_SPRINKLER, CATEGORY_SWITCH)
|
||||
CATEGORY_OUTLET, CATEGORY_SWITCH)
|
||||
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.const import (
|
||||
@@ -19,6 +18,10 @@ from .const import (
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CATEGORY_SPRINKLER = 28
|
||||
CATEGORY_FAUCET = 29
|
||||
CATEGORY_SHOWER_HEAD = 30
|
||||
|
||||
VALVE_TYPE = {
|
||||
TYPE_FAUCET: (CATEGORY_FAUCET, 3),
|
||||
TYPE_SHOWER: (CATEGORY_SHOWER_HEAD, 2),
|
||||
|
||||
@@ -156,7 +156,7 @@ async def async_setup(hass, config):
|
||||
|
||||
# Initialize devices specified in the configuration on boot
|
||||
for device in cfg.get(CONF_DEVICES):
|
||||
ConfiguredDevice(hass, device).save_data()
|
||||
ConfiguredDevice(hass, device, config).save_data()
|
||||
|
||||
discovery.async_listen(
|
||||
hass,
|
||||
@@ -172,10 +172,11 @@ async def async_setup(hass, config):
|
||||
class ConfiguredDevice:
|
||||
"""A representation of a configured Konnected device."""
|
||||
|
||||
def __init__(self, hass, config):
|
||||
def __init__(self, hass, config, hass_config):
|
||||
"""Initialize the Konnected device."""
|
||||
self.hass = hass
|
||||
self.config = config
|
||||
self.hass_config = hass_config
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
@@ -237,11 +238,11 @@ class ConfiguredDevice:
|
||||
self.hass.data[DOMAIN][CONF_DEVICES][self.device_id] = device_data
|
||||
|
||||
discovery.load_platform(
|
||||
self.hass, 'binary_sensor',
|
||||
DOMAIN, {'device_id': self.device_id})
|
||||
self.hass, 'binary_sensor', DOMAIN,
|
||||
{'device_id': self.device_id}, self.hass_config)
|
||||
discovery.load_platform(
|
||||
self.hass, 'switch', DOMAIN,
|
||||
{'device_id': self.device_id})
|
||||
{'device_id': self.device_id}, self.hass_config)
|
||||
|
||||
|
||||
class DiscoveredDevice:
|
||||
|
||||
@@ -55,7 +55,7 @@ SENSOR_SCHEMA = vol.Schema({
|
||||
|
||||
AWAY_SCHEMA = vol.Schema({
|
||||
vol.Required(ATTR_HOME_MODE): vol.In([HOME_MODE_AWAY, HOME_MODE_HOME]),
|
||||
vol.Optional(ATTR_STRUCTURE): vol.All(cv.ensure_list, cv.string),
|
||||
vol.Optional(ATTR_STRUCTURE): vol.All(cv.ensure_list, [cv.string]),
|
||||
vol.Optional(ATTR_TRIP_ID): cv.string,
|
||||
vol.Optional(ATTR_ETA): cv.time_period,
|
||||
vol.Optional(ATTR_ETA_WINDOW): cv.time_period
|
||||
@@ -65,7 +65,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
||||
vol.Required(CONF_CLIENT_SECRET): cv.string,
|
||||
vol.Optional(CONF_STRUCTURE): vol.All(cv.ensure_list, cv.string),
|
||||
vol.Optional(CONF_STRUCTURE): vol.All(cv.ensure_list, [cv.string]),
|
||||
vol.Optional(CONF_SENSORS): SENSOR_SCHEMA,
|
||||
vol.Optional(CONF_BINARY_SENSORS): SENSOR_SCHEMA
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ from homeassistant.util import slugify
|
||||
from homeassistant.util.color import (
|
||||
color_temperature_to_rgb, color_RGB_to_xy_brightness,
|
||||
color_temperature_kelvin_to_mired)
|
||||
from homeassistant.util.dt import now as dt_now
|
||||
from homeassistant.util.dt import utcnow as dt_utcnow, as_local
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -195,10 +195,12 @@ class FluxSwitch(SwitchDevice):
|
||||
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def flux_update(self, now=None):
|
||||
def flux_update(self, utcnow=None):
|
||||
"""Update all the lights using flux."""
|
||||
if now is None:
|
||||
now = dt_now()
|
||||
if utcnow is None:
|
||||
utcnow = dt_utcnow()
|
||||
|
||||
now = as_local(utcnow)
|
||||
|
||||
sunset = get_astral_event_date(self.hass, 'sunset', now.date())
|
||||
start_time = self.find_start_time(now)
|
||||
|
||||
@@ -20,7 +20,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
REQUIREMENTS = ['pyipma==1.1.3']
|
||||
REQUIREMENTS = ['pyipma==1.1.4']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -71,8 +71,8 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||
station = await Station.get(websession, float(latitude),
|
||||
float(longitude))
|
||||
|
||||
_LOGGER.debug("Initializing ipma weather: coordinates %s, %s",
|
||||
latitude, longitude)
|
||||
_LOGGER.debug("Initializing for coordinates %s, %s -> station %s",
|
||||
latitude, longitude, station.local)
|
||||
|
||||
async_add_entities([IPMAWeather(station, config)], True)
|
||||
|
||||
@@ -93,6 +93,8 @@ class IPMAWeather(WeatherEntity):
|
||||
"""Update Condition and Forecast."""
|
||||
with async_timeout.timeout(10, loop=self.hass.loop):
|
||||
self._condition = await self._station.observation()
|
||||
_LOGGER.debug("Updating station %s, condition %s",
|
||||
self._station.local, self._condition)
|
||||
self._forecast = await self._station.forecast()
|
||||
self._description = self._forecast[0].description
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from homeassistant.const import (
|
||||
CONF_NAME, TEMP_CELSIUS)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.util import dt, Throttle
|
||||
from homeassistant.util import dt, slugify, Throttle
|
||||
|
||||
from homeassistant.components.weather import (
|
||||
WeatherEntity, ATTR_FORECAST_CONDITION, ATTR_FORECAST_TEMP,
|
||||
@@ -73,11 +73,11 @@ async def async_setup_entry(hass: HomeAssistant,
|
||||
config_entries) -> bool:
|
||||
"""Add a weather entity from map location."""
|
||||
location = config_entry.data
|
||||
name = location[CONF_NAME]
|
||||
name = slugify(location[CONF_NAME])
|
||||
|
||||
session = aiohttp_client.async_get_clientsession(hass)
|
||||
|
||||
entity = SmhiWeather(name, location[CONF_LATITUDE],
|
||||
entity = SmhiWeather(location[CONF_NAME], location[CONF_LATITUDE],
|
||||
location[CONF_LONGITUDE],
|
||||
session=session)
|
||||
entity.entity_id = ENTITY_ID_SENSOR_FORMAT.format(name)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 81
|
||||
PATCH_VERSION = '2'
|
||||
PATCH_VERSION = '5'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 5, 3)
|
||||
|
||||
@@ -34,7 +34,7 @@ Adafruit-SHT31==1.0.2
|
||||
DoorBirdPy==0.1.3
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==2.3.0
|
||||
HAP-python==2.2.2
|
||||
|
||||
# homeassistant.components.notify.mastodon
|
||||
Mastodon.py==1.3.1
|
||||
@@ -466,7 +466,7 @@ hole==0.3.0
|
||||
holidays==0.9.8
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20181026.1
|
||||
home-assistant-frontend==20181026.4
|
||||
|
||||
# homeassistant.components.homekit_controller
|
||||
# homekit==0.10
|
||||
@@ -929,7 +929,7 @@ pyialarm==0.2
|
||||
pyicloud==0.9.1
|
||||
|
||||
# homeassistant.components.weather.ipma
|
||||
pyipma==1.1.3
|
||||
pyipma==1.1.4
|
||||
|
||||
# homeassistant.components.sensor.irish_rail_transport
|
||||
pyirishrail==0.0.2
|
||||
|
||||
@@ -19,7 +19,7 @@ requests_mock==1.5.2
|
||||
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==2.3.0
|
||||
HAP-python==2.2.2
|
||||
|
||||
# homeassistant.components.sensor.rmvtransport
|
||||
PyRMVtransport==0.1.3
|
||||
@@ -97,7 +97,7 @@ hdate==0.6.5
|
||||
holidays==0.9.8
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20181026.1
|
||||
home-assistant-frontend==20181026.4
|
||||
|
||||
# homeassistant.components.homematicip_cloud
|
||||
homematicip==0.9.8
|
||||
|
||||
@@ -15,9 +15,6 @@ class TestFFmpegNoiseSetup:
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
self.config = {
|
||||
'ffmpeg': {
|
||||
'run_test': False,
|
||||
},
|
||||
'binary_sensor': {
|
||||
'platform': 'ffmpeg_noise',
|
||||
'input': 'testinputvideo',
|
||||
@@ -80,9 +77,6 @@ class TestFFmpegMotionSetup:
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
self.config = {
|
||||
'ffmpeg': {
|
||||
'run_test': False,
|
||||
},
|
||||
'binary_sensor': {
|
||||
'platform': 'ffmpeg_motion',
|
||||
'input': 'testinputvideo',
|
||||
|
||||
@@ -82,7 +82,6 @@ async def test_no_code(hass, hk_driver, config, events):
|
||||
# Set from HomeKit
|
||||
call_lock = async_mock_service(hass, DOMAIN, 'lock')
|
||||
|
||||
acc.char_target_state.value = 0
|
||||
await hass.async_add_job(acc.char_target_state.client_update_value, 1)
|
||||
await hass.async_block_till_done()
|
||||
assert call_lock
|
||||
|
||||
@@ -64,7 +64,6 @@ async def test_media_player_set_state(hass, hk_driver, events):
|
||||
call_media_stop = async_mock_service(hass, DOMAIN, 'media_stop')
|
||||
call_toggle_mute = async_mock_service(hass, DOMAIN, 'volume_mute')
|
||||
|
||||
acc.chars[FEATURE_ON_OFF].value = False
|
||||
await hass.async_add_job(acc.chars[FEATURE_ON_OFF]
|
||||
.client_update_value, True)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -87,7 +87,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=10, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=10, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
|
||||
with patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
@@ -128,7 +128,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=2, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -137,7 +137,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
|
||||
with patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
@@ -174,7 +174,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=8, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -183,7 +183,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -221,7 +221,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=17, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -230,7 +230,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -269,7 +269,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=23, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=23, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -278,7 +278,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
|
||||
with patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
@@ -315,7 +315,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=17, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -324,7 +324,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -366,7 +366,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=2, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -375,7 +375,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -418,7 +418,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=8, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -427,7 +427,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -469,7 +469,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=23, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=23, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -478,7 +478,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
|
||||
with patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
@@ -519,7 +519,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=00, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=00, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -528,7 +528,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -570,7 +570,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=2, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=2, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -579,7 +579,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -618,7 +618,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=17, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -627,7 +627,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -668,7 +668,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=17, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=17, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -677,7 +677,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -729,7 +729,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('xy_color'))
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=12, minute=0, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=12, minute=0, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -740,7 +740,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
print('sunset {}'.format(sunset_time))
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -784,7 +784,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertIsNone(state.attributes.get('color_temp'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=8, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -793,7 +793,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
@@ -829,7 +829,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertIsNone(state.attributes.get('color_temp'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=8, minute=30, second=0)
|
||||
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5, minute=0, second=0)
|
||||
|
||||
@@ -838,7 +838,7 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
return sunrise_time
|
||||
return sunset_time
|
||||
|
||||
with patch('homeassistant.components.switch.flux.dt_now',
|
||||
with patch('homeassistant.components.switch.flux.dt_utcnow',
|
||||
return_value=test_time), \
|
||||
patch('homeassistant.helpers.sun.get_astral_event_date',
|
||||
side_effect=event_date):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""The tests for Home Assistant ffmpeg."""
|
||||
import asyncio
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import homeassistant.components.ffmpeg as ffmpeg
|
||||
from homeassistant.components.ffmpeg import (
|
||||
@@ -10,7 +10,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.setup import setup_component, async_setup_component
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, mock_coro)
|
||||
get_test_home_assistant, assert_setup_component)
|
||||
|
||||
|
||||
@callback
|
||||
@@ -85,14 +85,14 @@ class TestFFmpegSetup:
|
||||
|
||||
def test_setup_component(self):
|
||||
"""Set up ffmpeg component."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
assert self.hass.data[ffmpeg.DATA_FFMPEG].binary == 'ffmpeg'
|
||||
|
||||
def test_setup_component_test_service(self):
|
||||
"""Set up ffmpeg component test services."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
assert self.hass.services.has_service(ffmpeg.DOMAIN, 'start')
|
||||
@@ -103,7 +103,7 @@ class TestFFmpegSetup:
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_register(hass):
|
||||
"""Set up ffmpeg component test register."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -118,7 +118,7 @@ def test_setup_component_test_register(hass):
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_register_no_startup(hass):
|
||||
"""Set up ffmpeg component test register without startup."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -133,7 +133,7 @@ def test_setup_component_test_register_no_startup(hass):
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_service_start(hass):
|
||||
"""Set up ffmpeg component test service start."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -149,7 +149,7 @@ def test_setup_component_test_service_start(hass):
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_service_stop(hass):
|
||||
"""Set up ffmpeg component test service stop."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -165,7 +165,7 @@ def test_setup_component_test_service_stop(hass):
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_service_restart(hass):
|
||||
"""Set up ffmpeg component test service restart."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -182,7 +182,7 @@ def test_setup_component_test_service_restart(hass):
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_service_start_with_entity(hass):
|
||||
"""Set up ffmpeg component test service start."""
|
||||
with assert_setup_component(2):
|
||||
with assert_setup_component(1):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
@@ -194,71 +194,3 @@ def test_setup_component_test_service_start_with_entity(hass):
|
||||
|
||||
assert ffmpeg_dev.called_start
|
||||
assert ffmpeg_dev.called_entities == ['test.ffmpeg_device']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_run_test_false(hass):
|
||||
"""Set up ffmpeg component test run_test false."""
|
||||
with assert_setup_component(2):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {
|
||||
'run_test': False,
|
||||
}})
|
||||
|
||||
manager = hass.data[ffmpeg.DATA_FFMPEG]
|
||||
with patch('haffmpeg.Test.run_test', return_value=mock_coro(False)):
|
||||
yield from manager.async_run_test("blabalblabla")
|
||||
|
||||
assert len(manager._cache) == 0
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_run_test(hass):
|
||||
"""Set up ffmpeg component test run_test."""
|
||||
with assert_setup_component(2):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
manager = hass.data[ffmpeg.DATA_FFMPEG]
|
||||
|
||||
with patch('haffmpeg.Test.run_test', return_value=mock_coro(True)) \
|
||||
as mock_test:
|
||||
yield from manager.async_run_test("blabalblabla")
|
||||
|
||||
assert mock_test.called
|
||||
assert mock_test.call_count == 1
|
||||
assert len(manager._cache) == 1
|
||||
assert manager._cache['blabalblabla']
|
||||
|
||||
yield from manager.async_run_test("blabalblabla")
|
||||
|
||||
assert mock_test.called
|
||||
assert mock_test.call_count == 1
|
||||
assert len(manager._cache) == 1
|
||||
assert manager._cache['blabalblabla']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_setup_component_test_run_test_test_fail(hass):
|
||||
"""Set up ffmpeg component test run_test."""
|
||||
with assert_setup_component(2):
|
||||
yield from async_setup_component(
|
||||
hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
manager = hass.data[ffmpeg.DATA_FFMPEG]
|
||||
|
||||
with patch('haffmpeg.Test.run_test', return_value=mock_coro(False)) \
|
||||
as mock_test:
|
||||
yield from manager.async_run_test("blabalblabla")
|
||||
|
||||
assert mock_test.called
|
||||
assert mock_test.call_count == 1
|
||||
assert len(manager._cache) == 1
|
||||
assert not manager._cache['blabalblabla']
|
||||
|
||||
yield from manager.async_run_test("blabalblabla")
|
||||
|
||||
assert mock_test.called
|
||||
assert mock_test.call_count == 1
|
||||
assert len(manager._cache) == 1
|
||||
assert not manager._cache['blabalblabla']
|
||||
|
||||
Reference in New Issue
Block a user