This commit is contained in:
MakeMeASandwich 2015-09-09 19:37:48 +02:00
commit 34a6524019
85 changed files with 644 additions and 412 deletions

View File

@ -4,8 +4,6 @@ source = homeassistant
omit = omit =
homeassistant/__main__.py homeassistant/__main__.py
homeassistant/external/*
# omit pieces of code that rely on external devices being present # omit pieces of code that rely on external devices being present
homeassistant/components/arduino.py homeassistant/components/arduino.py
homeassistant/components/*/arduino.py homeassistant/components/*/arduino.py

9
.gitmodules vendored
View File

@ -1,12 +1,3 @@
[submodule "homeassistant/external/noop"]
path = homeassistant/external/noop
url = https://github.com/balloob/noop.git
[submodule "homeassistant/external/vera"]
path = homeassistant/external/vera
url = https://github.com/jamespcole/home-assistant-vera-api.git
[submodule "homeassistant/external/nzbclients"]
path = homeassistant/external/nzbclients
url = https://github.com/jamespcole/home-assistant-nzb-clients.git
[submodule "homeassistant/components/frontend/www_static/home-assistant-polymer"] [submodule "homeassistant/components/frontend/www_static/home-assistant-polymer"]
path = homeassistant/components/frontend/www_static/home-assistant-polymer path = homeassistant/components/frontend/www_static/home-assistant-polymer
url = https://github.com/balloob/home-assistant-polymer.git url = https://github.com/balloob/home-assistant-polymer.git

View File

@ -6,7 +6,7 @@ install:
- pip install -r requirements_all.txt - pip install -r requirements_all.txt
- pip install flake8 pylint coveralls - pip install flake8 pylint coveralls
script: script:
- flake8 homeassistant --exclude bower_components,external - flake8 homeassistant
- pylint homeassistant - pylint homeassistant
- coverage run -m unittest discover tests - coverage run -m unittest discover tests
after_success: after_success:

View File

@ -12,7 +12,7 @@ Example component to target an entity_id to:
Configuration: Configuration:
To use the Example custom component you will need to add the following to To use the Example custom component you will need to add the following to
your config/configuration.yaml your configuration.yaml file.
example: example:
target: TARGET_ENTITY target: TARGET_ENTITY

View File

@ -1,16 +1,14 @@
""" """
custom_components.hello_world custom_components.hello_world
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Implements the bare minimum that a component should implement. Implements the bare minimum that a component should implement.
Configuration: Configuration:
To use the hello_word component you will need to add the following to your To use the hello_word component you will need to add the following to your
config/configuration.yaml configuration.yaml file.
hello_world: hello_world:
""" """
# The domain of your component. Should be equal to the name of your component # The domain of your component. Should be equal to the name of your component

View File

@ -1,7 +1,6 @@
""" """
custom_components.mqtt_example custom_components.mqtt_example
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows how to communicate with MQTT. Follows a topic on MQTT and updates the Shows how to communicate with MQTT. Follows a topic on MQTT and updates the
state of an entity to the last message received on that topic. state of an entity to the last message received on that topic.
@ -12,7 +11,7 @@ example payload {"new_state": "some new state"}.
Configuration: Configuration:
To use the mqtt_example component you will need to add the following to your To use the mqtt_example component you will need to add the following to your
config/configuration.yaml configuration.yaml file.
mqtt_example: mqtt_example:
topic: home-assistant/mqtt_example topic: home-assistant/mqtt_example

View File

@ -7,7 +7,7 @@ runs with the Firmata firmware.
Configuration: Configuration:
To use the Arduino board you will need to add something like the following To use the Arduino board you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
arduino: arduino:
port: /dev/ttyACM0 port: /dev/ttyACM0

View File

@ -1,4 +1,6 @@
""" """
homeassistant.components.camera.generic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for IP Cameras. Support for IP Cameras.
This component provides basic support for IP cameras. For the basic support to This component provides basic support for IP cameras. For the basic support to
@ -7,11 +9,11 @@ need to specify the "still_image_url" parameter which should be the location of
the JPEG image. the JPEG image.
As part of the basic support the following features will be provided: As part of the basic support the following features will be provided:
-MJPEG video streaming - MJPEG video streaming
-Saving a snapshot - Saving a snapshot
-Recording(JPEG frame capture) - Recording(JPEG frame capture)
To use this component, add the following to your config/configuration.yaml: To use this component, add the following to your configuration.yaml file.
camera: camera:
platform: generic platform: generic
@ -20,29 +22,24 @@ camera:
password: YOUR_PASSWORD password: YOUR_PASSWORD
still_image_url: http://YOUR_CAMERA_IP_AND_PORT/image.jpg still_image_url: http://YOUR_CAMERA_IP_AND_PORT/image.jpg
Variables:
VARIABLES:
These are the variables for the device_data array:
still_image_url still_image_url
*Required *Required
The URL your camera serves the image on. The URL your camera serves the image on, eg. http://192.168.1.21:2112/
Example: http://192.168.1.21:2112/
name name
*Optional *Optional
This parameter allows you to override the name of your camera in homeassistant This parameter allows you to override the name of your camera in Home
Assistant.
username username
*Optional *Optional
THe username for acessing your camera The username for accessing your camera.
password password
*Optional *Optional
the password for accessing your camera The password for accessing your camera.
""" """
import logging import logging
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
@ -78,7 +75,7 @@ class GenericCamera(Camera):
self._still_image_url = device_info['still_image_url'] self._still_image_url = device_info['still_image_url']
def camera_image(self): def camera_image(self):
""" Return a still image reponse from the camera """ """ Return a still image reponse from the camera. """
if self._username and self._password: if self._username and self._password:
response = requests.get( response = requests.get(
self._still_image_url, self._still_image_url,
@ -90,5 +87,5 @@ class GenericCamera(Camera):
@property @property
def name(self): def name(self):
""" Return the name of this device """ """ Return the name of this device. """
return self._name return self._name

View File

@ -1,6 +1,6 @@
""" """
homeassistant.components.device_tracker.actiontec homeassistant.components.device_tracker.actiontec
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning an Actiontec MI424WR Device tracker platform that supports scanning an Actiontec MI424WR
(Verizon FIOS) router for device presence. (Verizon FIOS) router for device presence.
@ -9,10 +9,9 @@ This device tracker needs telnet to be enabled on the router.
Configuration: Configuration:
To use the Actiontec tracker you will need to add something like the To use the Actiontec tracker you will need to add something like the
following to your config/configuration.yaml. If you experience disconnects following to your configuration.yaml file. If you experience disconnects
you can modify the home_interval variable. you can modify the home_interval variable.
device_tracker: device_tracker:
platform: actiontec platform: actiontec
host: YOUR_ROUTER_IP host: YOUR_ROUTER_IP
@ -69,7 +68,7 @@ _LEASES_REGEX = re.compile(
# pylint: disable=unused-argument # pylint: disable=unused-argument
def get_scanner(hass, config): def get_scanner(hass, config):
""" Validates config and returns a DD-WRT scanner. """ """ Validates config and returns an Actiontec scanner. """
if not validate_config(config, if not validate_config(config,
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]}, {DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
_LOGGER): _LOGGER):
@ -83,8 +82,9 @@ Device = namedtuple("Device", ["mac", "ip", "last_update"])
class ActiontecDeviceScanner(object): class ActiontecDeviceScanner(object):
""" This class queries a an actiontec router """
for connected devices. Adapted from DD-WRT scanner. This class queries a an actiontec router for connected devices.
Adapted from DD-WRT scanner.
""" """
def __init__(self, config): def __init__(self, config):
@ -106,8 +106,9 @@ class ActiontecDeviceScanner(object):
_LOGGER.info("home_interval set to: %s", self.home_interval) _LOGGER.info("home_interval set to: %s", self.home_interval)
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
return [client.mac for client in self.last_results] return [client.mac for client in self.last_results]
@ -123,8 +124,10 @@ class ActiontecDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the Actiontec MI424WR router is up """
to date. Returns boolean if scanning successful. """ Ensures the information from the Actiontec MI424WR router is up
to date. Returns boolean if scanning successful.
"""
_LOGGER.info("Scanning") _LOGGER.info("Scanning")
if not self.success_init: if not self.success_init:
return False return False
@ -155,7 +158,7 @@ class ActiontecDeviceScanner(object):
return True return True
def get_actiontec_data(self): def get_actiontec_data(self):
""" Retrieve data from Actiontec MI424WR and return parsed result. """ """ Retrieve data from Actiontec MI424WR and return parsed result. """
try: try:
telnet = telnetlib.Telnet(self.host) telnet = telnetlib.Telnet(self.host)
telnet.read_until(b'Username: ') telnet.read_until(b'Username: ')

View File

@ -9,8 +9,8 @@ This device tracker needs telnet to be enabled on the router.
Configuration: Configuration:
To use the Aruba tracker you will need to add something like the following To use the Aruba tracker you will need to add something like the following
to your config/configuration.yaml. You also need to enable Telnet in the to your configuration.yaml file. You also need to enable Telnet in the
configuration pages. configuration page of your router.
device_tracker: device_tracker:
platform: aruba platform: aruba
@ -83,8 +83,9 @@ class ArubaDeviceScanner(object):
self.success_init = data is not None self.success_init = data is not None
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a list containing found device """
ids. """ Scans for new devices and return a list containing found device IDs.
"""
self._update_info() self._update_info()
return [client['mac'] for client in self.last_results] return [client['mac'] for client in self.last_results]
@ -100,8 +101,10 @@ class ArubaDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the Aruba Access Point is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the Aruba Access Point is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return False return False
@ -114,8 +117,7 @@ class ArubaDeviceScanner(object):
return True return True
def get_aruba_data(self): def get_aruba_data(self):
""" Retrieve data from Aruba Access Point and return parsed """ Retrieve data from Aruba Access Point and return parsed result. """
result. """
try: try:
telnet = telnetlib.Telnet(self.host) telnet = telnetlib.Telnet(self.host)
telnet.read_until(b'User: ') telnet.read_until(b'User: ')

View File

@ -9,7 +9,7 @@ This device tracker needs telnet to be enabled on the router.
Configuration: Configuration:
To use the ASUSWRT tracker you will need to add something like the following To use the ASUSWRT tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: asuswrt platform: asuswrt
@ -63,7 +63,7 @@ _IP_NEIGH_REGEX = re.compile(
# pylint: disable=unused-argument # pylint: disable=unused-argument
def get_scanner(hass, config): def get_scanner(hass, config):
""" Validates config and returns a DD-WRT scanner. """ """ Validates config and returns an ASUS-WRT scanner. """
if not validate_config(config, if not validate_config(config,
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]}, {DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
_LOGGER): _LOGGER):
@ -75,7 +75,8 @@ def get_scanner(hass, config):
class AsusWrtDeviceScanner(object): class AsusWrtDeviceScanner(object):
""" This class queries a router running ASUSWRT firmware """
This class queries a router running ASUSWRT firmware
for connected devices. Adapted from DD-WRT scanner. for connected devices. Adapted from DD-WRT scanner.
""" """
@ -93,8 +94,9 @@ class AsusWrtDeviceScanner(object):
self.success_init = data is not None self.success_init = data is not None
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device IDs.
"""
self._update_info() self._update_info()
return [client['mac'] for client in self.last_results] return [client['mac'] for client in self.last_results]
@ -110,8 +112,10 @@ class AsusWrtDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the ASUSWRT router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the ASUSWRT router is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return False return False
@ -129,7 +133,7 @@ class AsusWrtDeviceScanner(object):
return True return True
def get_asuswrt_data(self): def get_asuswrt_data(self):
""" Retrieve data from ASUSWRT and return parsed result. """ """ Retrieve data from ASUSWRT and return parsed result. """
try: try:
telnet = telnetlib.Telnet(self.host) telnet = telnetlib.Telnet(self.host)
telnet.read_until(b'login: ') telnet.read_until(b'login: ')

View File

@ -1,14 +1,13 @@
""" """
homeassistant.components.device_tracker.ddwrt homeassistant.components.device_tracker.ddwrt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a DD-WRT router for device Device tracker platform that supports scanning a DD-WRT router for device
presence. presence.
Configuration: Configuration:
To use the DD-WRT tracker you will need to add something like the following To use the DD-WRT tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: ddwrt platform: ddwrt
@ -64,7 +63,8 @@ def get_scanner(hass, config):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class DdWrtDeviceScanner(object): class DdWrtDeviceScanner(object):
""" This class queries a wireless router running DD-WRT firmware """
This class queries a wireless router running DD-WRT firmware
for connected devices. Adapted from Tomato scanner. for connected devices. Adapted from Tomato scanner.
""" """
@ -85,8 +85,9 @@ class DdWrtDeviceScanner(object):
self.success_init = data is not None self.success_init = data is not None
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
@ -124,8 +125,10 @@ class DdWrtDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the DD-WRT router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the DD-WRT router is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return False return False
@ -163,7 +166,7 @@ class DdWrtDeviceScanner(object):
return False return False
def get_ddwrt_data(self, url): def get_ddwrt_data(self, url):
""" Retrieve data from DD-WRT and return parsed result. """ """ Retrieve data from DD-WRT and return parsed result. """
try: try:
response = requests.get( response = requests.get(
url, url,

View File

@ -1,18 +1,16 @@
""" """
homeassistant.components.device_tracker.luci homeassistant.components.device_tracker.luci
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a OpenWRT router for device Device tracker platform that supports scanning a OpenWRT router for device
presence. presence.
It's required that the luci RPC package is installed on the OpenWRT router: It's required that the luci RPC package is installed on the OpenWRT router:
# opkg install luci-mod-rpc # opkg install luci-mod-rpc
Configuration: Configuration:
To use the Luci tracker you will need to add something like the following To use the Luci tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: luci platform: luci
@ -66,7 +64,8 @@ def get_scanner(hass, config):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class LuciDeviceScanner(object): class LuciDeviceScanner(object):
""" This class queries a wireless router running OpenWrt firmware """
This class queries a wireless router running OpenWrt firmware
for connected devices. Adapted from Tomato scanner. for connected devices. Adapted from Tomato scanner.
# opkg install luci-mod-rpc # opkg install luci-mod-rpc
@ -95,8 +94,9 @@ class LuciDeviceScanner(object):
self.success_init = self.token is not None self.success_init = self.token is not None
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
@ -124,8 +124,10 @@ class LuciDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the Luci router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the Luci router is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return False return False
@ -179,6 +181,6 @@ def _req_json_rpc(url, method, *args, **kwargs):
def _get_token(host, username, password): def _get_token(host, username, password):
""" Get authentication token for the given host+username+password """ """ Get authentication token for the given host+username+password. """
url = 'http://{}/cgi-bin/luci/rpc/auth'.format(host) url = 'http://{}/cgi-bin/luci/rpc/auth'.format(host)
return _req_json_rpc(url, 'login', username, password) return _req_json_rpc(url, 'login', username, password)

View File

@ -1,14 +1,13 @@
""" """
homeassistant.components.device_tracker.netgear homeassistant.components.device_tracker.netgear
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a Netgear router for device Device tracker platform that supports scanning a Netgear router for device
presence. presence.
Configuration: Configuration:
To use the Netgear tracker you will need to add something like the following To use the Netgear tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: netgear platform: netgear
@ -90,8 +89,9 @@ class NetgearDeviceScanner(object):
_LOGGER.error("Failed to Login") _LOGGER.error("Failed to Login")
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
return (device.mac for device in self.last_results) return (device.mac for device in self.last_results)
@ -106,8 +106,10 @@ class NetgearDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Retrieves latest information from the Netgear router. """
Returns boolean if scanning successful. """ Retrieves latest information from the Netgear router.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return return

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.device_tracker.nmap homeassistant.components.device_tracker.nmap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a network with nmap. Device tracker platform that supports scanning a network with nmap.
Configuration: Configuration:
To use the nmap tracker you will need to add something like the following To use the nmap tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: nmap_tracker platform: nmap_tracker
@ -74,7 +73,7 @@ def _arp(ip_address):
class NmapDeviceScanner(object): class NmapDeviceScanner(object):
""" This class scans for devices using nmap """ """ This class scans for devices using nmap. """
def __init__(self, config): def __init__(self, config):
self.last_results = [] self.last_results = []
@ -87,8 +86,9 @@ class NmapDeviceScanner(object):
_LOGGER.info("nmap scanner initialized") _LOGGER.info("nmap scanner initialized")
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
@ -107,8 +107,10 @@ class NmapDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Scans the network for devices. """
Returns boolean if scanning successful. """ Scans the network for devices.
Returns boolean if scanning successful.
"""
_LOGGER.info("Scanning") _LOGGER.info("Scanning")
from nmap import PortScanner, PortScannerError from nmap import PortScanner, PortScannerError

View File

@ -9,7 +9,7 @@ This device tracker needs telnet to be enabled on the router.
Configuration: Configuration:
To use the THOMSON tracker you will need to add something like the following To use the THOMSON tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: thomson platform: thomson
@ -71,7 +71,8 @@ def get_scanner(hass, config):
class ThomsonDeviceScanner(object): class ThomsonDeviceScanner(object):
""" This class queries a router running THOMSON firmware """
This class queries a router running THOMSON firmware
for connected devices. Adapted from ASUSWRT scanner. for connected devices. Adapted from ASUSWRT scanner.
""" """
@ -107,8 +108,10 @@ class ThomsonDeviceScanner(object):
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the THOMSON router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the THOMSON router is up to date.
Returns boolean if scanning successful.
"""
if not self.success_init: if not self.success_init:
return False return False
@ -125,7 +128,7 @@ class ThomsonDeviceScanner(object):
return True return True
def get_thomson_data(self): def get_thomson_data(self):
""" Retrieve data from THOMSON and return parsed result. """ """ Retrieve data from THOMSON and return parsed result. """
try: try:
telnet = telnetlib.Telnet(self.host) telnet = telnetlib.Telnet(self.host)
telnet.read_until(b'Username : ') telnet.read_until(b'Username : ')

View File

@ -1,14 +1,13 @@
""" """
homeassistant.components.device_tracker.tomato homeassistant.components.device_tracker.tomato
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a Tomato router for device Device tracker platform that supports scanning a Tomato router for device
presence. presence.
Configuration: Configuration:
To use the Tomato tracker you will need to add something like the following To use the Tomato tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: tomato platform: tomato

View File

@ -1,14 +1,13 @@
""" """
homeassistant.components.device_tracker.tplink homeassistant.components.device_tracker.tplink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Device tracker platform that supports scanning a TP-Link router for device Device tracker platform that supports scanning a TP-Link router for device
presence. presence.
Configuration: Configuration:
To use the TP-Link tracker you will need to add something like the following To use the TP-Link tracker you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
device_tracker: device_tracker:
platform: tplink platform: tplink
@ -29,7 +28,6 @@ The username of an user with administrative privileges, usually 'admin'.
password password
*Required *Required
The password for your given admin account. The password for your given admin account.
""" """
import base64 import base64
import logging import logging
@ -65,7 +63,8 @@ def get_scanner(hass, config):
class TplinkDeviceScanner(object): class TplinkDeviceScanner(object):
""" This class queries a wireless router running TP-Link firmware """
This class queries a wireless router running TP-Link firmware
for connected devices. for connected devices.
""" """
@ -85,8 +84,9 @@ class TplinkDeviceScanner(object):
self.success_init = self._update_info() self.success_init = self._update_info()
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
@ -94,15 +94,18 @@ class TplinkDeviceScanner(object):
# pylint: disable=no-self-use # pylint: disable=no-self-use
def get_device_name(self, device): def get_device_name(self, device):
""" The TP-Link firmware doesn't save the name of the wireless """
device. """ The TP-Link firmware doesn't save the name of the wireless device.
"""
return None return None
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the TP-Link router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the TP-Link router is up to date.
Returns boolean if scanning successful.
"""
with self.lock: with self.lock:
_LOGGER.info("Loading wireless clients...") _LOGGER.info("Loading wireless clients...")
@ -122,28 +125,33 @@ class TplinkDeviceScanner(object):
class Tplink2DeviceScanner(TplinkDeviceScanner): class Tplink2DeviceScanner(TplinkDeviceScanner):
""" This class queries a wireless router running newer version of TP-Link """
This class queries a wireless router running newer version of TP-Link
firmware for connected devices. firmware for connected devices.
""" """
def scan_devices(self): def scan_devices(self):
""" Scans for new devices and return a """
list containing found device ids. """ Scans for new devices and return a list containing found device ids.
"""
self._update_info() self._update_info()
return self.last_results.keys() return self.last_results.keys()
# pylint: disable=no-self-use # pylint: disable=no-self-use
def get_device_name(self, device): def get_device_name(self, device):
""" The TP-Link firmware doesn't save the name of the wireless """
device. """ The TP-Link firmware doesn't save the name of the wireless device.
"""
return self.last_results.get(device) return self.last_results.get(device)
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)
def _update_info(self): def _update_info(self):
""" Ensures the information from the TP-Link router is up to date. """
Returns boolean if scanning successful. """ Ensures the information from the TP-Link router is up to date.
Returns boolean if scanning successful.
"""
with self.lock: with self.lock:
_LOGGER.info("Loading wireless clients...") _LOGGER.info("Loading wireless clients...")

View File

@ -15,7 +15,7 @@ Support for LimitlessLED bulbs, also known as...
Configuration: Configuration:
To use limitlessled you will need to add the following to your To use limitlessled you will need to add the following to your
config/configuration.yaml. configuration.yaml file.
light: light:
platform: limitlessled platform: limitlessled
@ -24,7 +24,6 @@ light:
group_2_name: Bedroom group_2_name: Bedroom
group_3_name: Office group_3_name: Office
group_4_name: Kitchen group_4_name: Kitchen
""" """
import logging import logging
@ -107,7 +106,7 @@ class LimitlessLED(Light):
return self._xy_color return self._xy_color
def _xy_to_led_color(self, xy_color): def _xy_to_led_color(self, xy_color):
""" Convert an XY color to the closest LedController color string """ """ Convert an XY color to the closest LedController color string. """
def abs_dist_squared(p_0, p_1): def abs_dist_squared(p_0, p_1):
""" Returns the absolute value of the squared distance """ """ Returns the absolute value of the squared distance """
return abs((p_0[0] - p_1[0])**2 + (p_0[1] - p_1[1])**2) return abs((p_0[0] - p_1[0])**2 + (p_0[1] - p_1[1])**2)

View File

@ -1,7 +1,6 @@
""" """
homeassistant.components.light.vera homeassistant.components.light.vera
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Vera lights. This component is useful if you wish for switches Support for Vera lights. This component is useful if you wish for switches
connected to your Vera controller to appear as lights in Home Assistant. connected to your Vera controller to appear as lights in Home Assistant.
All switches will be added as a light unless you exclude them in the config. All switches will be added as a light unless you exclude them in the config.
@ -9,17 +8,17 @@ All switches will be added as a light unless you exclude them in the config.
Configuration: Configuration:
To use the Vera lights you will need to add something like the following to To use the Vera lights you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
light: light:
platform: vera platform: vera
vera_controller_url: http://YOUR_VERA_IP:3480/ vera_controller_url: http://YOUR_VERA_IP:3480/
device_data: device_data:
12: 12:
name: My awesome switch name: My awesome switch
exclude: true exclude: true
13: 13:
name: Another switch name: Another switch
Variables: Variables:
@ -52,8 +51,10 @@ it should be set to "true" if you want this device excluded.
import logging import logging
from requests.exceptions import RequestException from requests.exceptions import RequestException
from homeassistant.components.switch.vera import VeraSwitch from homeassistant.components.switch.vera import VeraSwitch
# pylint: disable=no-name-in-module, import-error
import homeassistant.external.vera.vera as veraApi REQUIREMENTS = ['https://github.com/balloob/home-assistant-vera-api/archive/'
'a8f823066ead6c7da6fb5e7abaf16fef62e63364.zip'
'#python-vera==0.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -61,6 +62,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return Vera lights. """ """ Find and return Vera lights. """
import pyvera as veraApi
base_url = config.get('vera_controller_url') base_url = config.get('vera_controller_url')
if not base_url: if not base_url:

View File

@ -1,10 +1,24 @@
""" """
homeassistant.components.media_player.chromecast homeassistant.components.media_player.chromecast
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to interact with Cast devices on the network. Provides functionality to interact with Cast devices on the network.
WARNING: This platform is currently not working due to a changed Cast API WARNING: This platform is currently not working due to a changed Cast API.
Configuration:
To use the chromecast integration you will need to add something like the
following to your configuration.yaml file.
media_player:
platform: chromecast
host: 192.168.1.9
Variables:
host
*Optional
Use only if you don't want to scan for devices.
""" """
import logging import logging

View File

@ -1,9 +1,7 @@
""" """
homeassistant.components.media_player.demo homeassistant.components.media_player.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo implementation of the media player. Demo implementation of the media player.
""" """
from homeassistant.const import ( from homeassistant.const import (
STATE_PLAYING, STATE_PAUSED, STATE_OFF) STATE_PLAYING, STATE_PAUSED, STATE_OFF)

View File

@ -6,7 +6,7 @@ Provides an interface to the XBMC/Kodi JSON-RPC API
Configuration: Configuration:
To use the Kodi you will need to add something like the following to To use the Kodi you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
media_player: media_player:
platform: kodi platform: kodi
@ -74,7 +74,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def _get_image_url(kodi_url): def _get_image_url(kodi_url):
""" Helper function that parses the thumbnail URLs used by Kodi """ """ Helper function that parses the thumbnail URLs used by Kodi. """
url_components = urllib.parse.urlparse(kodi_url) url_components = urllib.parse.urlparse(kodi_url)
if url_components.scheme == 'image': if url_components.scheme == 'image':
@ -235,7 +235,7 @@ class KodiDevice(MediaPlayerDevice):
self.update_ha_state() self.update_ha_state()
def _set_play_state(self, state): def _set_play_state(self, state):
""" Helper method for play/pause/toggle """ """ Helper method for play/pause/toggle. """
players = self._get_players() players = self._get_players()
if len(players) != 0: if len(players) != 0:
@ -256,7 +256,7 @@ class KodiDevice(MediaPlayerDevice):
self._set_play_state(False) self._set_play_state(False)
def _goto(self, direction): def _goto(self, direction):
""" Helper method used for previous/next track """ """ Helper method used for previous/next track. """
players = self._get_players() players = self._get_players()
if len(players) != 0: if len(players) != 0:

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.media_player.mpd homeassistant.components.media_player.mpd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to interact with a Music Player Daemon. Provides functionality to interact with a Music Player Daemon.
Configuration: Configuration:
To use MPD you will need to add something like the following to your To use MPD you will need to add something like the following to your
config/configuration.yaml configuration.yaml file.
media_player: media_player:
platform: mpd platform: mpd

View File

@ -1,12 +1,12 @@
""" """
homeassistant.components.media_player.squeezebox homeassistant.components.media_player.squeezebox
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides an interface to the Logitech SqueezeBox API Provides an interface to the Logitech SqueezeBox API
Configuration: Configuration:
To use SqueezeBox add something like this to your configuration: To use SqueezeBox add something something like the following to your
configuration.yaml file.
media_player: media_player:
platform: squeezebox platform: squeezebox
@ -19,19 +19,19 @@ Variables:
host host
*Required *Required
The host name or address of the Logitech Media Server The host name or address of the Logitech Media Server.
port port
*Optional *Optional
Telnet port to Logitech Media Server, default 9090 Telnet port to Logitech Media Server, default 9090.
usermame usermame
*Optional *Optional
Username, if password protection is enabled Username, if password protection is enabled.
password password
*Optional *Optional
Password, if password protection is enabled Password, if password protection is enabled.
""" """
import logging import logging
@ -91,7 +91,7 @@ class LogitechMediaServer(object):
self.init_success = True if self.http_port else False self.init_success = True if self.http_port else False
def _get_http_port(self): def _get_http_port(self):
""" Get http port from media server, it is used to get cover art """ """ Get http port from media server, it is used to get cover art. """
http_port = None http_port = None
try: try:
http_port = self.query('pref', 'httpport', '?') http_port = self.query('pref', 'httpport', '?')
@ -111,7 +111,7 @@ class LogitechMediaServer(object):
return return
def create_players(self): def create_players(self):
""" Create a list of SqueezeBoxDevices connected to the LMS """ """ Create a list of SqueezeBoxDevices connected to the LMS. """
players = [] players = []
count = self.query('player', 'count', '?') count = self.query('player', 'count', '?')
for index in range(0, int(count)): for index in range(0, int(count)):
@ -121,7 +121,7 @@ class LogitechMediaServer(object):
return players return players
def query(self, *parameters): def query(self, *parameters):
""" Send request and await response from server """ """ Send request and await response from server. """
telnet = telnetlib.Telnet(self.host, self.port) telnet = telnetlib.Telnet(self.host, self.port)
if self._username and self._password: if self._username and self._password:
telnet.write('login {username} {password}\n'.format( telnet.write('login {username} {password}\n'.format(
@ -138,7 +138,7 @@ class LogitechMediaServer(object):
return urllib.parse.unquote(response) return urllib.parse.unquote(response)
def get_player_status(self, player): def get_player_status(self, player):
""" Get ithe status of a player """ """ Get ithe status of a player. """
# (title) : Song title # (title) : Song title
# Requested Information # Requested Information
# a (artist): Artist name 'artist' # a (artist): Artist name 'artist'
@ -195,7 +195,7 @@ class SqueezeBoxDevice(MediaPlayerDevice):
def update(self): def update(self):
""" Retrieve latest state. """ """ Retrieve latest state. """
self._status = self._lms.get_player_status(self._name) self._status = self._lms.get_player_status(self._id)
@property @property
def volume_level(self): def volume_level(self):

View File

@ -1,17 +1,12 @@
""" """
homeassistant.components.modbus homeassistant.components.modbus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modbus component, using pymodbus (python3 branch) Modbus component, using pymodbus (python3 branch).
Configuration:
To use the Forecast sensor you will need to add something like the
following to your config/configuration.yaml
Configuration: Configuration:
To use the Modbus component you will need to add something like the following To use the Modbus component you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
#Modbus TCP #Modbus TCP
modbus: modbus:
@ -38,8 +33,8 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_START,
DOMAIN = "modbus" DOMAIN = "modbus"
DEPENDENCIES = [] DEPENDENCIES = []
REQUIREMENTS = ['https://github.com/bashwork/pymodbus/archive/' + REQUIREMENTS = ['https://github.com/bashwork/pymodbus/archive/'
'd7fc4f1cc975631e0a9011390e8017f64b612661.zip'] 'd7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0']
# Type of network # Type of network
MEDIUM = "type" MEDIUM = "type"

View File

@ -60,7 +60,6 @@ MQTT_CLIENT = None
DEFAULT_PORT = 1883 DEFAULT_PORT = 1883
DEFAULT_KEEPALIVE = 60 DEFAULT_KEEPALIVE = 60
DEFAULT_QOS = 0
SERVICE_PUBLISH = 'publish' SERVICE_PUBLISH = 'publish'
EVENT_MQTT_MESSAGE_RECEIVED = 'MQTT_MESSAGE_RECEIVED' EVENT_MQTT_MESSAGE_RECEIVED = 'MQTT_MESSAGE_RECEIVED'
@ -75,16 +74,17 @@ CONF_KEEPALIVE = 'keepalive'
CONF_USERNAME = 'username' CONF_USERNAME = 'username'
CONF_PASSWORD = 'password' CONF_PASSWORD = 'password'
ATTR_QOS = 'qos'
ATTR_TOPIC = 'topic' ATTR_TOPIC = 'topic'
ATTR_PAYLOAD = 'payload' ATTR_PAYLOAD = 'payload'
ATTR_QOS = 'qos'
def publish(hass, topic, payload): def publish(hass, topic, payload, qos=0):
""" Send an MQTT message. """ """ Send an MQTT message. """
data = { data = {
ATTR_TOPIC: topic, ATTR_TOPIC: topic,
ATTR_PAYLOAD: payload, ATTR_PAYLOAD: payload,
ATTR_QOS: qos,
} }
hass.services.call(DOMAIN, SERVICE_PUBLISH, data) hass.services.call(DOMAIN, SERVICE_PUBLISH, data)
@ -141,9 +141,10 @@ def setup(hass, config):
""" Handle MQTT publish service calls. """ """ Handle MQTT publish service calls. """
msg_topic = call.data.get(ATTR_TOPIC) msg_topic = call.data.get(ATTR_TOPIC)
payload = call.data.get(ATTR_PAYLOAD) payload = call.data.get(ATTR_PAYLOAD)
qos = call.data.get(ATTR_QOS)
if msg_topic is None or payload is None: if msg_topic is None or payload is None:
return return
MQTT_CLIENT.publish(msg_topic, payload) MQTT_CLIENT.publish(msg_topic, payload, qos)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_mqtt) hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_mqtt)
@ -177,9 +178,9 @@ class MQTT(object): # pragma: no cover
self._mqttc.on_message = self._mqtt_on_message self._mqttc.on_message = self._mqtt_on_message
self._mqttc.connect(broker, port, keepalive) self._mqttc.connect(broker, port, keepalive)
def publish(self, topic, payload): def publish(self, topic, payload, qos):
""" Publish a MQTT message. """ """ Publish a MQTT message. """
self._mqttc.publish(topic, payload) self._mqttc.publish(topic, payload, qos)
def unsubscribe(self, topic): def unsubscribe(self, topic):
""" Unsubscribe from topic. """ """ Unsubscribe from topic. """

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.notify.file homeassistant.components.notify.file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File notification service. File notification service.
Configuration: Configuration:
To use the File notifier you will need to add something like the following To use the File notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: file platform: file

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.notify.instapush homeassistant.components.notify.instapush
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instapush notification service. Instapush notification service.
Configuration: Configuration:
To use the Instapush notifier you will need to add something like the following To use the Instapush notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: instapush platform: instapush
@ -16,7 +15,7 @@ notify:
event: YOUR_EVENT event: YOUR_EVENT
tracker: YOUR_TRACKER tracker: YOUR_TRACKER
VARIABLES: Variables:
api_key api_key
*Required *Required
@ -50,7 +49,6 @@ curl -X POST \
https://api.instapush.im/v1/post https://api.instapush.im/v1/post
Details for the API : https://instapush.im/developer/rest Details for the API : https://instapush.im/developer/rest
""" """
import logging import logging
import json import json

View File

@ -1,19 +1,18 @@
""" """
homeassistant.components.notify.nma homeassistant.components.notify.nma
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NMA (Notify My Android) notification service. NMA (Notify My Android) notification service.
Configuration: Configuration:
To use the NMA notifier you will need to add something like the following To use the NMA notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: nma platform: nma
api_key: YOUR_API_KEY api_key: YOUR_API_KEY
VARIABLES: Variables:
api_key api_key
*Required *Required
@ -21,7 +20,6 @@ Enter the API key for NMA. Go to https://www.notifymyandroid.com and create a
new API key to use with Home Assistant. new API key to use with Home Assistant.
Details for the API : https://www.notifymyandroid.com/api.jsp Details for the API : https://www.notifymyandroid.com/api.jsp
""" """
import logging import logging
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.notify.pushbullet homeassistant.components.notify.pushbullet
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PushBullet platform for notify component. PushBullet platform for notify component.
Configuration: Configuration:
To use the PushBullet notifier you will need to add something like the To use the PushBullet notifier you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
notify: notify:
platform: pushbullet platform: pushbullet
@ -32,7 +31,7 @@ REQUIREMENTS = ['pushbullet.py==0.7.1']
def get_service(hass, config): def get_service(hass, config):
""" Get the pushbullet notification service. """ """ Get the PushBullet notification service. """
if not validate_config(config, if not validate_config(config,
{DOMAIN: [CONF_API_KEY]}, {DOMAIN: [CONF_API_KEY]},

View File

@ -1,18 +1,17 @@
""" """
homeassistant.components.notify.pushover homeassistant.components.notify.pushover
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pushover platform for notify component. Pushover platform for notify component.
Configuration: Configuration:
To use the Pushover notifier you will need to add something like the following To use the Pushover notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: pushover platform: pushover
api_key: ABCDEFGHJKLMNOPQRSTUVXYZ api_key: ABCDEFGHJKLMNOPQRSTUVXYZ
user_key: ABCDEFGHJKLMNOPQRSTUVXYZ user_key: ABCDEFGHJKLMNOPQRSTUVXYZ
Variables: Variables:
@ -33,7 +32,6 @@ https://home-assistant.io/images/favicon-192x192.png
user_key user_key
*Required *Required
To retrieve this value log into your account at https://pushover.net To retrieve this value log into your account at https://pushover.net
""" """
import logging import logging

View File

@ -6,7 +6,7 @@ Slack platform for notify component.
Configuration: Configuration:
To use the Slack notifier you will need to add something like the following To use the Slack notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: slack platform: slack

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.notify.mail homeassistant.components.notify.mail
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mail (SMTP) notification service.
Mail notification service.
Configuration: Configuration:
To use the Mail notifier you will need to add something like the following To use the Mail notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: mail platform: mail

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.notify.syslog homeassistant.components.notify.syslog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Syslog notification service. Syslog notification service.
Configuration: Configuration:
To use the Syslog notifier you will need to add something like the following To use the Syslog notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: syslog platform: syslog

View File

@ -6,7 +6,7 @@ Jabber (XMPP) notification service.
Configuration: Configuration:
To use the Jabber notifier you will need to add something like the following To use the Jabber notifier you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
notify: notify:
platform: xmpp platform: xmpp

View File

@ -6,6 +6,9 @@ supported.
Configuration: Configuration:
To use the arduino sensor you will need to add something like the following
to your configuration.yaml file.
sensor: sensor:
platform: arduino platform: arduino
pins: pins:
@ -46,7 +49,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Arduino platform. """ """ Sets up the Arduino platform. """
# Verify that Arduino board is present # Verify that the Arduino board is present
if arduino.BOARD is None: if arduino.BOARD is None:
_LOGGER.error('A connection has not been made to the Arduino board.') _LOGGER.error('A connection has not been made to the Arduino board.')
return False return False

View File

@ -0,0 +1,150 @@
"""
homeassistant.components.sensor.arest
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The arest sensor will consume an exposed aREST API of a device.
Configuration:
To use the arest sensor you will need to add something like the following
to your configuration.yaml file.
sensor:
platform: arest
resource: http://IP_ADDRESS
monitored_variables:
- name: temperature
unit: '°C'
- name: humidity
unit: '%'
Variables:
resource:
*Required
IP address of the device that is exposing an aREST API.
These are the variables for the monitored_variables array:
name
*Required
The name of the variable you wish to monitor.
unit
*Optional
Defines the units of measurement of the sensor, if any.
Details for the API: http://arest.io
Format of a default JSON response by aREST:
{
"variables":{
"temperature":21,
"humidity":89
},
"id":"device008",
"name":"Bedroom",
"connected":true
}
"""
import logging
from requests import get, exceptions
from datetime import timedelta
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
# Return cached results if last scan was less then this time ago
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the aREST sensor. """
resource = config.get('resource', None)
try:
response = get(resource)
except exceptions.MissingSchema:
_LOGGER.error("Missing resource or schema in configuration. "
"Add http:// to your URL.")
return False
except exceptions.ConnectionError:
_LOGGER.error("No route to device. "
"Please check the IP address in the configuration file.")
return False
rest = ArestData(resource)
dev = []
for variable in config['monitored_variables']:
if 'unit' not in variable:
variable['unit'] = ' '
if variable['name'] not in response.json()['variables']:
_LOGGER.error('Variable: "%s" does not exist', variable['name'])
else:
dev.append(ArestSensor(rest,
response.json()['name'],
variable['name'],
variable['unit']))
add_devices(dev)
class ArestSensor(Entity):
""" Implements an aREST sensor. """
def __init__(self, rest, location, variable, unit_of_measurement):
self.rest = rest
self._name = '{} {}'.format(location.title(), variable.title())
self._variable = variable
self._state = 'n/a'
self._unit_of_measurement = unit_of_measurement
self.update()
@property
def name(self):
""" The name of the sensor. """
return self._name
@property
def unit_of_measurement(self):
""" Unit the value is expressed in. """
return self._unit_of_measurement
@property
def state(self):
""" Returns the state of the device. """
return self._state
def update(self):
""" Gets the latest data from aREST API and updates the state. """
self.rest.update()
values = self.rest.data
if 'error' in values:
self._state = values['error']
else:
self._state = values[self._variable]
# pylint: disable=too-few-public-methods
class ArestData(object):
""" Class for handling the data retrieval. """
def __init__(self, resource):
self.resource = resource
self.data = dict()
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from aREST device. """
try:
response = get(self.resource)
if 'error' in self.data:
del self.data['error']
self.data = response.json()['variables']
except exceptions.ConnectionError:
_LOGGER.error("No route to device. Is device offline?")
self.data['error'] = 'n/a'

View File

@ -1,7 +1,6 @@
""" """
homeassistant.components.sensor.bitcoin homeassistant.components.sensor.bitcoin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bitcoin information service that uses blockchain.info and its online wallet. Bitcoin information service that uses blockchain.info and its online wallet.
Configuration: Configuration:
@ -12,7 +11,7 @@ check 'Enable Api Access'. You will get an email message from blockchain.info
where you must authorize the API access. where you must authorize the API access.
To use the Bitcoin sensor you will need to add something like the following To use the Bitcoin sensor you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
sensor: sensor:
platform: bitcoin platform: bitcoin

View File

@ -1,9 +1,7 @@
""" """
homeassistant.components.sensor.demo homeassistant.components.sensor.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has a couple of fake sensors.
Demo platform that has two fake sensors.
""" """
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.const import TEMP_CELCIUS, ATTR_BATTERY_LEVEL from homeassistant.const import TEMP_CELCIUS, ATTR_BATTERY_LEVEL

View File

@ -1,6 +1,6 @@
""" """
homeassistant.components.sensor.dht homeassistant.components.sensor.dht
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adafruit DHT temperature and humidity sensor. Adafruit DHT temperature and humidity sensor.
You need a Python3 compatible version of the Adafruit_Python_DHT library You need a Python3 compatible version of the Adafruit_Python_DHT library
(e.g. https://github.com/mala-zaba/Adafruit_Python_DHT, (e.g. https://github.com/mala-zaba/Adafruit_Python_DHT,
@ -10,8 +10,8 @@ as root.
Configuration: Configuration:
To use the Adafruit DHT sensor you will need to To use the Adafruit DHT sensor you will need to add something like the
add something like the following to your config/configuration.yaml: following to your configuration.yaml file.
sensor: sensor:
platform: dht platform: dht
@ -44,8 +44,10 @@ from homeassistant.const import TEMP_FAHRENHEIT
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
# update this requirement to upstream as soon as it supports python3 # update this requirement to upstream as soon as it supports python3
REQUIREMENTS = ['http://github.com/mala-zaba/Adafruit_Python_DHT/archive/' + REQUIREMENTS = ['http://github.com/mala-zaba/Adafruit_Python_DHT/archive/'
'4101340de8d2457dd194bca1e8d11cbfc237e919.zip'] '4101340de8d2457dd194bca1e8d11cbfc237e919.zip'
'#Adafruit_DHT==1.1.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SENSOR_TYPES = { SENSOR_TYPES = {
'temperature': ['Temperature', ''], 'temperature': ['Temperature', ''],
@ -102,7 +104,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
class DHTSensor(Entity): class DHTSensor(Entity):
""" Implements an DHT sensor. """ """ Implements an DHT sensor. """
def __init__(self, dht_client, sensor_type, temp_unit): def __init__(self, dht_client, sensor_type, temp_unit):
@ -144,7 +145,6 @@ class DHTSensor(Entity):
class DHTClient(object): class DHTClient(object):
""" Gets the latest data from the DHT sensor. """ """ Gets the latest data from the DHT sensor. """
def __init__(self, adafruit_dht, sensor, pin): def __init__(self, adafruit_dht, sensor, pin):

View File

@ -7,7 +7,7 @@ Monitors home energy use as measured by an efergy engage hub using its
Configuration: Configuration:
To use the efergy sensor you will need to add something like the following To use the efergy sensor you will need to add something like the following
to your config/configuration.yaml to your configuration.yaml file.
sensor: sensor:
platform: efergy platform: efergy
@ -61,7 +61,7 @@ SENSOR_TYPES = {
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the efergy sensor. """ """ Sets up the Efergy sensor. """
app_token = config.get("app_token") app_token = config.get("app_token")
if not app_token: if not app_token:
_LOGGER.error( _LOGGER.error(
@ -118,7 +118,7 @@ class EfergySensor(Entity):
return self._unit_of_measurement return self._unit_of_measurement
def update(self): def update(self):
""" Gets the efergy monitor data from the web service """ """ Gets the Efergy monitor data from the web service. """
if self.type == 'instant_readings': if self.type == 'instant_readings':
url_string = _RESOURCE + 'getInstant?token=' + self.app_token url_string = _RESOURCE + 'getInstant?token=' + self.app_token
response = get(url_string) response = get(url_string)

View File

@ -1,12 +1,12 @@
""" """
homeassistant.components.sensor.forecast homeassistant.components.sensor.forecast
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Forecast.io service. Forecast.io weather service.
Configuration: Configuration:
To use the Forecast sensor you will need to add something like the To use the Forecast sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: forecast platform: forecast
@ -37,11 +37,9 @@ monitored_conditions
*Required *Required
An array specifying the conditions to monitor. An array specifying the conditions to monitor.
These are the variables for the monitored_conditions array: monitored_conditions
type
*Required *Required
The condition you wish to monitor, see the configuration example above for a Conditions to monitor. See the configuration example above for a
list of all available conditions to monitor. list of all available conditions to monitor.
Details for the API : https://developer.forecast.io/docs/v2 Details for the API : https://developer.forecast.io/docs/v2
@ -73,7 +71,7 @@ SENSOR_TYPES = {
'humidity': ['Humidity', '%'], 'humidity': ['Humidity', '%'],
'pressure': ['Pressure', 'mBar'], 'pressure': ['Pressure', 'mBar'],
'visibility': ['Visibility', 'km'], 'visibility': ['Visibility', 'km'],
'ozone': ['Ozone', ''], 'ozone': ['Ozone', 'DU'],
} }
# Return cached results if last scan was less then this time ago # Return cached results if last scan was less then this time ago

View File

@ -1,7 +1,6 @@
""" """
homeassistant.components.sensor.isy994 homeassistant.components.sensor.isy994
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for ISY994 sensors. Support for ISY994 sensors.
""" """
import logging import logging

View File

@ -4,8 +4,9 @@ homeassistant.components.modbus
Support for Modbus sensors. Support for Modbus sensors.
Configuration: Configuration:
To use the Modbus sensors you will need to add something like the following to To use the Modbus sensors you will need to add something like the following to
your config/configuration.yaml your configuration.yaml file.
sensor: sensor:
platform: modbus platform: modbus
@ -47,7 +48,6 @@ Note:
- Each named register will create an integer sensor. - Each named register will create an integer sensor.
- Each named bit will create a boolean sensor. - Each named bit will create a boolean sensor.
""" """
import logging import logging
import homeassistant.components.modbus as modbus import homeassistant.components.modbus as modbus
@ -61,7 +61,7 @@ DEPENDENCIES = ['modbus']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Read config and create Modbus devices """ """ Read config and create Modbus devices. """
sensors = [] sensors = []
slave = config.get("slave", None) slave = config.get("slave", None)
if modbus.TYPE == "serial" and not slave: if modbus.TYPE == "serial" and not slave:
@ -97,7 +97,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ModbusSensor(Entity): class ModbusSensor(Entity):
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
""" Represents a Modbus Sensor """ """ Represents a Modbus Sensor. """
def __init__(self, name, slave, register, bit=None, unit=None, coil=False): def __init__(self, name, slave, register, bit=None, unit=None, coil=False):
self._name = name self._name = name
@ -113,8 +113,10 @@ class ModbusSensor(Entity):
@property @property
def should_poll(self): def should_poll(self):
""" We should poll, because slaves are not allowed to """
initiate communication on Modbus networks""" We should poll, because slaves are not allowed to
initiate communication on Modbus networks.
"""
return True return True
@property @property

View File

@ -13,6 +13,7 @@ sensor:
platform: mqtt platform: mqtt
name: "MQTT Sensor" name: "MQTT Sensor"
state_topic: "home/bedroom/temperature" state_topic: "home/bedroom/temperature"
qos: 0
unit_of_measurement: "ºC" unit_of_measurement: "ºC"
Variables: Variables:
@ -25,6 +26,10 @@ state_topic
*Required *Required
The MQTT topic subscribed to receive sensor values. The MQTT topic subscribed to receive sensor values.
qos
*Optional
The maximum QoS level of the state topic. Default is 0.
unit_of_measurement unit_of_measurement
*Optional *Optional
Defines the units of measurement of the sensor, if any. Defines the units of measurement of the sensor, if any.
@ -38,6 +43,7 @@ import homeassistant.components.mqtt as mqtt
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "MQTT Sensor" DEFAULT_NAME = "MQTT Sensor"
DEFAULT_QOS = 0
DEPENDENCIES = ['mqtt'] DEPENDENCIES = ['mqtt']
@ -54,16 +60,19 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
hass, hass,
config.get('name', DEFAULT_NAME), config.get('name', DEFAULT_NAME),
config.get('state_topic'), config.get('state_topic'),
config.get('qos', DEFAULT_QOS),
config.get('unit_of_measurement'))]) config.get('unit_of_measurement'))])
# pylint: disable=too-many-arguments, too-many-instance-attributes
class MqttSensor(Entity): class MqttSensor(Entity):
""" Represents a sensor that can be updated using MQTT """ """ Represents a sensor that can be updated using MQTT """
def __init__(self, hass, name, state_topic, unit_of_measurement): def __init__(self, hass, name, state_topic, qos, unit_of_measurement):
self._state = "-" self._state = "-"
self._hass = hass self._hass = hass
self._name = name self._name = name
self._state_topic = state_topic self._state_topic = state_topic
self._qos = qos
self._unit_of_measurement = unit_of_measurement self._unit_of_measurement = unit_of_measurement
def message_received(topic, payload, qos): def message_received(topic, payload, qos):
@ -71,7 +80,7 @@ class MqttSensor(Entity):
self._state = payload self._state = payload
self.update_ha_state() self.update_ha_state()
mqtt.subscribe(hass, self._state_topic, message_received) mqtt.subscribe(hass, self._state_topic, message_received, self._qos)
@property @property
def should_poll(self): def should_poll(self):

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.sensor.mysensors homeassistant.components.sensor.mysensors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for MySensors sensors. Support for MySensors sensors.
Configuration: Configuration:
To use the MySensors sensor you will need to add something like the To use the MySensors sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: mysensors platform: mysensors
@ -36,8 +35,9 @@ ATTR_NODE_ID = "node_id"
ATTR_CHILD_ID = "child_id" ATTR_CHILD_ID = "child_id"
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['https://github.com/theolind/pymysensors/archive/' + REQUIREMENTS = ['https://github.com/theolind/pymysensors/archive/'
'35b87d880147a34107da0d40cb815d75e6cb4af7.zip'] '35b87d880147a34107da0d40cb815d75e6cb4af7.zip'
'#pymysensors==0.2']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):

View File

@ -6,7 +6,7 @@ OpenWeatherMap (OWM) service.
Configuration: Configuration:
To use the OpenWeatherMap sensor you will need to add something like the To use the OpenWeatherMap sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: openweathermap platform: openweathermap
@ -33,7 +33,7 @@ forecast
Enables the forecast. The default is to display the current conditions. Enables the forecast. The default is to display the current conditions.
monitored_conditions monitored_conditions
*Optional *Required
Conditions to monitor. See the configuration example above for a Conditions to monitor. See the configuration example above for a
list of all available conditions to monitor. list of all available conditions to monitor.

View File

@ -4,10 +4,9 @@ homeassistant.components.sensor.rfxtrx
Shows sensor values from RFXtrx sensors. Shows sensor values from RFXtrx sensors.
Configuration: Configuration:
To use the rfxtrx sensors you will need to add something like the following to
your config/configuration.yaml
Example: To use the rfxtrx sensors you will need to add something like the following to
your configuration.yaml file.
sensor: sensor:
platform: rfxtrx platform: rfxtrx
@ -27,7 +26,7 @@ from homeassistant.const import (TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/' + REQUIREMENTS = ['https://github.com/Danielhiversen/pyRFXtrx/archive/' +
'ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip'] 'ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip#RFXtrx==0.15']
DATA_TYPES = OrderedDict([ DATA_TYPES = OrderedDict([
('Temperature', TEMP_CELCIUS), ('Temperature', TEMP_CELCIUS),
@ -102,4 +101,5 @@ class RfxtrxSensor(Entity):
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit this state is expressed in. """
return self._unit_of_measurement return self._unit_of_measurement

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
homeassistant.components.sensor.rpi_gpio homeassistant.components.sensor.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure a binary state sensor using RPi GPIO. Allows to configure a binary state sensor using RPi GPIO.
Note: To use RPi GPIO, Home Assistant must be run as root. Note: To use RPi GPIO, Home Assistant must be run as root.
@ -35,11 +35,10 @@ The time in milliseconds for port debouncing. Default is 50ms.
ports ports
*Required *Required
An array specifying the GPIO ports to use and the name to use in the frontend. An array specifying the GPIO ports to use and the name to use in the frontend.
""" """
import logging import logging
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
try: try:
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
except ImportError: except ImportError:
@ -119,12 +118,12 @@ class RPiGPIOSensor(Entity):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed """ """ No polling needed. """
return False return False
@property @property
def name(self): def name(self):
""" The name of the sensor """ """ The name of the sensor. """
return self._name return self._name
@property @property

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.sensor.sabnzbd homeassistant.components.sensor.sabnzbd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Monitors SABnzbd NZB client API Monitors SABnzbd NZB client API
Configuration: Configuration:
To use the SABnzbd sensor you will need to add something like the following to To use the SABnzbd sensor you will need to add something like the following to
your config/configuration.yaml your configuration.yaml file.
sensor: sensor:
platform: sabnzbd platform: sabnzbd
@ -27,11 +26,11 @@ Variables:
base_url base_url
*Required *Required
This is the base URL of your SABnzbd instance including the port number if not This is the base URL of your SABnzbd instance including the port number if not
running on 80. Example: http://192.168.1.32:8124/ running on 80, e.g. http://192.168.1.32:8124/
name name
*Optional *Optional
The name to use when displaying this SABnzbd instance The name to use when displaying this SABnzbd instance.
monitored_variables monitored_variables
*Required *Required
@ -44,17 +43,17 @@ type
The variable you wish to monitor, see the configuration example above for a The variable you wish to monitor, see the configuration example above for a
list of all available variables. list of all available variables.
""" """
from homeassistant.util import Throttle from homeassistant.util import Throttle
from datetime import timedelta from datetime import timedelta
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
# pylint: disable=no-name-in-module, import-error
from homeassistant.external.nzbclients.sabnzbd import SabnzbdApi
from homeassistant.external.nzbclients.sabnzbd import SabnzbdApiException
import logging import logging
REQUIREMENTS = ['https://github.com/jamespcole/home-assistant-nzb-clients/'
'archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip'
'#python-sabnzbd==0.1']
SENSOR_TYPES = { SENSOR_TYPES = {
'current_status': ['Status', ''], 'current_status': ['Status', ''],
'speed': ['Speed', 'MB/s'], 'speed': ['Speed', 'MB/s'],
@ -71,7 +70,9 @@ _THROTTLED_REFRESH = None
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the sensors. """ """ Sets up the SABnzbd sensors. """
from pysabnzbd import SabnzbdApi, SabnzbdApiException
api_key = config.get("api_key") api_key = config.get("api_key")
base_url = config.get("base_url") base_url = config.get("base_url")
name = config.get("name", "SABnzbd") name = config.get("name", "SABnzbd")
@ -105,7 +106,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class SabnzbdSensor(Entity): class SabnzbdSensor(Entity):
""" A Sabnzbd sensor """ """ Represents an SABnzbd sensor. """
def __init__(self, sensor_type, sabnzb_client, client_name): def __init__(self, sensor_type, sabnzb_client, client_name):
self._name = SENSOR_TYPES[sensor_type][0] self._name = SENSOR_TYPES[sensor_type][0]
@ -132,6 +133,7 @@ class SabnzbdSensor(Entity):
def refresh_sabnzbd_data(self): def refresh_sabnzbd_data(self):
""" Calls the throttled SABnzbd refresh method. """ """ Calls the throttled SABnzbd refresh method. """
if _THROTTLED_REFRESH is not None: if _THROTTLED_REFRESH is not None:
from pysabnzbd import SabnzbdApiException
try: try:
_THROTTLED_REFRESH() _THROTTLED_REFRESH()
except SabnzbdApiException: except SabnzbdApiException:

View File

@ -1,14 +1,13 @@
""" """
homeassistant.components.sensor.swiss_public_transport homeassistant.components.sensor.swiss_public_transport
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Swiss public transport sensor will give you the next two departure times The Swiss public transport sensor will give you the next two departure times
from a given location to another one. This sensor is limited to Switzerland. from a given location to another one. This sensor is limited to Switzerland.
Configuration: Configuration:
To use the Swiss public transport sensor you will need to add something like To use the Swiss public transport sensor you will need to add something like
the following to your config/configuration.yaml the following to your configuration.yaml file.
sensor: sensor:
platform: swiss_public_transport platform: swiss_public_transport

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.sensor.systemmonitor homeassistant.components.sensor.systemmonitor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows system monitor values such as: disk, memory, and processor use.
Shows system monitor values such as: disk, memory and processor use
Configuration: Configuration:
To use the System monitor sensor you will need to add something like the To use the System monitor sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: systemmonitor platform: systemmonitor

View File

@ -1,8 +1,7 @@
""" """
homeassistant.components.sensor.tellstick homeassistant.components.sensor.tellstick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows sensor values from Tellstick sensors.
Shows sensor values from tellstick sensors.
Possible config keys: Possible config keys:

View File

@ -4,10 +4,9 @@ homeassistant.components.sensor.temper
Support for getting temperature from TEMPer devices. Support for getting temperature from TEMPer devices.
Configuration: Configuration:
To use the temper sensors you will need to add something like the following to
your config/configuration.yaml
Example: To use the temper sensors you will need to add something like the following to
your configuration.yaml file.
sensor: sensor:
platform: temper platform: temper
@ -18,8 +17,9 @@ from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['https://github.com/rkabadi/temper-python/archive/' + REQUIREMENTS = ['https://github.com/rkabadi/temper-python/archive/'
'3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip'] '3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip'
'#temperusb==1.2.3']
# pylint: disable=unused-argument # pylint: disable=unused-argument

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.sensor.time_date homeassistant.components.sensor.time_date
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date and Time service. Date and Time service.
Configuration: Configuration:
To use the Date and Time sensor you will need to add something like the To use the Date and Time sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: time_date platform: time_date

View File

@ -1,31 +1,30 @@
""" """
homeassistant.components.sensor.transmission homeassistant.components.sensor.transmission
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Monitors Transmission BitTorrent client API.
Monitors Transmission BitTorrent client API
Configuration: Configuration:
To use the Transmission sensor you will need to add something like the To use the Transmission sensor you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
sensor: sensor:
platform: transmission platform: transmission
name: Transmission name: Transmission
host: 192.168.1.26 host: 192.168.1.26
port: 9091 port: 9091
username: YOUR_USERNAME username: YOUR_USERNAME
password: YOUR_PASSWORD password: YOUR_PASSWORD
monitored_variables: monitored_variables:
- type: 'current_status' - 'current_status'
- type: 'download_speed' - 'download_speed'
- type: 'upload_speed' - 'upload_speed'
Variables: Variables:
host host
*Required *Required
This is the IP address of your Transmission daemon. Example: 192.168.1.32 This is the IP address of your Transmission daemon, e.g. 192.168.1.32
port port
*Optional *Optional
@ -33,11 +32,11 @@ The port your Transmission daemon uses, defaults to 9091. Example: 8080
username username
*Required *Required
Your Transmission username Your Transmission username.
password password
*Required *Required
Your Transmission password Your Transmission password.
name name
*Optional *Optional
@ -45,16 +44,9 @@ The name to use when displaying this Transmission instance.
monitored_variables monitored_variables
*Required *Required
An array specifying the variables to monitor. Variables to monitor. See the configuration example above for a
list of all available variables to monitor.
These are the variables for the monitored_variables array:
type
*Required
The variable you wish to monitor, see the configuration example above for a
list of all available variables.
""" """
from homeassistant.util import Throttle from homeassistant.util import Throttle
from datetime import timedelta from datetime import timedelta
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
@ -81,7 +73,7 @@ _THROTTLED_REFRESH = None
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the sensors. """ """ Sets up the Transmission sensors. """
host = config.get(CONF_HOST) host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME, None) username = config.get(CONF_USERNAME, None)
password = config.get(CONF_PASSWORD, None) password = config.get(CONF_PASSWORD, None)
@ -110,11 +102,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev = [] dev = []
for variable in config['monitored_variables']: for variable in config['monitored_variables']:
if variable['type'] not in SENSOR_TYPES: if variable not in SENSOR_TYPES:
_LOGGER.error('Sensor type: "%s" does not exist', variable['type']) _LOGGER.error('Sensor type: "%s" does not exist', variable)
else: else:
dev.append(TransmissionSensor( dev.append(TransmissionSensor(
variable['type'], transmission_api, name)) variable, transmission_api, name))
add_devices(dev) add_devices(dev)

View File

@ -1,13 +1,12 @@
""" """
homeassistant.components.sensor.vera homeassistant.components.sensor.vera
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Vera sensors. Support for Vera sensors.
Configuration: Configuration:
To use the Vera sensors you will need to add something like the following to To use the Vera sensors you will need to add something like the following to
your config/configuration.yaml your configuration.yaml file.
sensor: sensor:
platform: vera platform: vera
@ -24,8 +23,7 @@ Variables:
vera_controller_url vera_controller_url
*Required *Required
This is the base URL of your vera controller including the port number if not This is the base URL of your vera controller including the port number if not
running on 80 running on 80, e.g. http://192.168.1.21:3480/
Example: http://192.168.1.21:3480/
device_data device_data
@ -33,7 +31,7 @@ device_data
This contains an array additional device info for your Vera devices. It is not This contains an array additional device info for your Vera devices. It is not
required and if not specified all sensors configured in your Vera controller required and if not specified all sensors configured in your Vera controller
will be added with default values. You should use the id of your vera device will be added with default values. You should use the id of your vera device
as the key for the device within device_data as the key for the device within device_data.
These are the variables for the device_data array: These are the variables for the device_data array:
@ -41,14 +39,12 @@ name
*Optional *Optional
This parameter allows you to override the name of your Vera device in the HA This parameter allows you to override the name of your Vera device in the HA
interface, if not specified the value configured for the device in your Vera interface, if not specified the value configured for the device in your Vera
will be used will be used.
exclude exclude
*Optional *Optional
This parameter allows you to exclude the specified device from homeassistant, This parameter allows you to exclude the specified device from Home Assistant,
it should be set to "true" if you want this device excluded it should be set to "true" if you want this device excluded.
""" """
import logging import logging
from requests.exceptions import RequestException from requests.exceptions import RequestException
@ -58,8 +54,10 @@ from homeassistant.helpers.entity import Entity
from homeassistant.const import ( from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME, ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME,
TEMP_CELCIUS, TEMP_FAHRENHEIT) TEMP_CELCIUS, TEMP_FAHRENHEIT)
# pylint: disable=no-name-in-module, import-error
import homeassistant.external.vera.vera as veraApi REQUIREMENTS = ['https://github.com/balloob/home-assistant-vera-api/archive/'
'a8f823066ead6c7da6fb5e7abaf16fef62e63364.zip'
'#python-vera==0.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -67,6 +65,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def get_devices(hass, config): def get_devices(hass, config):
""" Find and return Vera Sensors. """ """ Find and return Vera Sensors. """
import pyvera as veraApi
base_url = config.get('vera_controller_url') base_url = config.get('vera_controller_url')
if not base_url: if not base_url:

View File

@ -6,6 +6,9 @@ supported.
Configuration: Configuration:
To use the arduino switch you will need to add something like the following
to your configuration.yaml file.
switch: switch:
platform: arduino platform: arduino
pins: pins:
@ -62,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ArduinoSwitch(SwitchDevice): class ArduinoSwitch(SwitchDevice):
""" Represents an Arduino Switch. """ """ Represents an Arduino switch. """
def __init__(self, name, pin, pin_type): def __init__(self, name, pin, pin_type):
self._pin = pin self._pin = pin
self._name = name or DEVICE_DEFAULT_NAME self._name = name or DEVICE_DEFAULT_NAME

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
homeassistant.components.switch.command_switch homeassistant.components.switch.command_switch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to configure custom shell commands to turn a switch on/off. Allows to configure custom shell commands to turn a switch on/off.
""" """
@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class CommandSwitch(SwitchDevice): class CommandSwitch(SwitchDevice):
""" Represents a switch that can be togggled using shell commands """ """ Represents a switch that can be togggled using shell commands. """
def __init__(self, name, command_on, command_off): def __init__(self, name, command_on, command_off):
self._name = name self._name = name
self._state = False self._state = False
@ -39,7 +39,7 @@ class CommandSwitch(SwitchDevice):
@staticmethod @staticmethod
def _switch(command): def _switch(command):
""" Execute the actual commands """ """ Execute the actual commands. """
_LOGGER.info('Running command: %s', command) _LOGGER.info('Running command: %s', command)
success = (subprocess.call(command, shell=True) == 0) success = (subprocess.call(command, shell=True) == 0)
@ -51,12 +51,12 @@ class CommandSwitch(SwitchDevice):
@property @property
def should_poll(self): def should_poll(self):
""" No polling needed """ """ No polling needed. """
return False return False
@property @property
def name(self): def name(self):
""" The name of the switch """ """ The name of the switch. """
return self._name return self._name
@property @property

View File

@ -3,7 +3,6 @@ homeassistant.components.switch.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has two fake switches. Demo platform that has two fake switches.
""" """
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice
from homeassistant.const import DEVICE_DEFAULT_NAME from homeassistant.const import DEVICE_DEFAULT_NAME

View File

@ -6,7 +6,7 @@ Support for Edimax switches.
Configuration: Configuration:
To use the Edimax switch you will need to add something like the following to To use the Edimax switch you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
switch: switch:
platform: edimax platform: edimax
@ -44,8 +44,8 @@ from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD,\
DEFAULT_USERNAME = 'admin' DEFAULT_USERNAME = 'admin'
DEFAULT_PASSWORD = '1234' DEFAULT_PASSWORD = '1234'
DEVICE_DEFAULT_NAME = 'Edimax Smart Plug' DEVICE_DEFAULT_NAME = 'Edimax Smart Plug'
REQUIREMENTS = ['https://github.com/rkabadi/pyedimax/archive/' + REQUIREMENTS = ['https://github.com/rkabadi/pyedimax/archive/'
'365301ce3ff26129a7910c501ead09ea625f3700.zip'] '365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1']
# setup logger # setup logger
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -89,7 +89,7 @@ class SmartPlugSwitch(SwitchDevice):
@property @property
def current_power_mwh(self): def current_power_mwh(self):
""" Current power usage in mwh. """ """ Current power usage in mWh. """
try: try:
return float(self.smartplug.now_power) / 1000000.0 return float(self.smartplug.now_power) / 1000000.0
except ValueError: except ValueError:
@ -97,7 +97,7 @@ class SmartPlugSwitch(SwitchDevice):
@property @property
def today_power_mw(self): def today_power_mw(self):
""" Today total power usage in mw. """ """ Today total power usage in mW. """
try: try:
return float(self.smartplug.now_energy_day) / 1000.0 return float(self.smartplug.now_energy_day) / 1000.0
except ValueError: except ValueError:

View File

@ -1,12 +1,12 @@
""" """
homeassistant.components.switch.modbus homeassistant.components.switch.modbus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Modbus switches. Support for Modbus switches.
Configuration: Configuration:
To use the Modbus switches you will need to add something like the following to To use the Modbus switches you will need to add something like the following to
your config/configuration.yaml your configuration.yaml file.
sensor: sensor:
platform: modbus platform: modbus
@ -42,7 +42,7 @@ DEPENDENCIES = ['modbus']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Read config and create Modbus devices """ """ Read configuration and create Modbus devices. """
switches = [] switches = []
slave = config.get("slave", None) slave = config.get("slave", None)
if modbus.TYPE == "serial" and not slave: if modbus.TYPE == "serial" and not slave:
@ -87,8 +87,10 @@ class ModbusSwitch(ToggleEntity):
@property @property
def should_poll(self): def should_poll(self):
""" We should poll, because slaves are not allowed to """
initiate communication on Modbus networks""" We should poll, because slaves are not allowed to initiate
communication on Modbus networks.
"""
return True return True
@property @property

View File

@ -26,6 +26,7 @@ switch:
name: "Bedroom Switch" name: "Bedroom Switch"
state_topic: "home/bedroom/switch1" state_topic: "home/bedroom/switch1"
command_topic: "home/bedroom/switch1/set" command_topic: "home/bedroom/switch1/set"
qos: 0
payload_on: "ON" payload_on: "ON"
payload_off: "OFF" payload_off: "OFF"
optimistic: false optimistic: false
@ -45,6 +46,11 @@ command_topic
*Required *Required
The MQTT topic to publish commands to change the switch state. The MQTT topic to publish commands to change the switch state.
qos
*Optional
The maximum QoS level of the state topic. Default is 0.
This QoS will also be used to publishing messages.
payload_on payload_on
*Optional *Optional
The payload that represents enabled state. Default is "ON". The payload that represents enabled state. Default is "ON".
@ -66,6 +72,7 @@ from homeassistant.components.switch import SwitchDevice
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "MQTT Switch" DEFAULT_NAME = "MQTT Switch"
DEFAULT_QOS = 0
DEFAULT_PAYLOAD_ON = "ON" DEFAULT_PAYLOAD_ON = "ON"
DEFAULT_PAYLOAD_OFF = "OFF" DEFAULT_PAYLOAD_OFF = "OFF"
DEFAULT_OPTIMISTIC = False DEFAULT_OPTIMISTIC = False
@ -86,6 +93,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
config.get('name', DEFAULT_NAME), config.get('name', DEFAULT_NAME),
config.get('state_topic'), config.get('state_topic'),
config.get('command_topic'), config.get('command_topic'),
config.get('qos', DEFAULT_QOS),
config.get('payload_on', DEFAULT_PAYLOAD_ON), config.get('payload_on', DEFAULT_PAYLOAD_ON),
config.get('payload_off', DEFAULT_PAYLOAD_OFF), config.get('payload_off', DEFAULT_PAYLOAD_OFF),
config.get('optimistic', DEFAULT_OPTIMISTIC))]) config.get('optimistic', DEFAULT_OPTIMISTIC))])
@ -94,13 +102,14 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-arguments, too-many-instance-attributes # pylint: disable=too-many-arguments, too-many-instance-attributes
class MqttSwitch(SwitchDevice): class MqttSwitch(SwitchDevice):
""" Represents a switch that can be togggled using MQTT """ """ Represents a switch that can be togggled using MQTT """
def __init__(self, hass, name, state_topic, command_topic, def __init__(self, hass, name, state_topic, command_topic, qos,
payload_on, payload_off, optimistic): payload_on, payload_off, optimistic):
self._state = False self._state = False
self._hass = hass self._hass = hass
self._name = name self._name = name
self._state_topic = state_topic self._state_topic = state_topic
self._command_topic = command_topic self._command_topic = command_topic
self._qos = qos
self._payload_on = payload_on self._payload_on = payload_on
self._payload_off = payload_off self._payload_off = payload_off
self._optimistic = optimistic self._optimistic = optimistic
@ -119,7 +128,8 @@ class MqttSwitch(SwitchDevice):
self._optimistic = True self._optimistic = True
else: else:
# subscribe the state_topic # subscribe the state_topic
mqtt.subscribe(hass, self._state_topic, message_received) mqtt.subscribe(hass, self._state_topic, message_received,
self._qos)
@property @property
def should_poll(self): def should_poll(self):
@ -138,7 +148,8 @@ class MqttSwitch(SwitchDevice):
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
""" Turn the device on. """ """ Turn the device on. """
mqtt.publish(self.hass, self._command_topic, self._payload_on) mqtt.publish(self.hass, self._command_topic, self._payload_on,
self._qos)
if self._optimistic: if self._optimistic:
# optimistically assume that switch has changed state # optimistically assume that switch has changed state
self._state = True self._state = True
@ -146,7 +157,8 @@ class MqttSwitch(SwitchDevice):
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
""" Turn the device off. """ """ Turn the device off. """
mqtt.publish(self.hass, self._command_topic, self._payload_off) mqtt.publish(self.hass, self._command_topic, self._payload_off,
self._qos)
if self._optimistic: if self._optimistic:
# optimistically assume that switch has changed state # optimistically assume that switch has changed state
self._state = False self._state = False

View File

@ -2,10 +2,14 @@
homeassistant.components.switch.rpi_gpio homeassistant.components.switch.rpi_gpio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allows to control the GPIO pins of a Raspberry Pi. Allows to control the GPIO pins of a Raspberry Pi.
Note: To use RPi GPIO, Home Assistant must be run as root. Note: To use RPi GPIO, Home Assistant must be run as root.
Configuration: Configuration:
To use the Raspberry GPIO switches you will need to add something like the
following to your configuration.yaml file.
switch: switch:
platform: rpi_gpio platform: rpi_gpio
invert_logic: false invert_logic: false

View File

@ -1,7 +1,6 @@
""" """
homeassistant.components.switch.tellstick homeassistant.components.switch.tellstick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Tellstick switches. Support for Tellstick switches.
Because the tellstick sends its actions via radio and from most Because the tellstick sends its actions via radio and from most
@ -47,7 +46,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class TellstickSwitchDevice(ToggleEntity): class TellstickSwitchDevice(ToggleEntity):
""" Represents a Tellstick switch within Home Assistant. """ """ Represents a Tellstick switch. """
last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON | last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
tellcore_constants.TELLSTICK_TURNOFF) tellcore_constants.TELLSTICK_TURNOFF)

View File

@ -6,15 +6,15 @@ Enable or disable Transmission BitTorrent client Turtle Mode.
Configuration: Configuration:
To use the Transmission switch you will need to add something like the To use the Transmission switch you will need to add something like the
following to your config/configuration.yaml following to your configuration.yaml file.
switch: switch:
platform: transmission platform: transmission
name: Transmission name: Transmission
host: 192.168.1.26 host: 192.168.1.26
port: 9091 port: 9091
username: YOUR_USERNAME username: YOUR_USERNAME
password: YOUR_PASSWORD password: YOUR_PASSWORD
Variables: Variables:

View File

@ -5,7 +5,7 @@ Support for Vera switches.
Configuration: Configuration:
To use the Vera lights you will need to add something like the following to To use the Vera lights you will need to add something like the following to
your config/configuration.yaml. your configuration.yaml file.
switch: switch:
platform: vera platform: vera
@ -52,8 +52,10 @@ import homeassistant.util.dt as dt_util
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.const import ( from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME) ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME)
# pylint: disable=no-name-in-module, import-error
import homeassistant.external.vera.vera as veraApi REQUIREMENTS = ['https://github.com/balloob/home-assistant-vera-api/archive/'
'a8f823066ead6c7da6fb5e7abaf16fef62e63364.zip'
'#python-vera==0.1']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -61,6 +63,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def get_devices(hass, config): def get_devices(hass, config):
""" Find and return Vera switches. """ """ Find and return Vera switches. """
import pyvera as veraApi
base_url = config.get('vera_controller_url') base_url = config.get('vera_controller_url')
if not base_url: if not base_url:

View File

@ -1,7 +1,7 @@
""" """
homeassistant.components.switch.verisure homeassistant.components.switch.verisure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Verisure Smartplugs Support for Verisure Smartplugs.
""" """
import logging import logging
@ -12,7 +12,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Arduino platform. """ """ Sets up the Verisure platform. """
if not verisure.MY_PAGES: if not verisure.MY_PAGES:
_LOGGER.error('A connection has not been made to Verisure mypages.') _LOGGER.error('A connection has not been made to Verisure mypages.')
@ -48,13 +48,13 @@ class VerisureSmartplug(SwitchDevice):
return plug_status == self.status_on return plug_status == self.status_on
def turn_on(self): def turn_on(self):
""" Set smartplug status on """ """ Set smartplug status on. """
verisure.MY_PAGES.set_smartplug_status( verisure.MY_PAGES.set_smartplug_status(
self._id, self._id,
self.status_on) self.status_on)
def turn_off(self): def turn_off(self):
""" Set smartplug status off """ """ Set smartplug status off. """
verisure.MY_PAGES.set_smartplug_status( verisure.MY_PAGES.set_smartplug_status(
self._id, self._id,
self.status_off) self.status_off)

View File

@ -36,7 +36,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class WemoSwitch(SwitchDevice): class WemoSwitch(SwitchDevice):
""" Represents a WeMo switch within Home Assistant. """ """ Represents a WeMo switch. """
def __init__(self, wemo): def __init__(self, wemo):
self.wemo = wemo self.wemo = wemo
self.insight_params = None self.insight_params = None

View File

@ -3,7 +3,6 @@ homeassistant.components.thermostat.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that offers a fake thermostat. Demo platform that offers a fake thermostat.
""" """
from homeassistant.components.thermostat import ThermostatDevice from homeassistant.components.thermostat import ThermostatDevice
from homeassistant.const import TEMP_CELCIUS, TEMP_FAHRENHEIT from homeassistant.const import TEMP_CELCIUS, TEMP_FAHRENHEIT
@ -19,7 +18,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
class DemoThermostat(ThermostatDevice): class DemoThermostat(ThermostatDevice):
""" Represents a HeatControl within Home Assistant. """ """ Represents a HeatControl thermostat. """
def __init__(self, name, target_temperature, unit_of_measurement, def __init__(self, name, target_temperature, unit_of_measurement,
away, current_temperature): away, current_temperature):
@ -60,7 +59,7 @@ class DemoThermostat(ThermostatDevice):
return self._away return self._away
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """ Set new target temperature. """
self._target_temperature = temperature self._target_temperature = temperature
def turn_away_mode_on(self): def turn_away_mode_on(self):

View File

@ -1,4 +1,6 @@
""" """
homeassistant.components.thermostat.heat_control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for a thermostat. Adds support for a thermostat.
Specify a start time, end time and a target temperature. Specify a start time, end time and a target temperature.
@ -12,8 +14,8 @@ temperature (min_temp in config). The min temperature is also used
as target temperature when no other temperature is specified. as target temperature when no other temperature is specified.
If the heater is manually turned on, the target temperature will If the heater is manually turned on, the target temperature will
be sat to 100*C. Meaning be sat to 100*C. Meaning the thermostat probably will never turn
the thermostat probably will never turn off the heater. off the heater.
If the heater is manually turned off, the target temperature will If the heater is manually turned off, the target temperature will
be sat according to normal rules. (Based on target temperature be sat according to normal rules. (Based on target temperature
for given time intervals and the min temperature.) for given time intervals and the min temperature.)
@ -21,7 +23,6 @@ for given time intervals and the min temperature.)
A target temperature sat with the set_temperature function will A target temperature sat with the set_temperature function will
override all other rules for the target temperature. override all other rules for the target temperature.
Config: Config:
[thermostat] [thermostat]
@ -55,9 +56,7 @@ target temperature will be 17*C. Between 0745 and 1500 no temperature
is specified. so the min_temp of 10*C will be used. From 1500 to 1850 is specified. so the min_temp of 10*C will be used. From 1500 to 1850
the target temperature is 20*, but if away mode is true the target the target temperature is 20*, but if away mode is true the target
temperature will be sat to 10*C temperature will be sat to 10*C
""" """
import logging import logging
import datetime import datetime
import homeassistant.components as core import homeassistant.components as core
@ -80,7 +79,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class HeatControl(ThermostatDevice): class HeatControl(ThermostatDevice):
""" Represents a HeatControl within Home Assistant. """ """ Represents a HeatControl device. """
def __init__(self, hass, config, logger): def __init__(self, hass, config, logger):
@ -150,14 +149,14 @@ class HeatControl(ThermostatDevice):
return self.min_temp return self.min_temp
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """ Set new target temperature. """
if temperature is None: if temperature is None:
self._manual_sat_temp = None self._manual_sat_temp = None
else: else:
self._manual_sat_temp = float(temperature) self._manual_sat_temp = float(temperature)
def update(self): def update(self):
""" Update current thermostat """ """ Update current thermostat. """
heater = self.hass.states.get(self.heater_entity_id) heater = self.hass.states.get(self.heater_entity_id)
if heater is None: if heater is None:
self.logger.error("No heater available") self.logger.error("No heater available")
@ -178,7 +177,7 @@ class HeatControl(ThermostatDevice):
core.turn_on(self.hass, self.heater_entity_id) core.turn_on(self.hass, self.heater_entity_id)
def _heater_turned_on(self, entity_id, old_state, new_state): def _heater_turned_on(self, entity_id, old_state, new_state):
""" heater is turned on""" """ Heater is turned on. """
if not self._heater_manual_changed: if not self._heater_manual_changed:
pass pass
else: else:
@ -187,7 +186,7 @@ class HeatControl(ThermostatDevice):
self._heater_manual_changed = True self._heater_manual_changed = True
def _heater_turned_off(self, entity_id, old_state, new_state): def _heater_turned_off(self, entity_id, old_state, new_state):
""" heater is turned off""" """ Heater is turned off. """
if self._heater_manual_changed: if self._heater_manual_changed:
self.set_temperature(None) self.set_temperature(None)

View File

@ -1,4 +1,6 @@
""" """
homeassistant.components.thermostat.nest
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Nest thermostats. Adds support for Nest thermostats.
""" """
import logging import logging
@ -41,7 +43,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class NestThermostat(ThermostatDevice): class NestThermostat(ThermostatDevice):
""" Represents a Nest thermostat within Home Assistant. """ """ Represents a Nest thermostat. """
def __init__(self, structure, device): def __init__(self, structure, device):
self.structure = structure self.structure = structure

View File

@ -1,11 +1,13 @@
""" """
components.verisure components.verisure
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
Provides support for verisure components.
Provides support for verisure components
Configuration: Configuration:
To use the Verisure component you will need to add something like the
following to your configuration.yaml file.
verisure: verisure:
username: user@example.com username: user@example.com
password: password password: password
@ -14,32 +16,31 @@ verisure:
smartplugs: 1 smartplugs: 1
thermometers: 0 thermometers: 0
Variables: Variables:
username username
*Required *Required
Username to verisure mypages Username to Verisure mypages.
password password
*Required *Required
Password to verisure mypages Password to Verisure mypages.
alarm alarm
*Opional *Optional
Set to 1 to show alarm, 0 to disable. Default 1 Set to 1 to show alarm, 0 to disable. Default 1.
hygrometers hygrometers
*Opional *Optional
Set to 1 to show hygrometers, 0 to disable. Default 1 Set to 1 to show hygrometers, 0 to disable. Default 1.
smartplugs smartplugs
*Opional *Optional
Set to 1 to show smartplugs, 0 to disable. Default 1 Set to 1 to show smartplugs, 0 to disable. Default 1.
thermometers thermometers
*Opional *Optional
Set to 1 to show thermometers, 0 to disable. Default 1 Set to 1 to show thermometers, 0 to disable. Default 1.
""" """
import logging import logging
from datetime import timedelta from datetime import timedelta
@ -61,9 +62,9 @@ DISCOVER_SWITCHES = 'verisure.switches'
DEPENDENCIES = [] DEPENDENCIES = []
REQUIREMENTS = [ REQUIREMENTS = [
'https://github.com/persandstrom/python-verisure/archive/' + 'https://github.com/persandstrom/python-verisure/archive/'
'9873c4527f01b1ba1f72ae60f7f35854390d59be.zip' '9873c4527f01b1ba1f72ae60f7f35854390d59be.zip#python-verisure==0.2.6'
] ]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -135,22 +136,22 @@ def setup(hass, config):
def get_alarm_status(): def get_alarm_status():
''' return a list of status overviews for alarm components ''' """ Return a list of status overviews for alarm components. """
return STATUS[MY_PAGES.DEVICE_ALARM] return STATUS[MY_PAGES.DEVICE_ALARM]
def get_climate_status(): def get_climate_status():
''' return a list of status overviews for alarm components ''' """ Return a list of status overviews for alarm components. """
return STATUS[MY_PAGES.DEVICE_CLIMATE] return STATUS[MY_PAGES.DEVICE_CLIMATE]
def get_smartplug_status(): def get_smartplug_status():
''' return a list of status overviews for alarm components ''' """ Return a list of status overviews for alarm components. """
return STATUS[MY_PAGES.DEVICE_SMARTPLUG] return STATUS[MY_PAGES.DEVICE_SMARTPLUG]
def reconnect(): def reconnect():
''' reconnect to verisure mypages ''' """ Reconnect to verisure mypages. """
try: try:
MY_PAGES.login() MY_PAGES.login()
except VERISURE_LOGIN_ERROR as ex: except VERISURE_LOGIN_ERROR as ex:
@ -163,7 +164,7 @@ def reconnect():
@Throttle(MIN_TIME_BETWEEN_REQUESTS) @Throttle(MIN_TIME_BETWEEN_REQUESTS)
def update(): def update():
''' Updates the status of verisure components ''' """ Updates the status of verisure components. """
if WRONG_PASSWORD_GIVEN: if WRONG_PASSWORD_GIVEN:
# Is there any way to inform user? # Is there any way to inform user?
return return

View File

@ -1,8 +1,22 @@
""" """
homeassistant.components.wink homeassistant.components.wink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Connects to a Wink hub and loads relevant components to control its devices. Connects to a Wink hub and loads relevant components to control its devices.
Configuration:
To use the Wink component you will need to add something like the following
to your configuration.yaml file.
wink:
access_token: YOUR_ACCESS_TOKEN
Variables:
access_token
*Required
Please check https://home-assistant.io/components/wink.html for further
details.
""" """
import logging import logging
@ -16,8 +30,9 @@ from homeassistant.const import (
DOMAIN = "wink" DOMAIN = "wink"
DEPENDENCIES = [] DEPENDENCIES = []
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/' + REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'c2b700e8ca866159566ecf5e644d9c297f69f257.zip'] 'c2b700e8ca866159566ecf5e644d9c297f69f257.zip'
'#python-wink==0.1']
DISCOVER_LIGHTS = "wink.lights" DISCOVER_LIGHTS = "wink.lights"
DISCOVER_SWITCHES = "wink.switches" DISCOVER_SWITCHES = "wink.switches"

View File

@ -124,7 +124,7 @@ def load_yaml_config_file(config_path):
def parse(fname): def parse(fname):
""" Parse a YAML file. """ """ Parse a YAML file. """
try: try:
with open(fname) as conf_file: with open(fname, encoding='utf-8') as conf_file:
# If configuration file is empty YAML returns None # If configuration file is empty YAML returns None
# We convert that to an empty dict # We convert that to an empty dict
return yaml.load(conf_file) or {} return yaml.load(conf_file) or {}

View File

@ -1,6 +1,6 @@
""" Constants used by Home Assistant components. """ """ Constants used by Home Assistant components. """
__version__ = "0.7.2-pre" __version__ = "0.7.2rc0"
# Can be used to specify a catch all when registering state or event listeners. # Can be used to specify a catch all when registering state or event listeners.
MATCH_ALL = '*' MATCH_ALL = '*'

@ -1 +0,0 @@
Subproject commit 4eaeb3367f9ada05dae3319cf24ab1da5de1aa89

@ -1 +0,0 @@
Subproject commit f01997498fe190d6ac2a2c375a739024843bd44d

@ -1 +0,0 @@
Subproject commit 30c59781d63322db2160ff00a4b99f16ead40b85

View File

@ -1,19 +1,58 @@
"""Helpers to install PyPi packages.""" """Helpers to install PyPi packages."""
import os import os
import logging
import pkg_resources
import subprocess import subprocess
import sys import sys
import threading
from urllib.parse import urlparse
_LOGGER = logging.getLogger(__name__)
INSTALL_LOCK = threading.Lock()
def install_package(package, upgrade=False, target=None): def install_package(package, upgrade=True, target=None):
"""Install a package on PyPi. Accepts pip compatible package strings. """Install a package on PyPi. Accepts pip compatible package strings.
Return boolean if install successfull.""" Return boolean if install successfull."""
# Not using 'import pip; pip.main([])' because it breaks the logger # Not using 'import pip; pip.main([])' because it breaks the logger
args = [sys.executable, '-m', 'pip', 'install', '--quiet', package] args = [sys.executable, '-m', 'pip', 'install', '--quiet', package]
if upgrade: if upgrade:
args.append('--upgrade') args.append('--upgrade')
if target: if target:
args += ['--target', os.path.abspath(target)] args += ['--target', os.path.abspath(target)]
with INSTALL_LOCK:
if check_package_exists(package, target):
return True
_LOGGER.info('Attempting install of %s', package)
try:
return 0 == subprocess.call(args)
except subprocess.SubprocessError:
return False
def check_package_exists(package, target=None):
"""Check if a package exists.
Returns True when the requirement is met.
Returns False when the package is not installed or doesn't meet req."""
try: try:
return 0 == subprocess.call(args) req = pkg_resources.Requirement.parse(package)
except subprocess.SubprocessError: except ValueError:
# This is a zip file
req = pkg_resources.Requirement.parse(urlparse(package).fragment)
if target:
work_set = pkg_resources.WorkingSet([target])
search_fun = work_set.find
else:
search_fun = pkg_resources.get_distribution
try:
result = search_fun(req)
except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):
return False return False
return bool(result)

View File

@ -1,5 +1,4 @@
[MASTER] [MASTER]
ignore=external,setup.py
reports=no reports=no
# Reasons disabled: # Reasons disabled:

View File

@ -77,10 +77,10 @@ python-forecastio==1.3.3
PyMata==2.07a PyMata==2.07a
# Rfxtrx sensor (sensor.rfxtrx) # Rfxtrx sensor (sensor.rfxtrx)
https://github.com/Danielhiversen/pyRFXtrx/archive/ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip https://github.com/Danielhiversen/pyRFXtrx/archive/ec7a1aaddf8270db6e5da1c13d58c1547effd7cf.zip#RFXtrx==0.15
# Mysensors # Mysensors
https://github.com/theolind/pymysensors/archive/35b87d880147a34107da0d40cb815d75e6cb4af7.zip https://github.com/theolind/pymysensors/archive/35b87d880147a34107da0d40cb815d75e6cb4af7.zip#pymysensors==0.2
# Netgear (device_tracker.netgear) # Netgear (device_tracker.netgear)
pynetgear==0.3 pynetgear==0.3
@ -92,33 +92,41 @@ netdisco==0.3
pywemo==0.3 pywemo==0.3
# Wink (*.wink) # Wink (*.wink)
https://github.com/balloob/python-wink/archive/c2b700e8ca866159566ecf5e644d9c297f69f257.zip https://github.com/balloob/python-wink/archive/c2b700e8ca866159566ecf5e644d9c297f69f257.zip#python-wink==0.1
# Slack notifier (notify.slack) # Slack notifier (notify.slack)
slacker==0.6.8 slacker==0.6.8
# Temper sensors (sensor.temper) # Temper sensors (sensor.temper)
https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip https://github.com/rkabadi/temper-python/archive/3dbdaf2d87b8db9a3cd6e5585fc704537dd2d09b.zip#temperusb==1.2.3
# PyEdimax # PyEdimax
https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip https://github.com/rkabadi/pyedimax/archive/365301ce3ff26129a7910c501ead09ea625f3700.zip#pyedimax==0.1
# RPI-GPIO platform (*.rpi_gpio) # RPI-GPIO platform (*.rpi_gpio)
# Uncomment for Raspberry Pi # Uncomment for Raspberry Pi
# RPi.GPIO ==0.5.11 # RPi.GPIO==0.5.11
# Adafruit temperature/humidity sensor # Adafruit temperature/humidity sensor
# uncomment on a Raspberry Pi / Beaglebone # uncomment on a Raspberry Pi / Beaglebone
# http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip # http://github.com/mala-zaba/Adafruit_Python_DHT/archive/4101340de8d2457dd194bca1e8d11cbfc237e919.zip#Adafruit_DHT==1.1.0
# PAHO MQTT Binding (mqtt) # PAHO MQTT Binding (mqtt)
paho-mqtt==1.1 paho-mqtt==1.1
# PyModbus (modbus) # PyModbus (modbus)
https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b612661.zip#pymodbus==1.2.0
# Verisure (verisure) # Verisure (verisure)
https://github.com/persandstrom/python-verisure/archive/9873c4527f01b1ba1f72ae60f7f35854390d59be.zip https://github.com/persandstrom/python-verisure/archive/9873c4527f01b1ba1f72ae60f7f35854390d59be.zip#python-verisure==0.2.6
# Python tools for interacting with IFTTT Maker Channel (ifttt) # Python tools for interacting with IFTTT Maker Channel (ifttt)
pyfttt==0.3 pyfttt==0.3
# sensor.sabnzbd
https://github.com/balloob/home-assistant-nzb-clients/archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip#python-sabnzbd==0.1
# switch.vera
# sensor.vera
# light.vera
https://github.com/balloob/home-assistant-vera-api/archive/a8f823066ead6c7da6fb5e7abaf16fef62e63364.zip#python-vera==0.1

View File

@ -5,5 +5,5 @@ if [ ${PWD##*/} == "scripts" ]; then
cd .. cd ..
fi fi
flake8 homeassistant
pylint homeassistant pylint homeassistant
flake8 homeassistant --exclude bower_components,external

