Skip to content
Permalink
Browse files

Merge pull request #35907 from home-assistant/rc

0.110.1
  • Loading branch information
pvizeli committed May 21, 2020
2 parents 70b1451 + b266d3a commit 7c784b69638f3e2b3c91294b31a62e1058ba9709
@@ -16,7 +16,7 @@
from homeassistant.util import Throttle

from . import config_flow # noqa: F401
from .const import CONF_KEY, CONF_UUID, TIMEOUT
from .const import CONF_KEY, CONF_UUID, KEY_MAC, TIMEOUT

_LOGGER = logging.getLogger(__name__)

@@ -61,6 +61,9 @@ async def async_setup(hass, config):
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Establish connection with Daikin."""
conf = entry.data
# For backwards compat, set unique ID
if entry.unique_id is None:
hass.config_entries.async_update_entry(entry, unique_id=conf[KEY_MAC])
daikin_api = await daikin_api_setup(
hass,
conf[CONF_HOST],
@@ -3,5 +3,5 @@
"name": "De Lijn",
"documentation": "https://www.home-assistant.io/integrations/delijn",
"codeowners": ["@bollewolle"],
"requirements": ["pydelijn==0.5.1"]
"requirements": ["pydelijn==0.6.0"]
}
@@ -2,6 +2,7 @@
import logging

from pydelijn.api import Passages
from pydelijn.common import HttpException
import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
@@ -37,61 +38,68 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Create the sensor."""
api_key = config[CONF_API_KEY]
name = DEFAULT_NAME

session = async_get_clientsession(hass)

