Skip to content

Commit

Permalink
Merge pull request #36238 from home-assistant/rc
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored May 29, 2020
2 parents 4054b17 + 33f645a commit 7194b74
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 81 deletions.
5 changes: 5 additions & 0 deletions homeassistant/components/airvisual/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ def icon(self):
"""Return the icon."""
return self._icon

@property
def should_poll(self) -> bool:
"""Disable polling."""
return False

@property
def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/androidtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ def device_state_attributes(self):
"""Provide the last ADB command's response as an attribute."""
return {"adb_response": self._adb_response}

@property
def media_image_hash(self):
"""Hash value for media image."""
return f"{datetime.now().timestamp()}" if self._screencap else None

@property
def name(self):
"""Return the device name."""
Expand Down Expand Up @@ -497,11 +502,6 @@ def get_raw_media_data(self):
"""Raw image data."""
return self.aftv.adb_screencap()

@property
def media_image_hash(self):
"""Hash value for media image."""
return f"{datetime.now().timestamp()}"

@adb_decorator()
def media_play(self):
"""Send play command."""
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/cast/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ def internal_remove_callback(name, mdns):

_LOGGER.debug("Starting internal pychromecast discovery.")
listener, browser = pychromecast.start_discovery(
internal_add_callback, internal_remove_callback
internal_add_callback,
internal_remove_callback,
ChromeCastZeroconf.get_zeroconf(),
)
ChromeCastZeroconf.set_zeroconf(browser.zc)

def stop_discovery(event):
"""Stop discovery of new chromecasts."""
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/cast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "Google Cast",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/cast",
"requirements": ["pychromecast==5.1.0"],
"after_dependencies": ["cloud"],
"requirements": ["pychromecast==5.3.0"],
"after_dependencies": ["cloud","zeroconf"],
"zeroconf": ["_googlecast._tcp.local."],
"codeowners": ["@emontnemery"]
}
2 changes: 2 additions & 0 deletions homeassistant/components/cast/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
import voluptuous as vol

from homeassistant.components import zeroconf
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player.const import (
MEDIA_TYPE_MOVIE,
Expand Down Expand Up @@ -170,6 +171,7 @@ def async_cast_discovered(discover: ChromecastInfo) -> None:
for chromecast in list(hass.data[KNOWN_CHROMECAST_INFO_KEY]):
async_cast_discovered(chromecast)

ChromeCastZeroconf.set_zeroconf(await zeroconf.async_get_instance(hass))
hass.async_add_executor_job(setup_internal_discovery, hass)


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/devolo_home_control/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "devolo_home_control",
"name": "devolo_home_control",
"documentation": "https://www.home-assistant.io/integrations/devolo_home_control",
"requirements": ["devolo-home-control-api==0.10.0"],
"requirements": ["devolo-home-control-api==0.11.0"],
"config_flow": true,
"codeowners": [
"@2Fake",
Expand Down
19 changes: 7 additions & 12 deletions homeassistant/components/dsmr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
)
from homeassistant.core import CoreState, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.entity import Entity

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -113,7 +109,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=

async_add_entities(devices)

update_entities_telegram = partial(async_dispatcher_send, hass, DOMAIN)
def update_entities_telegram(telegram):
"""Update entities with latest telegram and trigger state update."""
# Make all device entities aware of new telegram
for device in devices:
device.update_data(telegram)

# Creates an asyncio.Protocol factory for reading DSMR telegrams from
# serial and calls update_entities_telegram to update entities on arrival
Expand Down Expand Up @@ -187,17 +187,12 @@ def __init__(self, name, obis, config):
self._config = config
self.telegram = {}

async def async_added_to_hass(self):
"""When entity is added to hass."""
self.async_on_remove(
async_dispatcher_connect(self.hass, DOMAIN, self.update_data)
)

@callback
def update_data(self, telegram):
"""Update data."""
self.telegram = telegram
self.async_write_ha_state()
if self.hass:
self.async_write_ha_state()

def get_dsmr_object_attr(self, attribute):
"""Read attribute from last received telegram for this DSMR object."""
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/heos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType):