View File

@ -1,17 +1,13 @@
import os import os
import re
from setuptools import setup, find_packages from setuptools import setup, find_packages
from homeassistant.const import __version__
PACKAGE_NAME = 'homeassistant' PACKAGE_NAME = 'homeassistant'
HERE = os.path.abspath(os.path.dirname(__file__)) HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, PACKAGE_NAME, 'const.py')) as fp: DOWNLOAD_URL = ('https://github.com/balloob/home-assistant/archive/'
VERSION = re.search("__version__ = ['\"]([^']+)['\"]\n", fp.read()).group(1) '{}.zip'.format(__version__))
DOWNLOAD_URL = \
'https://github.com/balloob/home-assistant/archive/{}.zip'.format(VERSION)
PACKAGES = find_packages(exclude=['tests', 'tests.*']) + \ PACKAGES = find_packages(exclude=['tests', 'tests.*'])
['homeassistant.external', 'homeassistant.external.noop',
'homeassistant.external.nzbclients', 'homeassistant.external.vera']
PACKAGE_DATA = \ PACKAGE_DATA = \
{'homeassistant.components.frontend': ['index.html.template'], {'homeassistant.components.frontend': ['index.html.template'],
@ -27,7 +23,7 @@ REQUIRES = [
setup( setup(
name=PACKAGE_NAME, name=PACKAGE_NAME,
version=VERSION, version=__version__,
license='MIT License', license='MIT License',
url='https://home-assistant.io/', url='https://home-assistant.io/',
download_url=DOWNLOAD_URL, download_url=DOWNLOAD_URL,