Skip to content

Commit

Permalink
Revert "Bugfix camera streams (home-assistant#5306)"
Browse files Browse the repository at this point in the history
This reverts commit 4b43537.

Revert "Version bump for kodi dependency (home-assistant#5307)"

This reverts commit 6abad6b.

Revert "Add HMWIOSwitch to sensor, binary (home-assistant#5304)"

This reverts commit 2c3f55a.

Revert "Remove GTFS default name & string change"

This reverts commit 6000c59.

Revert "Update pyhomematic 1.19 & small cleanups (home-assistant#5299)"

This reverts commit a30711f.

Revert "[sensor] Add Dublin bus RTPI sensor (home-assistant#5257)"

This reverts commit 1219ca3.

Revert "Bugfix group reload (home-assistant#5292)"

This reverts commit baa8e53.

Revert "Support for TrackR device trackers (home-assistant#5010)"

This reverts commit f7a1d63.

Revert "Bump pywemo version."

This reverts commit dc937cc.

Revert "Upgrade to voluptuous to 0.9.3 (home-assistant#5288)"

This reverts commit d12decc.

Revert "Upgrade distro to 1.0.2 (home-assistant#5291)"

This reverts commit 64800fd.

Revert "Don't build Adafruit_BBIO - doesn't work on all platforms. (home-assistant#5281)"

This reverts commit 9a3c0c8.

Revert "Convert flic to synchronous platform. (home-assistant#5276)"

This reverts commit eb9b95c.

Revert "Upgrade to aiohttp 1.2 (home-assistant#4964)"

This reverts commit e68e29e.

Revert "Fix TCP sensor to correctly use value_template (home-assistant#5211)"

This reverts commit 1cf9ae5.

Revert "Cleanup language support on TTS (home-assistant#5255)"

This reverts commit 3f3a3bc.

Revert "Add last triggered to script (home-assistant#5261)"

This reverts commit 467cb18.

Revert "Bump flux_led version and make use of PyPi package (home-assistant#5267)"

This reverts commit 34a9fb0.

Revert "Add support for NAD receivers (home-assistant#5191)"

This reverts commit 3b59e16.

Revert "Bugfix async device_tracker see callback (home-assistant#5259)"

This reverts commit 71fddd2.

Revert "Use SHA hash to make token harder to guess (home-assistant#5258)"

This reverts commit 922308b.
  • Loading branch information
nordlead2005 committed Jan 14, 2017
1 parent a33f049 commit 2ee8c44
Show file tree
Hide file tree
Showing 36 changed files with 534 additions and 1,109 deletions.
3 changes: 0 additions & 3 deletions .coveragerc
Expand Up @@ -169,7 +169,6 @@ omit =
homeassistant/components/device_tracker/thomson.py
homeassistant/components/device_tracker/tomato.py
homeassistant/components/device_tracker/tplink.py
homeassistant/components/device_tracker/trackr.py
homeassistant/components/device_tracker/ubus.py
homeassistant/components/device_tracker/volvooncall.py
homeassistant/components/discovery.py
Expand Down Expand Up @@ -211,7 +210,6 @@ omit =
homeassistant/components/media_player/lg_netcast.py
homeassistant/components/media_player/mpchc.py
homeassistant/components/media_player/mpd.py
homeassistant/components/media_player/nad.py
homeassistant/components/media_player/onkyo.py
homeassistant/components/media_player/panasonic_viera.py
homeassistant/components/media_player/pandora.py
Expand Down Expand Up @@ -266,7 +264,6 @@ omit =
homeassistant/components/sensor/bitcoin.py
homeassistant/components/sensor/bom.py
homeassistant/components/sensor/broadlink.py
homeassistant/components/sensor/dublin_bus_transport.py
homeassistant/components/sensor/coinmarketcap.py
homeassistant/components/sensor/cpuspeed.py
homeassistant/components/sensor/cups.py
Expand Down
13 changes: 2 additions & 11 deletions homeassistant/components/bbb_gpio.py
Expand Up @@ -19,7 +19,6 @@
# pylint: disable=no-member
def setup(hass, config):
"""Setup the Beaglebone black GPIO component."""
# pylint: disable=import-error
import Adafruit_BBIO.GPIO as GPIO

