2019-10-12 19:43:06 +00:00
|
|
|
|
"""Tests for HomematicIP Cloud weather."""
|
2019-10-15 10:12:58 +00:00
|
|
|
|
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
2019-10-12 19:43:06 +00:00
|
|
|
|
from homeassistant.components.weather import (
|
|
|
|
|
ATTR_WEATHER_ATTRIBUTION,
|
|
|
|
|
ATTR_WEATHER_HUMIDITY,
|
|
|
|
|
ATTR_WEATHER_TEMPERATURE,
|
|
|
|
|
ATTR_WEATHER_WIND_BEARING,
|
|
|
|
|
ATTR_WEATHER_WIND_SPEED,
|
2019-10-15 10:12:58 +00:00
|
|
|
|
DOMAIN as WEATHER_DOMAIN,
|
2019-10-12 19:43:06 +00:00
|
|
|
|
)
|
2019-10-15 10:12:58 +00:00
|
|
|
|
from homeassistant.setup import async_setup_component
|
2019-10-12 19:43:06 +00:00
|
|
|
|
|
|
|
|
|
from .helper import async_manipulate_test_data, get_and_check_entity_basics
|
|
|
|
|
|
|
|
|
|
|
2019-10-15 10:12:58 +00:00
|
|
|
|
async def test_manually_configured_platform(hass):
|
|
|
|
|
"""Test that we do not set up an access point."""
|
2020-02-16 09:09:26 +00:00
|
|
|
|
assert await async_setup_component(
|
|
|
|
|
hass, WEATHER_DOMAIN, {WEATHER_DOMAIN: {"platform": HMIPC_DOMAIN}}
|
2019-10-15 10:12:58 +00:00
|
|
|
|
)
|
|
|
|
|
assert not hass.data.get(HMIPC_DOMAIN)
|
|
|
|
|
|
|
|
|
|
|
2020-02-14 06:56:17 +00:00
|
|
|
|
async def test_hmip_weather_sensor(hass, default_mock_hap_factory):
|
2019-10-12 19:43:06 +00:00
|
|
|
|
"""Test HomematicipWeatherSensor."""
|
|
|
|
|
entity_id = "weather.weather_sensor_plus"
|
|
|
|
|
entity_name = "Weather Sensor – plus"
|
|
|
|
|
device_model = "HmIP-SWO-PL"
|
2020-02-14 06:56:17 +00:00
|
|
|
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
|
|
|
|
|
test_devices=[entity_name]
|
|
|
|
|
)
|
2019-10-12 19:43:06 +00:00
|
|
|
|
|
|
|
|
|
ha_state, hmip_device = get_and_check_entity_basics(
|
2020-02-14 06:56:17 +00:00
|
|
|
|
hass, mock_hap, entity_id, entity_name, device_model
|
2019-10-12 19:43:06 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert ha_state.state == ""
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 4.3
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_HUMIDITY] == 97
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_WIND_SPEED] == 15.0
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_ATTRIBUTION] == "Powered by Homematic IP"
|
|
|
|
|
|
|
|
|
|
await async_manipulate_test_data(hass, hmip_device, "actualTemperature", 12.1)
|
|
|
|
|
ha_state = hass.states.get(entity_id)
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 12.1
|
|
|
|
|
|
|
|
|
|
|
2020-02-14 06:56:17 +00:00
|
|
|
|
async def test_hmip_weather_sensor_pro(hass, default_mock_hap_factory):
|
2019-10-12 19:43:06 +00:00
|
|
|
|
"""Test HomematicipWeatherSensorPro."""
|
|
|
|
|
entity_id = "weather.wettersensor_pro"
|
|
|
|
|
entity_name = "Wettersensor - pro"
|
|
|
|
|
device_model = "HmIP-SWO-PR"
|
2020-02-14 06:56:17 +00:00
|
|
|
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
|
|
|
|
|
test_devices=[entity_name]
|
|
|
|
|
)
|
2019-10-12 19:43:06 +00:00
|
|
|
|
|
|
|
|
|
ha_state, hmip_device = get_and_check_entity_basics(
|
2020-02-14 06:56:17 +00:00
|
|
|
|
hass, mock_hap, entity_id, entity_name, device_model
|
2019-10-12 19:43:06 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert ha_state.state == "sunny"
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 15.4
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_HUMIDITY] == 65
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_WIND_SPEED] == 2.6
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_WIND_BEARING] == 295.0
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_ATTRIBUTION] == "Powered by Homematic IP"
|
|
|
|
|
|
|
|
|
|
await async_manipulate_test_data(hass, hmip_device, "actualTemperature", 12.1)
|
|
|
|
|
ha_state = hass.states.get(entity_id)
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 12.1
|
|
|
|
|
|
|
|
|
|
|
2020-02-14 06:56:17 +00:00
|
|
|
|
async def test_hmip_home_weather(hass, default_mock_hap_factory):
|
2019-10-12 19:43:06 +00:00
|
|
|
|
"""Test HomematicipHomeWeather."""
|
|
|
|
|
entity_id = "weather.weather_1010_wien_osterreich"
|
|
|
|
|
entity_name = "Weather 1010 Wien, Österreich"
|
|
|
|
|
device_model = None
|
2020-02-14 06:56:17 +00:00
|
|
|
|
mock_hap = await default_mock_hap_factory.async_get_mock_hap()
|
2019-10-12 19:43:06 +00:00
|
|
|
|
|
|
|
|
|
ha_state, hmip_device = get_and_check_entity_basics(
|
2020-02-14 06:56:17 +00:00
|
|
|
|
hass, mock_hap, entity_id, entity_name, device_model
|
2019-10-12 19:43:06 +00:00
|
|
|
|
)
|
|
|
|
|
assert hmip_device
|
|
|
|
|
assert ha_state.state == "partlycloudy"
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 16.6
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_HUMIDITY] == 54
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_WIND_SPEED] == 8.6
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_WIND_BEARING] == 294
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_ATTRIBUTION] == "Powered by Homematic IP"
|
|
|
|
|
|
|
|
|
|
await async_manipulate_test_data(
|
2020-02-14 06:56:17 +00:00
|
|
|
|
hass, mock_hap.home.weather, "temperature", 28.3, fire_device=mock_hap.home
|
2019-10-12 19:43:06 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ha_state = hass.states.get(entity_id)
|
|
|
|
|
assert ha_state.attributes[ATTR_WEATHER_TEMPERATURE] == 28.3
|