sensors = []
for nextpassage in config[CONF_NEXT_DEPARTURE]:
stop_id = nextpassage[CONF_STOP_ID]
number_of_departures = nextpassage[CONF_NUMBER_OF_DEPARTURES]
line = Passages(
hass.loop, stop_id, number_of_departures, api_key, session, True
sensors.append(
DeLijnPublicTransportSensor(
Passages(
hass.loop,
nextpassage[CONF_STOP_ID],
nextpassage[CONF_NUMBER_OF_DEPARTURES],
api_key,
session,
True,
)
)
)
await line.get_passages()
if line.passages is None:
_LOGGER.warning("No data received from De Lijn")
return
sensors.append(DeLijnPublicTransportSensor(line, name))

async_add_entities(sensors, True)


class DeLijnPublicTransportSensor(Entity):
"""Representation of a Ruter sensor."""

def __init__(self, line, name):
def __init__(self, line):
"""Initialize the sensor."""
self.line = line
self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
self._name = name
self._name = None
self._state = None
self._available = False
self._available = True

async def async_update(self):
"""Get the latest data from the De Lijn API."""
await self.line.get_passages()
if self.line.passages is None:
_LOGGER.warning("No data received from De Lijn")
try:
await self.line.get_passages()
self._name = await self.line.get_stopname()
except HttpException:
self._available = False
_LOGGER.error("De Lijn http error")
return

self._attributes["stopname"] = self._name
for passage in self.line.passages:
passage["stopname"] = self._name

try:
first = self.line.passages[0]
if first["due_at_realtime"] is not None:
first_passage = first["due_at_realtime"]
else:
first_passage = first["due_at_schedule"]
self._state = first_passage
self._name = first["stopname"]
self._attributes["stopname"] = first["stopname"]
self._attributes["line_number_public"] = first["line_number_public"]
self._attributes["line_transport_type"] = first["line_transport_type"]
self._attributes["final_destination"] = first["final_destination"]
self._attributes["due_at_schedule"] = first["due_at_schedule"]
self._attributes["due_at_realtime"] = first["due_at_realtime"]
self._attributes["next_passages"] = self.line.passages
self._available = True
except (KeyError, IndexError) as error:
_LOGGER.debug("Error getting data from De Lijn: %s", error)
except (KeyError, IndexError):
_LOGGER.error("Invalid data received from De Lijn")
self._available = False

@property
@@ -3,7 +3,7 @@
"name": "forked-daapd",
"documentation": "https://www.home-assistant.io/integrations/forked-daapd",
"codeowners": ["@uvjustin"],
"requirements": ["pyforked-daapd==0.1.8", "pylibrespot-java==0.1.0"],
"requirements": ["pyforked-daapd==0.1.9", "pylibrespot-java==0.1.0"],
"config_flow": true,
"zeroconf": ["_daap._tcp.local."]
}
@@ -794,26 +794,29 @@ async def _update(self, update_types):
"queue" in update_types
): # update queue, queue before player for async_play_media
queue = await self._api.get_request("queue")
update_events["queue"] = asyncio.Event()
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_QUEUE.format(self._entry_id),
queue,
update_events["queue"],
)
if queue:
update_events["queue"] = asyncio.Event()
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_QUEUE.format(self._entry_id),
queue,
update_events["queue"],
)
# order of below don't matter
if not {"outputs", "volume"}.isdisjoint(update_types): # update outputs
outputs = (await self._api.get_request("outputs"))["outputs"]
update_events[
"outputs"
] = asyncio.Event() # only for master, zones should ignore
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_OUTPUTS.format(self._entry_id),
outputs,
update_events["outputs"],
)
self._add_zones(outputs)
outputs = await self._api.get_request("outputs")
if outputs:
outputs = outputs["outputs"]
update_events[
"outputs"
] = asyncio.Event() # only for master, zones should ignore
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_OUTPUTS.format(self._entry_id),
outputs,
update_events["outputs"],
)
self._add_zones(outputs)
if not {"database"}.isdisjoint(update_types):
pipes, playlists = await asyncio.gather(
self._api.get_pipes(), self._api.get_playlists()
@@ -832,17 +835,18 @@ async def _update(self, update_types):
update_types
): # update player
player = await self._api.get_request("player")
update_events["player"] = asyncio.Event()
if update_events.get("queue"):
await update_events[
"queue"
].wait() # make sure queue done before player for async_play_media
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_PLAYER.format(self._entry_id),
player,
update_events["player"],
)
if player:
update_events["player"] = asyncio.Event()
if update_events.get("queue"):
await update_events[
"queue"
].wait() # make sure queue done before player for async_play_media
async_dispatcher_send(
self.hass,
SIGNAL_UPDATE_PLAYER.format(self._entry_id),
player,
update_events["player"],
)
if update_events:
await asyncio.wait(
[event.wait() for event in update_events.values()]
@@ -2,7 +2,7 @@
"domain": "frontend",
"name": "Home Assistant Frontend",
"documentation": "https://www.home-assistant.io/integrations/frontend",
"requirements": ["home-assistant-frontend==20200519.0"],
"requirements": ["home-assistant-frontend==20200519.1"],
"dependencies": [
"api",
"auth",
@@ -627,12 +627,14 @@ async def _async_set_device_info_attributes(self, ent_reg_ent, dev_reg, entity_i
ent_cfg = self._config.setdefault(entity_id, {})
if ent_reg_ent.device_id:
dev_reg_ent = dev_reg.async_get(ent_reg_ent.device_id)
if dev_reg_ent.manufacturer:
ent_cfg[ATTR_MANUFACTURER] = dev_reg_ent.manufacturer
if dev_reg_ent.model:
ent_cfg[ATTR_MODEL] = dev_reg_ent.model
if dev_reg_ent.sw_version:
ent_cfg[ATTR_SOFTWARE_VERSION] = dev_reg_ent.sw_version
if dev_reg_ent is not None:
# Handle missing devices
if dev_reg_ent.manufacturer:
ent_cfg[ATTR_MANUFACTURER] = dev_reg_ent.manufacturer
if dev_reg_ent.model:
ent_cfg[ATTR_MODEL] = dev_reg_ent.model
if dev_reg_ent.sw_version:
ent_cfg[ATTR_SOFTWARE_VERSION] = dev_reg_ent.sw_version
if ATTR_MANUFACTURER not in ent_cfg:
integration = await async_get_integration(self.hass, ent_reg_ent.platform)
ent_cfg[ATTR_INTERGRATION] = integration.name
@@ -111,7 +111,7 @@ def turn_on(self, **kwargs):
):
self._hmdevice.on(self._channel)

if ATTR_HS_COLOR in kwargs:
if ATTR_HS_COLOR in kwargs and self.supported_features & SUPPORT_COLOR:
self._hmdevice.set_hs_color(
hue=kwargs[ATTR_HS_COLOR][0] / 360.0,
saturation=kwargs[ATTR_HS_COLOR][1] / 100.0,
@@ -31,9 +31,15 @@
DEVICE_REVISION,
DEVICE_SERIAL_NUMBER,
DOMAIN,
FIRMWARE_BUILD,
FIRMWARE_IN_USERDATA,
FIRMWARE_SUB_REVISION,
HUB_EXCEPTIONS,
HUB_NAME,
LEGACY_DEVICE_BUILD,
LEGACY_DEVICE_MODEL,
LEGACY_DEVICE_REVISION,
LEGACY_DEVICE_SUB_REVISION,
MAC_ADDRESS_IN_USERDATA,
MAINPROCESSOR_IN_USERDATA_FIRMWARE,
MODEL_IN_MAINPROCESSOR,
@@ -159,9 +165,19 @@ async def async_get_device_info(pv_request):
resources = await userdata.get_resources()
userdata_data = resources[USER_DATA]

main_processor_info = userdata_data[FIRMWARE_IN_USERDATA][
MAINPROCESSOR_IN_USERDATA_FIRMWARE
]
if FIRMWARE_IN_USERDATA in userdata_data:
main_processor_info = userdata_data[FIRMWARE_IN_USERDATA][
MAINPROCESSOR_IN_USERDATA_FIRMWARE
]
else:
# Legacy devices
main_processor_info = {
REVISION_IN_MAINPROCESSOR: LEGACY_DEVICE_REVISION,
FIRMWARE_SUB_REVISION: LEGACY_DEVICE_SUB_REVISION,
FIRMWARE_BUILD: LEGACY_DEVICE_BUILD,
MODEL_IN_MAINPROCESSOR: LEGACY_DEVICE_MODEL,
}

return {
DEVICE_NAME: base64_to_unicode(userdata_data[HUB_NAME]),
DEVICE_MAC_ADDRESS: userdata_data[MAC_ADDRESS_IN_USERDATA],
@@ -65,3 +65,8 @@
COORDINATOR = "coordinator"

HUB_EXCEPTIONS = (asyncio.TimeoutError, PvApiConnectionError)

LEGACY_DEVICE_SUB_REVISION = 1
LEGACY_DEVICE_REVISION = 0
LEGACY_DEVICE_BUILD = 0
LEGACY_DEVICE_MODEL = "PV Hub1.0"
@@ -3,6 +3,5 @@
"name": "Logbook",
"documentation": "https://www.home-assistant.io/integrations/logbook",
"dependencies": ["frontend", "http", "recorder"],
"after_dependencies": ["homekit"],
"codeowners": []
}
@@ -106,23 +106,13 @@ def entity_registry_enabled_default(self) -> bool:

async def stream_source(self):
"""Return the stream source."""
if self._stream_uri is None:
uri_no_auth = await self.device.async_get_stream_uri(self.profile)
self._stream_uri = uri_no_auth.replace(
"rtsp://", f"rtsp://{self.device.username}:{self.device.password}@", 1
)
return self._stream_uri

async def async_camera_image(self):
"""Return a still image response from the camera."""
image = None

if self.device.capabilities.snapshot:
if self._snapshot_uri is None:
self._snapshot_uri = await self.device.async_get_snapshot_uri(
self.profile
)

auth = None
if self.device.username and self.device.password:
auth = HTTPDigestAuth(self.device.username, self.device.password)
@@ -181,6 +171,16 @@ async def handle_async_mjpeg_stream(self, request):
finally:
await stream.close()

async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
uri_no_auth = await self.device.async_get_stream_uri(self.profile)
self._stream_uri = uri_no_auth.replace(
"rtsp://", f"rtsp://{self.device.username}:{self.device.password}@", 1
)

if self.device.capabilities.snapshot:
self._snapshot_uri = await self.device.async_get_snapshot_uri(self.profile)

async def async_perform_ptz(
self,
distance,
@@ -223,15 +223,15 @@ async def async_get_capabilities(self):
try:
media_service = self.device.create_media_service()
media_capabilities = await media_service.GetServiceCapabilities()
snapshot = media_capabilities.SnapshotUri
snapshot = media_capabilities and media_capabilities.SnapshotUri
except (ONVIFError, Fault):
pass

pullpoint = False
try:
event_service = self.device.create_events_service()
event_capabilities = await event_service.GetServiceCapabilities()
pullpoint = event_capabilities.WSPullPointSupport
pullpoint = event_capabilities and event_capabilities.WSPullPointSupport
except (ONVIFError, Fault):
pass

@@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 110
PATCH_VERSION = "0"
PATCH_VERSION = "1"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 7, 0)
@@ -200,14 +200,19 @@ async def _async_callback_final_write(self, _event):

async def _async_handle_write_data(self, *_args):
"""Handle writing the config."""
data = self._data

if "data_func" in data:
data["data"] = data.pop("data_func")()
async with self._write_lock:
if self._data is None:
# Another write already consumed the data
return

self._data = None
data = self._data

if "data_func" in data:
data["data"] = data.pop("data_func")()

self._data = None

async with self._write_lock:
try:
await self.hass.async_add_executor_job(
self._write_data, self.path, data

0 comments on commit 7c784b6

Please sign in to comment.
You can’t perform that action at this time.