async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Initialize config entry which represents the HEOS controller."""
# For backwards compat
if entry.unique_id is None:
hass.config_entries.async_update_entry(entry, unique_id=DOMAIN)

host = entry.data[CONF_HOST]
# Setting all_progress_events=False ensures that we only receive a
# media position update upon start of playback or when media changes
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/heos/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ async def async_step_ssdp(self, discovery_info):
# Abort if other flows in progress or an entry already exists
if self._async_in_progress() or self._async_current_entries():
return self.async_abort(reason="already_setup")
await self.async_set_unique_id(DOMAIN)
# Show selection form
return self.async_show_form(step_id="user")

async def async_step_import(self, user_input=None):
"""Occurs when an entry is setup through config."""
host = user_input[CONF_HOST]
# raise_on_progress is False here in case ssdp discovers
# heos first which would block the import
await self.async_set_unique_id(DOMAIN, raise_on_progress=False)
return self.async_create_entry(title=format_title(host), data={CONF_HOST: host})

async def async_step_user(self, user_input=None):
Expand Down
29 changes: 10 additions & 19 deletions homeassistant/components/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
EVENT_HOMEASSISTANT_STOP,
)
from homeassistant.core import Event, ServiceCall, callback
from homeassistant.exceptions import (
ConfigEntryNotReady,
HomeAssistantError,
Unauthorized,
)
from homeassistant.exceptions import HomeAssistantError, Unauthorized
from homeassistant.helpers import config_validation as cv, event, template
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
Expand Down Expand Up @@ -649,13 +645,7 @@ async def async_setup_entry(hass, entry):
tls_version=tls_version,
)

result: str = await hass.data[DATA_MQTT].async_connect()

if result == CONNECTION_FAILED:
return False

if result == CONNECTION_FAILED_RECOVERABLE:
raise ConfigEntryNotReady
await hass.data[DATA_MQTT].async_connect()

async def async_stop_mqtt(_event: Event):
"""Stop MQTT component."""
Expand Down Expand Up @@ -835,15 +825,14 @@ async def async_connect(self) -> str:
self._mqttc.connect, self.broker, self.port, self.keepalive
)
except OSError as err:
_LOGGER.error("Failed to connect due to exception: %s", err)
return CONNECTION_FAILED_RECOVERABLE
_LOGGER.error("Failed to connect to MQTT server due to exception: %s", err)

if result != 0:
_LOGGER.error("Failed to connect: %s", mqtt.error_string(result))
return CONNECTION_FAILED
if result is not None and result != 0:
_LOGGER.error(
"Failed to connect to MQTT server: %s", mqtt.error_string(result)
)

self._mqttc.loop_start()
return CONNECTION_SUCCESS

async def async_disconnect(self):
"""Stop the MQTT client."""
Expand Down Expand Up @@ -898,6 +887,7 @@ async def _async_unsubscribe(self, topic: str) -> None:
This method is a coroutine.
"""
_LOGGER.debug("Unsubscribing from %s", topic)
async with self._paho_lock:
result: int = None
result, _ = await self.hass.async_add_executor_job(
Expand Down Expand Up @@ -933,6 +923,7 @@ def _mqtt_on_connect(self, _mqttc, _userdata, _flags, result_code: int) -> None:
return

self.connected = True
_LOGGER.info("Connected to MQTT server (%s)", result_code)

# Group subscriptions to only re-subscribe once for each topic.
keyfunc = attrgetter("topic")
Expand Down Expand Up @@ -999,7 +990,7 @@ def _mqtt_handle_message(self, msg) -> None:
def _mqtt_on_disconnect(self, _mqttc, _userdata, result_code: int) -> None:
"""Disconnected callback."""
self.connected = False
_LOGGER.warning("Disconnected from MQTT (%s).", result_code)
_LOGGER.warning("Disconnected from MQTT server (%s)", result_code)


def _raise_on_error(result_code: int) -> None:
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/mqtt/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ async def async_close_cover_tilt(self, **kwargs):

async def async_set_cover_tilt_position(self, **kwargs):
"""Move the cover tilt to a specific position."""
position = float(kwargs[ATTR_TILT_POSITION])
position = kwargs[ATTR_TILT_POSITION]

# The position needs to be between min and max
level = self.find_in_range_from_percent(position)
Expand All @@ -550,10 +550,7 @@ async def async_set_cover_position(self, **kwargs):
percentage_position = position
if set_position_template is not None:
position = set_position_template.async_render(**kwargs)
elif (
self._config[CONF_POSITION_OPEN] != 100
and self._config[CONF_POSITION_CLOSED] != 0
):
else:
position = self.find_in_range_from_percent(position, COVER_PAYLOAD)

mqtt.async_publish(
Expand Down
12 changes: 8 additions & 4 deletions homeassistant/components/mqtt/device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ async def update_trigger(self, config, discovery_hash, remove_signal):
self.remove_signal = remove_signal
self.type = config[CONF_TYPE]
self.subtype = config[CONF_SUBTYPE]
self.topic = config[CONF_TOPIC]
self.payload = config[CONF_PAYLOAD]
self.qos = config[CONF_QOS]
topic_changed = self.topic != config[CONF_TOPIC]
self.topic = config[CONF_TOPIC]

# Unsubscribe+subscribe if this trigger is in use
for trig in self.trigger_instances:
await trig.async_attach_trigger()
# Unsubscribe+subscribe if this trigger is in use and topic has changed
# If topic is same unsubscribe+subscribe will execute in the wrong order
# because unsubscribe is done with help of async_create_task
if topic_changed:
for trig in self.trigger_instances:
await trig.async_attach_trigger()

def detach_trigger(self):
"""Remove MQTT device trigger."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onvif/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async def async_get_profiles(self) -> List[Profile]:
try:
ptz_service = self.device.create_ptz_service()
presets = await ptz_service.GetPresets(profile.token)
profile.ptz.presets = [preset.token for preset in presets]
profile.ptz.presets = [preset.token for preset in presets if preset]
except (Fault, ServerDisconnectedError):
# It's OK if Presets aren't supported
profile.ptz.presets = []
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/roku/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ async def async_select_source(self, source: str) -> None:
await self.coordinator.roku.remote("home")

appl = next(
(app for app in self.coordinator.data.apps if app.name == source), None
(
app
for app in self.coordinator.data.apps
if source in (app.name, app.app_id)
),
None,
)

if appl is not None:
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/todoist/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ async def async_get_events(self, hass, start_date, end_date):

events = []
for task in project_task_data:
if task["due"] is None:
continue
due_date = _parse_due_date(task["due"])
if start_date < due_date < end_date:
event = {
Expand Down
10 changes: 6 additions & 4 deletions homeassistant/components/zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def update_record(self, zc: "Zeroconf", now: float, record: DNSRecord) -> None:
# To avoid overwhemling the system we pre-filter here and only process
# DNSPointers for the configured record name (type)
#
if record.name != self.type or not isinstance(record, DNSPointer):
if record.name not in self.types or not isinstance(record, DNSPointer):
return
super().update_record(zc, now, record)

Expand Down Expand Up @@ -181,6 +181,7 @@ def service_update(zeroconf, service_type, name, state_change):
if not service_info:
# Prevent the browser thread from collapsing as
# service_info can be None
_LOGGER.debug("Failed to get info for device %s", name)
return

info = info_from_service(service_info)
Expand Down Expand Up @@ -216,11 +217,12 @@ def service_update(zeroconf, service_type, name, state_change):
)
)

for service in ZEROCONF:
HaServiceBrowser(zeroconf, service, handlers=[service_update])
types = list(ZEROCONF)

if HOMEKIT_TYPE not in ZEROCONF:
HaServiceBrowser(zeroconf, HOMEKIT_TYPE, handlers=[service_update])
types.append(HOMEKIT_TYPE)

HaServiceBrowser(zeroconf, types, handlers=[service_update])

return True

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zeroconf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "zeroconf",
"name": "Zero-configuration networking (zeroconf)",
"documentation": "https://www.home-assistant.io/integrations/zeroconf",
"requirements": ["zeroconf==0.26.1"],
"requirements": ["zeroconf==0.26.3"],
"dependencies": ["api"],
"codeowners": ["@robbiet480", "@Kane610"],
"quality_scale": "internal"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 110
PATCH_VERSION = "3"
PATCH_VERSION = "4"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 7, 0)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ruamel.yaml==0.15.100
sqlalchemy==1.3.16
voluptuous-serialize==2.3.0
voluptuous==0.11.7
zeroconf==0.26.1
zeroconf==0.26.3

pycryptodome>=3.6.6

Expand Down
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ deluge-client==1.7.1
denonavr==0.8.1

# homeassistant.components.devolo_home_control
devolo-home-control-api==0.10.0
devolo-home-control-api==0.11.0

# homeassistant.components.directv
directv==0.3.0
Expand Down Expand Up @@ -1245,7 +1245,7 @@ pycfdns==0.0.1
pychannels==1.0.0

# homeassistant.components.cast
pychromecast==5.1.0
pychromecast==5.3.0

# homeassistant.components.cmus
pycmus==0.1.1
Expand Down Expand Up @@ -2239,7 +2239,7 @@ youtube_dl==2020.05.08
zengge==0.2

# homeassistant.components.zeroconf
zeroconf==0.26.1
zeroconf==0.26.3

# homeassistant.components.zha
zha-quirks==0.0.39
Expand Down
Loading

0 comments on commit 7194b74

Please sign in to comment.