def cleanup_gpio(event):
Expand All @@ -34,41 +33,33 @@ def prepare_gpio(event):
return True


# noqa: F821

def setup_output(pin):
"""Setup a GPIO as output."""
# pylint: disable=import-error,undefined-variable
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup(pin, GPIO.OUT)


def setup_input(pin, pull_mode):
"""Setup a GPIO as input."""
# pylint: disable=import-error,undefined-variable
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup(pin, GPIO.IN, # noqa: F821
GPIO.PUD_DOWN if pull_mode == 'DOWN' # noqa: F821
else GPIO.PUD_UP) # noqa: F821
GPIO.setup(pin, GPIO.IN,
GPIO.PUD_DOWN if pull_mode == 'DOWN' else GPIO.PUD_UP)


def write_output(pin, value):
"""Write a value to a GPIO."""
# pylint: disable=import-error,undefined-variable
import Adafruit_BBIO.GPIO as GPIO
GPIO.output(pin, value)


def read_input(pin):
"""Read a value from a GPIO."""
# pylint: disable=import-error,undefined-variable
import Adafruit_BBIO.GPIO as GPIO
return GPIO.input(pin)


def edge_detect(pin, event_callback, bounce):
"""Add detection for RISING and FALLING events."""
# pylint: disable=import-error,undefined-variable
import Adafruit_BBIO.GPIO as GPIO
GPIO.add_event_detect(
pin,
Expand Down
56 changes: 36 additions & 20 deletions homeassistant/components/binary_sensor/flic.py
@@ -1,6 +1,6 @@
"""Contains functionality to use flic buttons as a binary sensor."""
import asyncio
import logging
import threading

import voluptuous as vol

Expand All @@ -10,6 +10,7 @@
EVENT_HOMEASSISTANT_STOP)
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA)
from homeassistant.util.async import run_callback_threadsafe


REQUIREMENTS = ['https://github.com/soldag/pyflic/archive/0.4.zip#pyflic==0.4']
Expand Down Expand Up @@ -42,7 +43,9 @@
})


def setup_platform(hass, config, add_entities, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Setup the flic platform."""
import pyflic

Expand All @@ -60,29 +63,26 @@ def setup_platform(hass, config, add_entities, discovery_info=None):

def new_button_callback(address):
"""Setup newly verified button as device in home assistant."""
setup_button(hass, config, add_entities, client, address)
hass.add_job(async_setup_button(hass, config, async_add_entities,
client, address))

client.on_new_verified_button = new_button_callback
if discovery:
start_scanning(config, add_entities, client)
start_scanning(hass, config, async_add_entities, client)

hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP,
lambda event: client.close())

# Start the pyflic event handling thread
threading.Thread(target=client.handle_events).start()

def get_info_callback(items):
"""Add entities for already verified buttons."""
addresses = items["bd_addr_of_verified_buttons"] or []
for address in addresses:
setup_button(hass, config, add_entities, client, address)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP,
lambda event: client.close())
hass.loop.run_in_executor(None, client.handle_events)

# Get addresses of already verified buttons
client.get_info(get_info_callback)
addresses = yield from async_get_verified_addresses(client)
if addresses:
for address in addresses:
yield from async_setup_button(hass, config, async_add_entities,
client, address)


def start_scanning(config, add_entities, client):
def start_scanning(hass, config, async_add_entities, client):
"""Start a new flic client for scanning & connceting to new buttons."""
import pyflic

Expand All @@ -97,20 +97,36 @@ def scan_completed_callback(scan_wizard, result, address, name):
address, result)

# Restart scan wizard
start_scanning(config, add_entities, client)
start_scanning(hass, config, async_add_entities, client)

scan_wizard.on_completed = scan_completed_callback
client.add_scan_wizard(scan_wizard)


def setup_button(hass, config, add_entities, client, address):
@asyncio.coroutine
def async_setup_button(hass, config, async_add_entities, client, address):
"""Setup single button device."""
timeout = config.get(CONF_TIMEOUT)
ignored_click_types = config.get(CONF_IGNORED_CLICK_TYPES)
button = FlicButton(hass, client, address, timeout, ignored_click_types)
_LOGGER.info("Connected to button (%s)", address)

add_entities([button])
yield from async_add_entities([button])


@asyncio.coroutine
def async_get_verified_addresses(client):
"""Retrieve addresses of verified buttons."""
future = asyncio.Future()
loop = asyncio.get_event_loop()

def get_info_callback(items):
"""Set the addressed of connected buttons as result of the future."""
addresses = items["bd_addr_of_verified_buttons"]
run_callback_threadsafe(loop, future.set_result, addresses)
client.get_info(get_info_callback)

return future


class FlicButton(BinarySensorDevice):
Expand Down
5 changes: 1 addition & 4 deletions homeassistant/components/camera/__init__.py
Expand Up @@ -8,7 +8,6 @@
import asyncio
from datetime import timedelta
import logging
import hashlib

from aiohttp import web

Expand Down Expand Up @@ -48,13 +47,11 @@ class Camera(Entity):
def __init__(self):
"""Initialize a camera."""
self.is_streaming = False
self._access_token = hashlib.sha256(
str.encode(str(id(self)))).hexdigest()

@property
def access_token(self):
"""Access token for this camera."""
return self._access_token
return str(id(self))

@property
def should_poll(self):
Expand Down
10 changes: 2 additions & 8 deletions homeassistant/components/camera/ffmpeg.py
Expand Up @@ -84,15 +84,9 @@ def handle_async_mjpeg_stream(self, request):
if not data:
break
response.write(data)

except asyncio.CancelledError:
_LOGGER.debug("Close stream by browser.")
response = None

finally:
yield from stream.close()
if response is not None:
yield from response.write_eof()
self.hass.async_add_job(stream.close())
yield from response.write_eof()

@property
def name(self):
Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/camera/mjpeg.py
Expand Up @@ -124,13 +124,9 @@ def handle_async_mjpeg_stream(self, request):
except asyncio.TimeoutError:
raise HTTPGatewayTimeout()

except asyncio.CancelledError:
_LOGGER.debug("Close stream by browser.")
response = None

finally:
if stream is not None:
stream.close()
yield from stream.close()
if response is not None:
yield from response.write_eof()

Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/camera/synology.py
Expand Up @@ -276,13 +276,9 @@ def handle_async_mjpeg_stream(self, request):
_LOGGER.exception("Error on %s", streaming_url)
raise HTTPGatewayTimeout()

except asyncio.CancelledError:
_LOGGER.debug("Close stream by browser.")
response = None

finally:
if stream is not None:
stream.close()
self.hass.async_add_job(stream.release())
if response is not None:
yield from response.write_eof()

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/device_tracker/__init__.py
Expand Up @@ -158,7 +158,7 @@ def async_setup_platform(p_type, p_config, disc_info=None):
None, platform.get_scanner, hass, {DOMAIN: p_config})
elif hasattr(platform, 'async_setup_scanner'):
setup = yield from platform.async_setup_scanner(
hass, p_config, tracker.async_see)
hass, p_config, tracker.see)
elif hasattr(platform, 'setup_scanner'):
setup = yield from hass.loop.run_in_executor(
None, platform.setup_scanner, hass, p_config, tracker.see)
Expand Down
79 changes: 0 additions & 79 deletions homeassistant/components/device_tracker/trackr.py

This file was deleted.

2 changes: 1 addition & 1 deletion homeassistant/components/emulated_hue/hue_api.py
Expand Up @@ -91,7 +91,7 @@ def __init__(self, config):
self.config = config

@core.callback
def get(self, request, username, entity_id):
def get(self, request, username, entity_id=None):
"""Process a request to get the state of an individual light."""
hass = request.app['hass']
entity_id = self.config.number_to_entity_id(entity_id)
Expand Down

0 comments on commit 2ee8c44

Please sign in to comment.