Merge branch 'dev' of https://github.com/balloob/home-assistant into hyperion
This commit is contained in:
commit
e379e3d902
71 changed files with 711 additions and 1642 deletions
|
@ -92,6 +92,7 @@ omit =
|
|||
homeassistant/components/switch/command_switch.py
|
||||
homeassistant/components/switch/edimax.py
|
||||
homeassistant/components/switch/hikvisioncam.py
|
||||
homeassistant/components/switch/rest.py
|
||||
homeassistant/components/switch/rpi_gpio.py
|
||||
homeassistant/components/switch/transmission.py
|
||||
homeassistant/components/switch/wemo.py
|
||||
|
|
11
Dockerfile
11
Dockerfile
|
@ -10,11 +10,10 @@ RUN apt-get update && \
|
|||
apt-get install -y --no-install-recommends nmap net-tools && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Open Z-Wave disabled because broken
|
||||
#RUN apt-get update && \
|
||||
# apt-get install -y cython3 libudev-dev && \
|
||||
# apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
# pip3 install cython && \
|
||||
# scripts/build_python_openzwave
|
||||
RUN apt-get update && \
|
||||
apt-get install -y cython3 libudev-dev && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
pip3 install "cython<0.23" && \
|
||||
script/build_python_openzwave
|
||||
|
||||
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
|
||||
|
|
|
@ -4,26 +4,8 @@ components.arduino
|
|||
Arduino component that connects to a directly attached Arduino board which
|
||||
runs with the Firmata firmware.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Arduino board you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
arduino:
|
||||
port: /dev/ttyACM0
|
||||
|
||||
Variables:
|
||||
|
||||
port
|
||||
*Required
|
||||
The port where is your board connected to your Home Assistant system.
|
||||
If you are using an original Arduino the port will be named ttyACM*. The exact
|
||||
number can be determined with 'ls /dev/ttyACM*' or check your 'dmesg'/
|
||||
'journalctl -f' output. Keep in mind that Arduino clones are often using a
|
||||
different name for the port (e.g. '/dev/ttyUSB*').
|
||||
|
||||
A word of caution: The Arduino is not storing states. This means that with
|
||||
every initialization the pins are set to off/low.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/arduino.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
|||
|
||||
DOMAIN = "discovery"
|
||||
DEPENDENCIES = []
|
||||
REQUIREMENTS = ['netdisco==0.4.2']
|
||||
REQUIREMENTS = ['netdisco==0.5']
|
||||
|
||||
SCAN_INTERVAL = 300 # seconds
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.light.tellstick
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Tellstick lights.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.tellstick.html
|
||||
"""
|
||||
import logging
|
||||
# pylint: disable=no-name-in-module, import-error
|
||||
|
|
|
@ -1,52 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.light.vera
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
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.
|
||||
All switches will be added as a light unless you exclude them in the config.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Vera lights you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
light:
|
||||
platform: vera
|
||||
vera_controller_url: http://YOUR_VERA_IP:3480/
|
||||
device_data:
|
||||
12:
|
||||
name: My awesome switch
|
||||
exclude: true
|
||||
13:
|
||||
name: Another switch
|
||||
|
||||
Variables:
|
||||
|
||||
vera_controller_url
|
||||
*Required
|
||||
This is the base URL of your vera controller including the port number if not
|
||||
running on 80. Example: http://192.168.1.21:3480/
|
||||
|
||||
device_data
|
||||
*Optional
|
||||
This contains an array additional device info for your Vera devices. It is not
|
||||
required and if not specified all lights configured in your Vera controller
|
||||
will be added with default values. You should use the id of your vera device
|
||||
as the key for the device within device_data.
|
||||
|
||||
These are the variables for the device_data array:
|
||||
|
||||
name
|
||||
*Optional
|
||||
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
|
||||
will be used.
|
||||
|
||||
exclude
|
||||
*Optional
|
||||
This parameter allows you to exclude the specified device from Home Assistant,
|
||||
it should be set to "true" if you want this device excluded.
|
||||
Support for Vera lights.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.vera.html
|
||||
"""
|
||||
import logging
|
||||
from requests.exceptions import RequestException
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.light.wink
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Wink lights.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.wink.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,22 +3,8 @@ homeassistant.components.media_player.chromecast
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides functionality to interact with Cast devices on the network.
|
||||
|
||||
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.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.cast.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -2,42 +2,9 @@
|
|||
homeassistant.components.media_player.denon
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides an interface to Denon Network Receivers.
|
||||
Developed for a Denon DRA-N5, see
|
||||
http://www.denon.co.uk/chg/product/compactsystems/networkmusicsystems/ceolpiccolo
|
||||
|
||||
A few notes:
|
||||
- As long as this module is active and connected, the receiver does
|
||||
not seem to accept additional telnet connections.
|
||||
|
||||
- Be careful with the volume. 50% or even 100% are very loud.
|
||||
|
||||
- To be able to wake up the receiver, activate the "remote" setting
|
||||
in the receiver's settings.
|
||||
|
||||
- Play and pause are supported, toggling is not possible.
|
||||
|
||||
- Seeking cannot be implemented as the UI sends absolute positions.
|
||||
Only seeking via simulated button presses is possible.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use your Denon you will need to add something like the following to
|
||||
your config/configuration.yaml:
|
||||
|
||||
media_player:
|
||||
platform: denon
|
||||
name: Music station
|
||||
host: 192.168.0.123
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
The ip of the player. Example: 192.168.0.123
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the device.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.denon.html
|
||||
"""
|
||||
import telnetlib
|
||||
import logging
|
||||
|
@ -67,13 +34,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
CONF_HOST)
|
||||
return False
|
||||
|
||||
add_devices([
|
||||
DenonDevice(
|
||||
config.get('name', 'Music station'),
|
||||
config.get('host'))
|
||||
])
|
||||
|
||||
return True
|
||||
denon = DenonDevice(
|
||||
config.get("name", "Music station"),
|
||||
config.get("host")
|
||||
)
|
||||
if denon.update():
|
||||
add_devices([denon])
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class DenonDevice(MediaPlayerDevice):
|
||||
|
@ -84,28 +53,41 @@ class DenonDevice(MediaPlayerDevice):
|
|||
def __init__(self, name, host):
|
||||
self._name = name
|
||||
self._host = host
|
||||
self._telnet = telnetlib.Telnet(self._host)
|
||||
self._pwstate = "PWSTANDBY"
|
||||
self._volume = 0
|
||||
self._muted = False
|
||||
self._mediasource = ""
|
||||
|
||||
def query(self, message):
|
||||
""" Send request and await response from server """
|
||||
@classmethod
|
||||
def telnet_request(cls, telnet, command):
|
||||
""" Executes `command` and returns the response. """
|
||||
telnet.write(command.encode("ASCII") + b"\r")
|
||||
return telnet.read_until(b"\r", timeout=0.2).decode("ASCII").strip()
|
||||
|
||||
def telnet_command(self, command):
|
||||
""" Establishes a telnet connection and sends `command`. """
|
||||
telnet = telnetlib.Telnet(self._host)
|
||||
telnet.write(command.encode("ASCII") + b"\r")
|
||||
telnet.read_very_eager() # skip response
|
||||
telnet.close()
|
||||
|
||||
def update(self):
|
||||
try:
|
||||
# unspecified command, should be ignored
|
||||
self._telnet.write("?".encode('UTF-8') + b'\r')
|
||||
except (EOFError, BrokenPipeError, ConnectionResetError):
|
||||
self._telnet.open(self._host)
|
||||
telnet = telnetlib.Telnet(self._host)
|
||||
except ConnectionRefusedError:
|
||||
return False
|
||||
|
||||
self._telnet.read_very_eager() # skip what is not requested
|
||||
self._pwstate = self.telnet_request(telnet, "PW?")
|
||||
# PW? sends also SISTATUS, which is not interesting
|
||||
telnet.read_until(b"\r", timeout=0.2)
|
||||
|
||||
self._telnet.write(message.encode('ASCII') + b'\r')
|
||||
# timeout 200ms, defined by protocol
|
||||
resp = self._telnet.read_until(b'\r', timeout=0.2)\
|
||||
.decode('UTF-8').strip()
|
||||
volume_str = self.telnet_request(telnet, "MV?")[len("MV"):]
|
||||
self._volume = int(volume_str) / 60
|
||||
self._muted = (self.telnet_request(telnet, "MU?") == "MUON")
|
||||
self._mediasource = self.telnet_request(telnet, "SI?")[len("SI"):]
|
||||
|
||||
if message == "PW?":
|
||||
# workaround; PW? sends also SISTATUS
|
||||
self._telnet.read_until(b'\r', timeout=0.2)
|
||||
|
||||
return resp
|
||||
telnet.close()
|
||||
return True
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -115,10 +97,9 @@ class DenonDevice(MediaPlayerDevice):
|
|||
@property
|
||||
def state(self):
|
||||
""" Returns the state of the device. """
|
||||
pwstate = self.query('PW?')
|
||||
if pwstate == "PWSTANDBY":
|
||||
if self._pwstate == "PWSTANDBY":
|
||||
return STATE_OFF
|
||||
if pwstate == "PWON":
|
||||
if self._pwstate == "PWON":
|
||||
return STATE_ON
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
@ -126,17 +107,17 @@ class DenonDevice(MediaPlayerDevice):
|
|||
@property
|
||||
def volume_level(self):
|
||||
""" Volume level of the media player (0..1). """
|
||||
return int(self.query('MV?')[len('MV'):]) / 60
|
||||
return self._volume
|
||||
|
||||
@property
|
||||
def is_volume_muted(self):
|
||||
""" Boolean if volume is currently muted. """
|
||||
return self.query('MU?') == "MUON"
|
||||
return self._muted
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
""" Current media source. """
|
||||
return self.query('SI?')[len('SI'):]
|
||||
return self._mediasource
|
||||
|
||||
@property
|
||||
def supported_media_commands(self):
|
||||
|
@ -145,24 +126,24 @@ class DenonDevice(MediaPlayerDevice):
|
|||
|
||||
def turn_off(self):
|
||||
""" turn_off media player. """
|
||||
self.query('PWSTANDBY')
|
||||
self.telnet_command("PWSTANDBY")
|
||||
|
||||
def volume_up(self):
|
||||
""" volume_up media player. """
|
||||
self.query('MVUP')
|
||||
self.telnet_command("MVUP")
|
||||
|
||||
def volume_down(self):
|
||||
""" volume_down media player. """
|
||||
self.query('MVDOWN')
|
||||
self.telnet_command("MVDOWN")
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
""" set volume level, range 0..1. """
|
||||
# 60dB max
|
||||
self.query('MV' + str(round(volume * 60)).zfill(2))
|
||||
self.telnet_command("MV" + str(round(volume * 60)).zfill(2))
|
||||
|
||||
def mute_volume(self, mute):
|
||||
""" mute (true) or unmute (false) media player. """
|
||||
self.query('MU' + ('ON' if mute else 'OFF'))
|
||||
self.telnet_command("MU" + ("ON" if mute else "OFF"))
|
||||
|
||||
def media_play_pause(self):
|
||||
""" media_play_pause media player. """
|
||||
|
@ -170,22 +151,22 @@ class DenonDevice(MediaPlayerDevice):
|
|||
|
||||
def media_play(self):
|
||||
""" media_play media player. """
|
||||
self.query('NS9A')
|
||||
self.telnet_command("NS9A")
|
||||
|
||||
def media_pause(self):
|
||||
""" media_pause media player. """
|
||||
self.query('NS9B')
|
||||
self.telnet_command("NS9B")
|
||||
|
||||
def media_next_track(self):
|
||||
""" Send next track command. """
|
||||
self.query('NS9D')
|
||||
self.telnet_command("NS9D")
|
||||
|
||||
def media_previous_track(self):
|
||||
self.query('NS9E')
|
||||
self.telnet_command("NS9E")
|
||||
|
||||
def media_seek(self, position):
|
||||
raise NotImplementedError()
|
||||
|
||||
def turn_on(self):
|
||||
""" turn the media player on. """
|
||||
self.query('PWON')
|
||||
self.telnet_command("PWON")
|
||||
|
|
|
@ -1,47 +1,11 @@
|
|||
"""
|
||||
homeassistant.components.media_player.firetv
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides functionality to interact with FireTV devices.
|
||||
|
||||
Provides control over an Amazon Fire TV (/stick) via
|
||||
python-firetv, a Python 2.x module with a helper script
|
||||
that exposes a HTTP server to fetch state and perform
|
||||
actions.
|
||||
|
||||
Steps to configure your Amazon Fire TV stick with Home Assistant:
|
||||
|
||||
1. Turn on ADB Debugging on your Amazon Fire TV:
|
||||
a. From the main (Launcher) screen, select Settings.
|
||||
b. Select System > Developer Options.
|
||||
c. Select ADB Debugging.
|
||||
2. Find Amazon Fire TV device IP:
|
||||
a. From the main (Launcher) screen, select Settings.
|
||||
b. Select System > About > Network.
|
||||
3. `pip install firetv[firetv-server]` into a Python 2.x environment
|
||||
4. `firetv-server -d <fire tv device IP>:5555`, background the process
|
||||
5. Configure Home Assistant as follows:
|
||||
|
||||
media_player:
|
||||
platform: firetv
|
||||
# optional: where firetv-server is running (default is 'localhost:5556')
|
||||
host: localhost:5556
|
||||
# optional: device id (default is 'default')
|
||||
device: livingroom-firetv
|
||||
# optional: friendly name (default is 'Amazon Fire TV')
|
||||
name: My Amazon Fire TV
|
||||
|
||||
Note that python-firetv has support for multiple Amazon Fire TV devices.
|
||||
If you have more than one configured, be sure to specify the device id used.
|
||||
Run `firetv-server -h` and/or view the source for complete capabilities.
|
||||
|
||||
Possible states are:
|
||||
- off (TV screen is dark)
|
||||
- standby (standard UI is active - not apps)
|
||||
- idle (screen saver is active)
|
||||
- play (video is playing)
|
||||
- pause (video is paused)
|
||||
- disconnected (can't communicate with device)
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.firetv.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
import requests
|
||||
|
||||
|
@ -69,7 +33,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the firetv platform. """
|
||||
""" Sets up the FireTV platform. """
|
||||
host = config.get('host', 'localhost:5556')
|
||||
device_id = config.get('device', 'default')
|
||||
try:
|
||||
|
@ -94,12 +58,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class FireTV(object):
|
||||
""" firetv-server client.
|
||||
|
||||
Should a native Python 3 ADB module become available,
|
||||
python-firetv can support Python 3, it can be added
|
||||
as a dependency, and this class can be dispensed of.
|
||||
Should a native Python 3 ADB module become available, python-firetv can
|
||||
support Python 3, it can be added as a dependency, and this class can be
|
||||
dispensed of.
|
||||
|
||||
For now, it acts as a client to the firetv-server
|
||||
HTTP server (which must be running via Python 2).
|
||||
For now, it acts as a client to the firetv-server HTTP server (which must
|
||||
be running via Python 2).
|
||||
"""
|
||||
|
||||
def __init__(self, host, device_id):
|
||||
|
@ -108,10 +72,7 @@ class FireTV(object):
|
|||
|
||||
@property
|
||||
def state(self):
|
||||
""" Get the device state.
|
||||
|
||||
An exception means UNKNOWN state.
|
||||
"""
|
||||
""" Get the device state. An exception means UNKNOWN state. """
|
||||
try:
|
||||
response = requests.get(
|
||||
DEVICE_STATE_URL.format(
|
||||
|
@ -126,11 +87,7 @@ class FireTV(object):
|
|||
return STATE_UNKNOWN
|
||||
|
||||
def action(self, action_id):
|
||||
""" Perform an action on the device.
|
||||
|
||||
There is no action acknowledgment, so exceptions
|
||||
result in a pass.
|
||||
"""
|
||||
""" Perform an action on the device. """
|
||||
try:
|
||||
requests.get(
|
||||
DEVICE_ACTION_URL.format(
|
||||
|
@ -193,7 +150,7 @@ class FireTVDevice(MediaPlayerDevice):
|
|||
self._firetv.action('turn_off')
|
||||
|
||||
def media_play(self):
|
||||
""" Send play commmand. """
|
||||
""" Send play command. """
|
||||
self._firetv.action('media_play')
|
||||
|
||||
def media_pause(self):
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.media_player.itunes
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides an interface to iTunes-API (https://github.com/maddox/itunes-api)
|
||||
|
||||
The iTunes media player will allow you to control your iTunes instance. You
|
||||
can play/pause/next/previous/mute, adjust volume, etc.
|
||||
|
||||
In addition to controlling iTunes, your available AirPlay endpoints will be
|
||||
added as media players as well. You can then individually address them append
|
||||
turn them on, turn them off, or adjust their volume.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use iTunes you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
media_player:
|
||||
platform: itunes
|
||||
name: iTunes
|
||||
host: http://192.168.1.16
|
||||
port: 8181
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the device.
|
||||
|
||||
url
|
||||
*Required
|
||||
URL of your running version of iTunes-API. Example: http://192.168.1.50:8181
|
||||
Provides an interface to iTunes API.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.itunes.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -157,11 +131,9 @@ class Itunes(object):
|
|||
path = '/airplay_devices/' + device_id + '/volume'
|
||||
return self._request('PUT', path, {'level': level})
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=abstract-method
|
||||
|
||||
# pylint: disable=unused-argument, abstract-method
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the itunes platform. """
|
||||
|
||||
|
@ -179,7 +151,6 @@ class ItunesDevice(MediaPlayerDevice):
|
|||
""" Represents a iTunes-API instance. """
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
def __init__(self, name, host, port, add_devices):
|
||||
self._name = name
|
||||
self._host = host
|
||||
|
|
|
@ -3,35 +3,8 @@ homeassistant.components.media_player.kodi
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides an interface to the XBMC/Kodi JSON-RPC API
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Kodi you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
media_player:
|
||||
platform: kodi
|
||||
name: Kodi
|
||||
url: http://192.168.0.123/jsonrpc
|
||||
user: kodi
|
||||
password: my_secure_password
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the device.
|
||||
|
||||
url
|
||||
*Required
|
||||
The URL of the XBMC/Kodi JSON-RPC API. Example: http://192.168.0.123/jsonrpc
|
||||
|
||||
user
|
||||
*Optional
|
||||
The XBMC/Kodi HTTP username.
|
||||
|
||||
password
|
||||
*Optional
|
||||
The XBMC/Kodi HTTP password.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.kodi.html
|
||||
"""
|
||||
import urllib
|
||||
import logging
|
||||
|
|
|
@ -3,35 +3,8 @@ homeassistant.components.media_player.mpd
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides functionality to interact with a Music Player Daemon.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use MPD you will need to add something like the following to your
|
||||
configuration.yaml file.
|
||||
|
||||
media_player:
|
||||
platform: mpd
|
||||
server: 127.0.0.1
|
||||
port: 6600
|
||||
location: bedroom
|
||||
password: superSecretPassword123
|
||||
|
||||
Variables:
|
||||
|
||||
server
|
||||
*Required
|
||||
IP address of the Music Player Daemon. Example: 192.168.1.32
|
||||
|
||||
port
|
||||
*Optional
|
||||
Port of the Music Player Daemon, defaults to 6600. Example: 6600
|
||||
|
||||
location
|
||||
*Optional
|
||||
Location of your Music Player Daemon.
|
||||
|
||||
password
|
||||
*Optional
|
||||
Password for your Music Player Daemon.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.mpd.html
|
||||
"""
|
||||
import logging
|
||||
import socket
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
"""
|
||||
homeassistant.components.media_player.sonos
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides an interface to Sonos players (via SoCo)
|
||||
|
||||
Configuration:
|
||||
|
||||
To use SoCo, add something like this to your configuration:
|
||||
|
||||
media_player:
|
||||
platform: sonos
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.sonos.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
|
@ -56,8 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
return True
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
# pylint: disable=too-many-public-methods
|
||||
# pylint: disable=too-many-instance-attributes, too-many-public-methods
|
||||
# pylint: disable=abstract-method
|
||||
class SonosDevice(MediaPlayerDevice):
|
||||
""" Represents a Sonos device. """
|
||||
|
@ -74,7 +67,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||
return True
|
||||
|
||||
def update_sonos(self, now):
|
||||
""" Updates state, called by track_utc_time_change """
|
||||
""" Updates state, called by track_utc_time_change. """
|
||||
self.update_ha_state(True)
|
||||
|
||||
@property
|
||||
|
@ -162,31 +155,31 @@ class SonosDevice(MediaPlayerDevice):
|
|||
return SUPPORT_SONOS
|
||||
|
||||
def turn_off(self):
|
||||
""" turn_off media player. """
|
||||
""" Turn off media player. """
|
||||
self._player.pause()
|
||||
|
||||
def volume_up(self):
|
||||
""" volume_up media player. """
|
||||
""" Volume up media player. """
|
||||
self._player.volume += 1
|
||||
|
||||
def volume_down(self):
|
||||
""" volume_down media player. """
|
||||
""" Volume down media player. """
|
||||
self._player.volume -= 1
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
""" set volume level, range 0..1. """
|
||||
""" Set volume level, range 0..1. """
|
||||
self._player.volume = str(int(volume * 100))
|
||||
|
||||
def mute_volume(self, mute):
|
||||
""" mute (true) or unmute (false) media player. """
|
||||
""" Mute (true) or unmute (false) media player. """
|
||||
self._player.mute = mute
|
||||
|
||||
def media_play(self):
|
||||
""" media_play media player. """
|
||||
""" Send paly command. """
|
||||
self._player.play()
|
||||
|
||||
def media_pause(self):
|
||||
""" media_pause media player. """
|
||||
""" Send pause command. """
|
||||
self._player.pause()
|
||||
|
||||
def media_next_track(self):
|
||||
|
@ -202,5 +195,5 @@ class SonosDevice(MediaPlayerDevice):
|
|||
self._player.seek(str(datetime.timedelta(seconds=int(position))))
|
||||
|
||||
def turn_on(self):
|
||||
""" turn the media player on. """
|
||||
""" Turn the media player on. """
|
||||
self._player.play()
|
||||
|
|
|
@ -1,39 +1,11 @@
|
|||
"""
|
||||
homeassistant.components.media_player.squeezebox
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides an interface to the Logitech SqueezeBox API
|
||||
|
||||
Configuration:
|
||||
|
||||
To use SqueezeBox add something something like the following to your
|
||||
configuration.yaml file.
|
||||
|
||||
media_player:
|
||||
platform: squeezebox
|
||||
host: 192.168.1.21
|
||||
port: 9090
|
||||
username: user
|
||||
password: password
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
The host name or address of the Logitech Media Server.
|
||||
|
||||
port
|
||||
*Optional
|
||||
Telnet port to Logitech Media Server, default 9090.
|
||||
|
||||
usermame
|
||||
*Optional
|
||||
Username, if password protection is enabled.
|
||||
|
||||
password
|
||||
*Optional
|
||||
Password, if password protection is enabled.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.squeezebox.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
import telnetlib
|
||||
import urllib.parse
|
||||
|
|
|
@ -3,27 +3,8 @@ homeassistant.components.modbus
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Modbus component, using pymodbus (python3 branch).
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Modbus component you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
#Modbus TCP
|
||||
modbus:
|
||||
type: tcp
|
||||
host: 127.0.0.1
|
||||
port: 2020
|
||||
|
||||
#Modbus RTU
|
||||
modbus:
|
||||
type: serial
|
||||
method: rtu
|
||||
port: /dev/ttyUSB0
|
||||
baudrate: 9600
|
||||
stopbits: 1
|
||||
bytesize: 8
|
||||
parity: N
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/modbus.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -1,52 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.mqtt
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
MQTT component, using paho-mqtt. This component needs a MQTT broker like
|
||||
Mosquitto or Mosca. The Eclipse Foundation is running a public MQTT server
|
||||
at iot.eclipse.org. If you prefer to use that one, keep in mind to adjust
|
||||
the topic/client ID and that your messages are public.
|
||||
MQTT component, using paho-mqtt.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use MQTT you will need to add something like the following to your
|
||||
config/configuration.yaml.
|
||||
|
||||
mqtt:
|
||||
broker: 127.0.0.1
|
||||
|
||||
Or, if you want more options:
|
||||
|
||||
mqtt:
|
||||
broker: 127.0.0.1
|
||||
port: 1883
|
||||
client_id: home-assistant-1
|
||||
keepalive: 60
|
||||
username: your_username
|
||||
password: your_secret_password
|
||||
certificate: /home/paulus/dev/addtrustexternalcaroot.crt
|
||||
|
||||
Variables:
|
||||
|
||||
broker
|
||||
*Required
|
||||
This is the IP address of your MQTT broker, e.g. 192.168.1.32.
|
||||
|
||||
port
|
||||
*Optional
|
||||
The network port to connect to. Default is 1883.
|
||||
|
||||
client_id
|
||||
*Optional
|
||||
Client ID that Home Assistant will use. Has to be unique on the server.
|
||||
Default is a random generated one.
|
||||
|
||||
keepalive
|
||||
*Optional
|
||||
The keep alive in seconds for this client. Default is 60.
|
||||
|
||||
certificate
|
||||
*Optional
|
||||
Certificate to use for encrypting the connection to the broker.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/mqtt.html
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
|
|
@ -3,7 +3,7 @@ homeassistant.components.rfxtrx
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides support for RFXtrx components.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/rfxtrx.html
|
||||
"""
|
||||
import logging
|
||||
|
|
|
@ -4,36 +4,8 @@ homeassistant.components.sensor.arduino
|
|||
Support for getting information from Arduino pins. Only analog pins are
|
||||
supported.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the arduino sensor you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: arduino
|
||||
pins:
|
||||
7:
|
||||
name: Door switch
|
||||
type: analog
|
||||
0:
|
||||
name: Brightness
|
||||
type: analog
|
||||
|
||||
Variables:
|
||||
|
||||
pins
|
||||
*Required
|
||||
An array specifying the digital pins to use on the Arduino board.
|
||||
|
||||
These are the variables for the pins array:
|
||||
|
||||
name
|
||||
*Required
|
||||
The name for the pin that will be used in the frontend.
|
||||
|
||||
type
|
||||
*Required
|
||||
The type of the pin: 'analog'.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.arduino.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,41 +3,6 @@ homeassistant.components.sensor.command_sensor
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure custom shell commands to turn a value for a sensor.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the command_line sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: command_sensor
|
||||
name: "Command sensor"
|
||||
command: sensor_command
|
||||
unit_of_measurement: "°C"
|
||||
correction_factor: 0.0001
|
||||
decimal_places: 0
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
Name of the command sensor.
|
||||
|
||||
command
|
||||
*Required
|
||||
The action to take to get the value.
|
||||
|
||||
unit_of_measurement
|
||||
*Optional
|
||||
Defines the units of measurement of the sensor, if any.
|
||||
|
||||
correction_factor
|
||||
*Optional
|
||||
A float value to do some basic calculations.
|
||||
|
||||
decimal_places
|
||||
*Optional
|
||||
Number of decimal places of the value. Default is 0.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.command_sensor.html
|
||||
"""
|
||||
|
@ -133,7 +98,7 @@ class CommandSensorData(object):
|
|||
_LOGGER.info('Running command: %s', self.command)
|
||||
|
||||
try:
|
||||
return_value = subprocess.check_output(self.command.split())
|
||||
return_value = subprocess.check_output(self.command, shell=True)
|
||||
self.value = return_value.strip().decode('utf-8')
|
||||
except subprocess.CalledProcessError:
|
||||
_LOGGER.error('Command failed: %s', self.command)
|
||||
|
|
|
@ -2,39 +2,9 @@
|
|||
homeassistant.components.sensor.dht
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adafruit DHT temperature and humidity sensor.
|
||||
You need a Python3 compatible version of the Adafruit_Python_DHT library
|
||||
(e.g. https://github.com/mala-zaba/Adafruit_Python_DHT,
|
||||
also see requirements.txt).
|
||||
As this requires access to the GPIO, you will need to run home-assistant
|
||||
as root.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Adafruit DHT sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: dht
|
||||
sensor: DHT22
|
||||
pin: 23
|
||||
monitored_conditions:
|
||||
- temperature
|
||||
- humidity
|
||||
|
||||
Variables:
|
||||
|
||||
sensor
|
||||
*Required
|
||||
The sensor type, DHT11, DHT22 or AM2302
|
||||
|
||||
pin
|
||||
*Required
|
||||
The pin the sensor is connected to, something like
|
||||
'P8_11' for Beaglebone, '23' for Raspberry Pi
|
||||
|
||||
monitored_conditions
|
||||
*Optional
|
||||
Conditions to monitor. Available conditions are temperature and humidity.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.dht.html
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -4,47 +4,8 @@ homeassistant.components.sensor.efergy
|
|||
Monitors home energy use as measured by an efergy engage hub using its
|
||||
(unofficial, undocumented) API.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the efergy sensor you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: efergy
|
||||
app_token: APP_TOKEN
|
||||
utc_offset: UTC_OFFSET
|
||||
monitored_variables:
|
||||
- type: instant_readings
|
||||
- type: budget
|
||||
- type: cost
|
||||
period: day
|
||||
currency: $
|
||||
|
||||
Variables:
|
||||
|
||||
api_key
|
||||
*Required
|
||||
To get a new App Token, log in to your efergy account, go
|
||||
to the Settings page, click on App tokens, and click "Add token".
|
||||
|
||||
utc_offset
|
||||
*Required for some variables
|
||||
Some variables (currently only the daily_cost) require that the
|
||||
negative number of minutes your timezone is ahead/behind UTC time.
|
||||
|
||||
monitored_variables
|
||||
*Required
|
||||
An array specifying the variables to monitor.
|
||||
|
||||
period
|
||||
*Optional
|
||||
Some variables take a period argument. Valid options are "day", "week",
|
||||
"month", and "year".
|
||||
|
||||
currency
|
||||
*Optional
|
||||
This is used to display the cost/period as the unit when monitoring the
|
||||
cost. It should correspond to the actual currency used in your dashboard.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.efergy.html
|
||||
"""
|
||||
import logging
|
||||
from requests import get
|
||||
|
|
|
@ -3,46 +3,8 @@ homeassistant.components.sensor.forecast
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Forecast.io weather service.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Forecast sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: forecast
|
||||
api_key: YOUR_APP_KEY
|
||||
monitored_conditions:
|
||||
- summary
|
||||
- precip_type
|
||||
- precip_intensity
|
||||
- temperature
|
||||
- dew_point
|
||||
- wind_speed
|
||||
- wind_bearing
|
||||
- cloud_cover
|
||||
- humidity
|
||||
- pressure
|
||||
- visibility
|
||||
- ozone
|
||||
|
||||
Variables:
|
||||
|
||||
api_key
|
||||
*Required
|
||||
To retrieve this value log into your account at http://forecast.io/. You can
|
||||
make 1000 requests per day. This means that you could create every 1.4 minute
|
||||
one.
|
||||
|
||||
monitored_conditions
|
||||
*Required
|
||||
An array specifying the conditions to monitor.
|
||||
|
||||
monitored_conditions
|
||||
*Required
|
||||
Conditions to monitor. See the configuration example above for a
|
||||
list of all available conditions to monitor.
|
||||
|
||||
Details for the API : https://developer.forecast.io/docs/v2
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.forecast.html
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
@ -55,23 +17,34 @@ except ImportError:
|
|||
forecastio = None
|
||||
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
||||
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# Sensor types are defined like so:
|
||||
# Name, si unit, us unit, ca unit, uk unit, uk2 unit
|
||||
SENSOR_TYPES = {
|
||||
'summary': ['Summary', ''],
|
||||
'precip_type': ['Precip', ''],
|
||||
'precip_intensity': ['Precip intensity', 'mm'],
|
||||
'temperature': ['Temperature', ''],
|
||||
'dew_point': ['Dew point', '°C'],
|
||||
'wind_speed': ['Wind Speed', 'm/s'],
|
||||
'wind_bearing': ['Wind Bearing', '°'],
|
||||
'cloud_cover': ['Cloud coverage', '%'],
|
||||
'humidity': ['Humidity', '%'],
|
||||
'pressure': ['Pressure', 'mBar'],
|
||||
'visibility': ['Visibility', 'km'],
|
||||
'ozone': ['Ozone', 'DU'],
|
||||
'summary': ['Summary', '', '', '', '', ''],
|
||||
'icon': ['Icon', '', '', '', '', ''],
|
||||
'nearest_storm_distance': ['Nearest Storm Distance',
|
||||
'km', 'm', 'km', 'km', 'm'],
|
||||
'nearest_storm_bearing': ['Nearest Storm Bearing',
|
||||
'°', '°', '°', '°', '°'],
|
||||
'precip_type': ['Precip', '', '', '', '', ''],
|
||||
'precip_intensity': ['Precip Intensity', 'mm', 'in', 'mm', 'mm', 'mm'],
|
||||
'precip_probability': ['Precip Probability', '%', '%', '%', '%', '%'],
|
||||
'temperature': ['Temperature', '°C', '°F', '°C', '°C', '°C'],
|
||||
'apparent_temperature': ['Apparent Temperature',
|
||||
'°C', '°F', '°C', '°C', '°C'],
|
||||
'dew_point': ['Dew point', '°C', '°F', '°C', '°C', '°C'],
|
||||
'wind_speed': ['Wind Speed', 'm/s', 'mph', 'km/h', 'mph', 'mph'],
|
||||
'wind_bearing': ['Wind Bearing', '°', '°', '°', '°', '°'],
|
||||
'cloud_cover': ['Cloud Coverage', '%', '%', '%', '%', '%'],
|
||||
'humidity': ['Humidity', '%', '%', '%', '%', '%'],
|
||||
'pressure': ['Pressure', 'mBar', 'mBar', 'mBar', 'mBar', 'mBar'],
|
||||
'visibility': ['Visibility', 'km', 'm', 'km', 'km', 'm'],
|
||||
'ozone': ['Ozone', 'DU', 'DU', 'DU', 'DU', 'DU'],
|
||||
}
|
||||
|
||||
# Return cached results if last scan was less then this time ago
|
||||
|
@ -90,9 +63,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
_LOGGER.error("Latitude or longitude not set in Home Assistant config")
|
||||
return False
|
||||
|
||||
SENSOR_TYPES['temperature'][1] = hass.config.temperature_unit
|
||||
unit = hass.config.temperature_unit
|
||||
|
||||
try:
|
||||
forecast = forecastio.load_forecast(config.get(CONF_API_KEY, None),
|
||||
hass.config.latitude,
|
||||
|
@ -104,16 +74,24 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
"Please check your settings for Forecast.io.")
|
||||
return False
|
||||
|
||||
if 'units' in config:
|
||||
units = config['units']
|
||||
elif hass.config.temperature_unit == TEMP_CELCIUS:
|
||||
units = 'si'
|
||||
else:
|
||||
units = 'us'
|
||||
|
||||
data = ForeCastData(config.get(CONF_API_KEY, None),
|
||||
hass.config.latitude,
|
||||
hass.config.longitude)
|
||||
hass.config.longitude,
|
||||
units)
|
||||
|
||||
dev = []
|
||||
for variable in config['monitored_conditions']:
|
||||
if variable not in SENSOR_TYPES:
|
||||
_LOGGER.error('Sensor type: "%s" does not exist', variable)
|
||||
else:
|
||||
dev.append(ForeCastSensor(data, variable, unit))
|
||||
dev.append(ForeCastSensor(data, variable))
|
||||
|
||||
add_devices(dev)
|
||||
|
||||
|
@ -122,14 +100,23 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class ForeCastSensor(Entity):
|
||||
""" Implements an Forecast.io sensor. """
|
||||
|
||||
def __init__(self, weather_data, sensor_type, unit):
|
||||
def __init__(self, weather_data, sensor_type):
|
||||
self.client_name = 'Weather'
|
||||
self._name = SENSOR_TYPES[sensor_type][0]
|
||||
self.forecast_client = weather_data
|
||||
self._unit = unit
|
||||
self.type = sensor_type
|
||||
self._state = None
|
||||
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
||||
self._unit_system = self.forecast_client.unit_system
|
||||
if self._unit_system == 'si':
|
||||
self._unit_of_measurement = SENSOR_TYPES[self.type][1]
|
||||
elif self._unit_system == 'us':
|
||||
self._unit_of_measurement = SENSOR_TYPES[self.type][2]
|
||||
elif self._unit_system == 'ca':
|
||||
self._unit_of_measurement = SENSOR_TYPES[self.type][3]
|
||||
elif self._unit_system == 'uk':
|
||||
self._unit_of_measurement = SENSOR_TYPES[self.type][4]
|
||||
elif self._unit_system == 'uk2':
|
||||
self._unit_of_measurement = SENSOR_TYPES[self.type][5]
|
||||
self.update()
|
||||
|
||||
@property
|
||||
|
@ -146,6 +133,11 @@ class ForeCastSensor(Entity):
|
|||
""" Unit of measurement of this entity, if any. """
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def unit_system(self):
|
||||
""" Unit system of this entity. """
|
||||
return self._unit_system
|
||||
|
||||
# pylint: disable=too-many-branches
|
||||
def update(self):
|
||||
""" Gets the latest data from Forecast.io and updates the states. """
|
||||
|
@ -156,7 +148,14 @@ class ForeCastSensor(Entity):
|
|||
try:
|
||||
if self.type == 'summary':
|
||||
self._state = data.summary
|
||||
elif self.type == 'icon':
|
||||
self._state = data.icon
|
||||
elif self.type == 'nearest_storm_distance':
|
||||
self._state = data.nearestStormDistance
|
||||
elif self.type == 'nearest_storm_bearing':
|
||||
self._state = data.nearestStormBearing
|
||||
elif self.type == 'precip_intensity':
|
||||
self._state = data.precipIntensity
|
||||
if data.precipIntensity == 0:
|
||||
self._state = 'None'
|
||||
self._unit_of_measurement = ''
|
||||
|
@ -168,20 +167,14 @@ class ForeCastSensor(Entity):
|
|||
self._unit_of_measurement = ''
|
||||
else:
|
||||
self._state = data.precipType
|
||||
elif self.type == 'precip_probability':
|
||||
self._state = round(data.precipProbability * 100, 1)
|
||||
elif self.type == 'dew_point':
|
||||
if self._unit == TEMP_CELCIUS:
|
||||
self._state = round(data.dewPoint, 1)
|
||||
elif self._unit == TEMP_FAHRENHEIT:
|
||||
self._state = round(data.dewPoint * 1.8 + 32.0, 1)
|
||||
else:
|
||||
self._state = round(data.dewPoint, 1)
|
||||
self._state = round(data.dewPoint, 1)
|
||||
elif self.type == 'temperature':
|
||||
if self._unit == TEMP_CELCIUS:
|
||||
self._state = round(data.temperature, 1)
|
||||
elif self._unit == TEMP_FAHRENHEIT:
|
||||
self._state = round(data.temperature * 1.8 + 32.0, 1)
|
||||
else:
|
||||
self._state = round(data.temperature, 1)
|
||||
self._state = round(data.temperature, 1)
|
||||
elif self.type == 'apparent_temperature':
|
||||
self._state = round(data.apparentTemperature, 1)
|
||||
elif self.type == 'wind_speed':
|
||||
self._state = data.windSpeed
|
||||
elif self.type == 'wind_bearing':
|
||||
|
@ -196,6 +189,7 @@ class ForeCastSensor(Entity):
|
|||
self._state = data.visibility
|
||||
elif self.type == 'ozone':
|
||||
self._state = round(data.ozone, 1)
|
||||
|
||||
except forecastio.utils.PropertyUnavailable:
|
||||
pass
|
||||
|
||||
|
@ -203,11 +197,14 @@ class ForeCastSensor(Entity):
|
|||
class ForeCastData(object):
|
||||
""" Gets the latest data from Forecast.io. """
|
||||
|
||||
def __init__(self, api_key, latitude, longitude):
|
||||
def __init__(self, api_key, latitude, longitude, units):
|
||||
self._api_key = api_key
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
self.data = None
|
||||
self.unit_system = None
|
||||
self.units = units
|
||||
self.update()
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
|
@ -216,5 +213,6 @@ class ForeCastData(object):
|
|||
forecast = forecastio.load_forecast(self._api_key,
|
||||
self.latitude,
|
||||
self.longitude,
|
||||
units='si')
|
||||
units=self.units)
|
||||
self.data = forecast.currently()
|
||||
self.unit_system = forecast.json['flags']['units']
|
||||
|
|
|
@ -3,51 +3,6 @@ homeassistant.components.sensor.glances
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Gathers system information of hosts which running glances.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the glances sensor you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: glances
|
||||
name: Glances sensor
|
||||
host: IP_ADDRESS
|
||||
port: 61208
|
||||
resources:
|
||||
- 'disk_use_percent'
|
||||
- 'disk_use'
|
||||
- 'disk_free'
|
||||
- 'memory_use_percent'
|
||||
- 'memory_use'
|
||||
- 'memory_free'
|
||||
- 'swap_use_percent'
|
||||
- 'swap_use'
|
||||
- 'swap_free'
|
||||
- 'processor_load'
|
||||
- 'process_running'
|
||||
- 'process_total'
|
||||
- 'process_thread'
|
||||
- 'process_sleeping'
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the sensor. Default is 'Glances Sensor'.
|
||||
|
||||
host
|
||||
*Required
|
||||
The IP address of your host, e.g. 192.168.1.32.
|
||||
|
||||
port
|
||||
*Optional
|
||||
The network port to connect to. Default is 61208.
|
||||
|
||||
resources
|
||||
*Required
|
||||
Resources to monitor on the host. See the configuration example above for a
|
||||
list of all available conditions to monitor.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.glances.html
|
||||
"""
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.sensor.isy994
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for ISY994 sensors.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/isy994.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,50 +3,8 @@ homeassistant.components.modbus
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Modbus sensors.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Modbus sensors you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: modbus
|
||||
slave: 1
|
||||
registers:
|
||||
16:
|
||||
name: My integer sensor
|
||||
unit: C
|
||||
24:
|
||||
bits:
|
||||
0:
|
||||
name: My boolean sensor
|
||||
2:
|
||||
name: My other boolean sensor
|
||||
coils:
|
||||
0:
|
||||
name: My coil switch
|
||||
|
||||
Variables:
|
||||
|
||||
slave
|
||||
*Required
|
||||
Slave number (ignored and can be omitted if not serial Modbus).
|
||||
|
||||
unit
|
||||
*Required
|
||||
Unit to attach to value (optional, ignored for boolean sensors).
|
||||
|
||||
registers
|
||||
*Required
|
||||
Contains a list of relevant registers to read from. It can contain a
|
||||
"bits" section, listing relevant bits.
|
||||
|
||||
coils
|
||||
*Optional
|
||||
Contains a list of relevant coils to read from.
|
||||
|
||||
Note:
|
||||
- Each named register will create an integer sensor.
|
||||
- Each named bit will create a boolean sensor.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.modbus.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -1,41 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
homeassistant.components.sensor.mqtt
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure a MQTT sensor.
|
||||
|
||||
This generic sensor implementation uses the MQTT message payload
|
||||
as the sensor value. If messages in this state_topic are published
|
||||
with RETAIN flag, the sensor will receive an instant update with
|
||||
last known value. Otherwise, the initial state will be undefined.
|
||||
|
||||
sensor:
|
||||
platform: mqtt
|
||||
name: "MQTT Sensor"
|
||||
state_topic: "home/bedroom/temperature"
|
||||
qos: 0
|
||||
unit_of_measurement: "ºC"
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the sensor. Default is 'MQTT Sensor'.
|
||||
|
||||
state_topic
|
||||
*Required
|
||||
The MQTT topic subscribed to receive sensor values.
|
||||
|
||||
qos
|
||||
*Optional
|
||||
The maximum QoS level of the state topic. Default is 0.
|
||||
|
||||
unit_of_measurement
|
||||
*Optional
|
||||
Defines the units of measurement of the sensor, if any.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.mqtt.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
|
@ -50,7 +20,7 @@ DEPENDENCIES = ['mqtt']
|
|||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Add MQTT Sensor """
|
||||
""" Add MQTT Sensor. """
|
||||
|
||||
if config.get('state_topic') is None:
|
||||
_LOGGER.error("Missing required variable: state_topic")
|
||||
|
@ -66,7 +36,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
|
||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||
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, qos, unit_of_measurement):
|
||||
self._state = "-"
|
||||
self._hass = hass
|
||||
|
|
|
@ -3,40 +3,8 @@ homeassistant.components.sensor.mysensors
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for MySensors sensors.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the MySensors sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: mysensors
|
||||
port: '/dev/ttyACM0'
|
||||
|
||||
Variables:
|
||||
|
||||
port
|
||||
*Required
|
||||
Port of your connection to your MySensors device.
|
||||
|
||||
debug
|
||||
*Optional
|
||||
Enable or disable verbose debug logging.
|
||||
|
||||
persistence
|
||||
*Optional
|
||||
Enable or disable local persistence of sensor information.
|
||||
Note: If this is disabled, then each sensor will need to send presentation
|
||||
messages after Home Assistant starts
|
||||
|
||||
persistence_file
|
||||
*Optional
|
||||
Path to a file to save sensor information.
|
||||
Note: The file extension determines the file type. Currently supported file
|
||||
types are 'pickle' and 'json'.
|
||||
|
||||
version
|
||||
*Optional
|
||||
Specifies the MySensors protocol version to use (ex. 1.4, 1.5).
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.mysensors.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,43 +3,8 @@ homeassistant.components.sensor.openweathermap
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
OpenWeatherMap (OWM) service.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the OpenWeatherMap sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: openweathermap
|
||||
api_key: YOUR_APP_KEY
|
||||
forecast: 0 or 1
|
||||
monitored_conditions:
|
||||
- weather
|
||||
- temperature
|
||||
- wind_speed
|
||||
- humidity
|
||||
- pressure
|
||||
- clouds
|
||||
- rain
|
||||
- snow
|
||||
|
||||
Variables:
|
||||
|
||||
api_key
|
||||
*Required
|
||||
To retrieve this value log into your account at http://openweathermap.org/
|
||||
|
||||
forecast
|
||||
*Optional
|
||||
Enables the forecast. The default is to display the current conditions.
|
||||
|
||||
monitored_conditions
|
||||
*Required
|
||||
Conditions to monitor. See the configuration example above for a
|
||||
list of all available conditions to monitor.
|
||||
|
||||
Details for the API : http://bugs.openweathermap.org/projects/api/wiki
|
||||
|
||||
Only metric measurements are supported at the moment.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.openweathermap.html
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -1,41 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
homeassistant.components.sensor.rpi_gpio
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure a binary state sensor using RPi GPIO.
|
||||
To avoid having to run Home Assistant as root when using this component,
|
||||
run a Raspbian version released at or after September 29, 2015.
|
||||
|
||||
sensor:
|
||||
platform: rpi_gpio
|
||||
pull_mode: "UP"
|
||||
value_high: "Active"
|
||||
value_low: "Inactive"
|
||||
ports:
|
||||
11: PIR Office
|
||||
12: PIR Bedroom
|
||||
|
||||
Variables:
|
||||
|
||||
pull_mode
|
||||
*Optional
|
||||
The internal pull to use (UP or DOWN). Default is UP.
|
||||
|
||||
value_high
|
||||
*Optional
|
||||
The value of the sensor when the port is HIGH. Default is "HIGH".
|
||||
|
||||
value_low
|
||||
*Optional
|
||||
The value of the sensor when the port is LOW. Default is "LOW".
|
||||
|
||||
bouncetime
|
||||
*Optional
|
||||
The time in milliseconds for port debouncing. Default is 50ms.
|
||||
|
||||
ports
|
||||
*Required
|
||||
An array specifying the GPIO ports to use and the name to use in the frontend.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.rpi_gpio.html
|
||||
"""
|
||||
import logging
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
|
|
@ -4,7 +4,7 @@ homeassistant.components.sensor.sabnzbd
|
|||
Monitors SABnzbd NZB client API.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.sabnzbd.html
|
||||
https://home-assistant.io/components/sensor.sabnzbd.html
|
||||
"""
|
||||
from homeassistant.util import Throttle
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -4,30 +4,8 @@ homeassistant.components.sensor.swiss_public_transport
|
|||
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.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Swiss public transport sensor you will need to add something like
|
||||
the following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: swiss_public_transport
|
||||
from: STATION_ID
|
||||
to: STATION_ID
|
||||
|
||||
Variables:
|
||||
|
||||
from
|
||||
*Required
|
||||
Start station/stop of your trip. To search for the ID of the station, use the
|
||||
an URL like this: http://transport.opendata.ch/v1/locations?query=Wankdorf
|
||||
to query for the station. If the score is 100 ("score":"100" in the response),
|
||||
it is a perfect match.
|
||||
|
||||
to
|
||||
*Required
|
||||
Destination station/stop of the trip. Same procedure as for the start station.
|
||||
|
||||
Details for the API : http://transport.opendata.ch
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.swiss_public_transport.html
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
@ -40,6 +18,12 @@ from homeassistant.helpers.entity import Entity
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
_RESOURCE = 'http://transport.opendata.ch/v1/'
|
||||
|
||||
ATTR_DEPARTURE_TIME1 = 'Next departure'
|
||||
ATTR_DEPARTURE_TIME2 = 'Next on departure'
|
||||
ATTR_START = 'Start'
|
||||
ATTR_TARGET = 'Destination'
|
||||
ATTR_REMAINING_TIME = 'Remaining time'
|
||||
|
||||
# Return cached results if last scan was less then this time ago
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||
|
||||
|
@ -60,8 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
_LOGGER.exception(
|
||||
"Unable to determine stations. "
|
||||
"Check your settings and/or the availability of opendata.ch")
|
||||
|
||||
return None
|
||||
return False
|
||||
|
||||
dev = []
|
||||
data = PublicTransportData(journey)
|
||||
|
@ -75,7 +58,9 @@ class SwissPublicTransportSensor(Entity):
|
|||
|
||||
def __init__(self, data, journey):
|
||||
self.data = data
|
||||
self._name = '{}-{}'.format(journey[2], journey[3])
|
||||
self._name = 'Next Departure'
|
||||
self._from = journey[2]
|
||||
self._to = journey[3]
|
||||
self.update()
|
||||
|
||||
@property
|
||||
|
@ -88,12 +73,26 @@ class SwissPublicTransportSensor(Entity):
|
|||
""" Returns the state of the device. """
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def state_attributes(self):
|
||||
""" Returns the state attributes. """
|
||||
if self._times is not None:
|
||||
return {
|
||||
ATTR_DEPARTURE_TIME1: self._times[0],
|
||||
ATTR_DEPARTURE_TIME2: self._times[1],
|
||||
ATTR_START: self._from,
|
||||
ATTR_TARGET: self._to,
|
||||
ATTR_REMAINING_TIME: '{}'.format(
|
||||
':'.join(str(self._times[2]).split(':')[:2]))
|
||||
}
|
||||
|
||||
# pylint: disable=too-many-branches
|
||||
def update(self):
|
||||
""" Gets the latest data from opendata.ch and updates the states. """
|
||||
times = self.data.update()
|
||||
self.data.update()
|
||||
self._times = self.data.times
|
||||
try:
|
||||
self._state = ', '.join(times)
|
||||
self._state = self._times[0]
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
@ -105,6 +104,7 @@ class PublicTransportData(object):
|
|||
def __init__(self, journey):
|
||||
self.start = journey[0]
|
||||
self.destination = journey[1]
|
||||
self.times = {}
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
|
@ -117,16 +117,21 @@ class PublicTransportData(object):
|
|||
'to=' + self.destination + '&' +
|
||||
'fields[]=connections/from/departureTimestamp/&' +
|
||||
'fields[]=connections/',
|
||||
timeout=10)
|
||||
timeout=30)
|
||||
connections = response.json()['connections'][:2]
|
||||
|
||||
try:
|
||||
return [
|
||||
self.times = [
|
||||
dt_util.datetime_to_time_str(
|
||||
dt_util.as_local(dt_util.utc_from_timestamp(
|
||||
item['from']['departureTimestamp']))
|
||||
)
|
||||
for item in connections
|
||||
]
|
||||
self.times.append(
|
||||
dt_util.as_local(
|
||||
dt_util.utc_from_timestamp(
|
||||
connections[0]['from']['departureTimestamp'])) -
|
||||
dt_util.as_local(dt_util.utcnow()))
|
||||
except KeyError:
|
||||
return ['n/a']
|
||||
self.times = ['n/a']
|
||||
|
|
|
@ -3,24 +3,8 @@ homeassistant.components.sensor.tellstick
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Shows sensor values from Tellstick sensors.
|
||||
|
||||
Possible config keys:
|
||||
|
||||
id of the sensor: Name the sensor with ID
|
||||
135=Outside
|
||||
|
||||
only_named: Only show the named sensors
|
||||
only_named=1
|
||||
|
||||
temperature_scale: The scale of the temperature value
|
||||
temperature_scale=°C
|
||||
|
||||
datatype_mask: mask to determine which sensor values to show based on
|
||||
https://tellcore-py.readthedocs.org
|
||||
/en/v1.0.4/constants.html#module-tellcore.constants
|
||||
|
||||
datatype_mask=1 # only show temperature
|
||||
datatype_mask=12 # only show rain rate and rain total
|
||||
datatype_mask=127 # show all sensor values
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.tellstick.html
|
||||
"""
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
|
|
|
@ -3,13 +3,8 @@ homeassistant.components.sensor.temper
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for getting temperature from TEMPer devices.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the temper sensors you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: temper
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.temper.html
|
||||
"""
|
||||
import logging
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
|
|
@ -3,27 +3,8 @@ homeassistant.components.sensor.time_date
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Date and Time service.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Date and Time sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: time_date
|
||||
display_options:
|
||||
- 'time'
|
||||
- 'date'
|
||||
- 'date_time'
|
||||
- 'time_date'
|
||||
- 'time_utc'
|
||||
- 'beat'
|
||||
|
||||
Variables:
|
||||
|
||||
display_options
|
||||
*Required
|
||||
The variable you wish to display. See the configuration example above for a
|
||||
list of all available variables.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.time_date.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,49 +3,8 @@ homeassistant.components.sensor.transmission
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Monitors Transmission BitTorrent client API.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Transmission sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: transmission
|
||||
name: Transmission
|
||||
host: 192.168.1.26
|
||||
port: 9091
|
||||
username: YOUR_USERNAME
|
||||
password: YOUR_PASSWORD
|
||||
monitored_variables:
|
||||
- 'current_status'
|
||||
- 'download_speed'
|
||||
- 'upload_speed'
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
This is the IP address of your Transmission daemon, e.g. 192.168.1.32
|
||||
|
||||
port
|
||||
*Optional
|
||||
The port your Transmission daemon uses, defaults to 9091. Example: 8080
|
||||
|
||||
username
|
||||
*Required
|
||||
Your Transmission username.
|
||||
|
||||
password
|
||||
*Required
|
||||
Your Transmission password.
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name to use when displaying this Transmission instance.
|
||||
|
||||
monitored_variables
|
||||
*Required
|
||||
Variables to monitor. See the configuration example above for a
|
||||
list of all available variables to monitor.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.transmission.html
|
||||
"""
|
||||
from homeassistant.util import Throttle
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -3,48 +3,8 @@ homeassistant.components.sensor.vera
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Vera sensors.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Vera sensors you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: vera
|
||||
vera_controller_url: http://YOUR_VERA_IP:3480/
|
||||
device_data:
|
||||
12:
|
||||
name: My awesome sensor
|
||||
exclude: true
|
||||
13:
|
||||
name: Another sensor
|
||||
|
||||
Variables:
|
||||
|
||||
vera_controller_url
|
||||
*Required
|
||||
This is the base URL of your vera controller including the port number if not
|
||||
running on 80, e.g. http://192.168.1.21:3480/
|
||||
|
||||
|
||||
device_data
|
||||
*Optional
|
||||
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
|
||||
will be added with default values. You should use the id of your vera device
|
||||
as the key for the device within device_data.
|
||||
|
||||
These are the variables for the device_data array:
|
||||
|
||||
name
|
||||
*Optional
|
||||
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
|
||||
will be used.
|
||||
|
||||
exclude
|
||||
*Optional
|
||||
This parameter allows you to exclude the specified device from Home Assistant,
|
||||
it should be set to "true" if you want this device excluded.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.vera.html
|
||||
"""
|
||||
import logging
|
||||
from requests.exceptions import RequestException
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.sensor.verisure
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Interfaces with Verisure sensors.
|
||||
|
||||
For more details about the verisure component, please refer to the
|
||||
documentation at https://home-assistant.io/components/verisure.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.sensor.wink
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Wink sensors.
|
||||
|
||||
For more details about the wink component, please refer to the documentation
|
||||
at https://home-assistant.io/components/sensor.wink.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -22,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
if token is None:
|
||||
logging.getLogger(__name__).error(
|
||||
"Missing wink access_token - "
|
||||
"get one at https://winkbearertoken.appspot.com/")
|
||||
"Missing wink access_token. "
|
||||
"Get one at https://winkbearertoken.appspot.com/")
|
||||
return
|
||||
|
||||
pywink.set_bearer_token(token)
|
||||
|
@ -32,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
|
||||
class WinkSensorDevice(Entity):
|
||||
""" Represents a wink sensor. """
|
||||
""" Represents a Wink sensor. """
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
|
|
|
@ -4,26 +4,6 @@ homeassistant.components.sensor.worldclock
|
|||
The Worldclock sensor let you display the current time of a different time
|
||||
zone.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Worldclock sensor you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: worldclock
|
||||
time_zone: America/New_York
|
||||
name: New York
|
||||
|
||||
Variables:
|
||||
|
||||
time_zone
|
||||
*Required
|
||||
Time zone you want to display.
|
||||
|
||||
name
|
||||
*Optional
|
||||
Name of the sensor to use in the frontend.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.worldclock.html
|
||||
"""
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.sensor.zwave
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Interfaces with Z-Wave sensors.
|
||||
|
||||
For more details about the zwave component, please refer to the documentation
|
||||
at https://home-assistant.io/components/zwave.html
|
||||
"""
|
||||
# pylint: disable=import-error
|
||||
from openzwave.network import ZWaveNetwork
|
||||
|
|
|
@ -34,7 +34,7 @@ def setup(hass, config):
|
|||
def service_handler(call):
|
||||
""" Execute a shell command service. """
|
||||
try:
|
||||
subprocess.call(conf[call.service].split(' '),
|
||||
subprocess.call(conf[call.service], shell=True,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
except subprocess.SubprocessError:
|
||||
|
|
|
@ -4,36 +4,8 @@ homeassistant.components.switch.arduino
|
|||
Support for switching Arduino pins on and off. So far only digital pins are
|
||||
supported.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the arduino switch you will need to add something like the following
|
||||
to your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: arduino
|
||||
pins:
|
||||
11:
|
||||
name: Fan Office
|
||||
type: digital
|
||||
12:
|
||||
name: Light Desk
|
||||
type: digital
|
||||
|
||||
Variables:
|
||||
|
||||
pins
|
||||
*Required
|
||||
An array specifying the digital pins to use on the Arduino board.
|
||||
|
||||
These are the variables for the pins array:
|
||||
|
||||
name
|
||||
*Required
|
||||
The name for the pin that will be used in the frontend.
|
||||
|
||||
type
|
||||
*Required
|
||||
The type of the pin: 'digital'.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.arduino.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -28,8 +28,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
"Add http:// to your URL.")
|
||||
return False
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.error("No route to device. "
|
||||
"Please check the IP address in the configuration file.")
|
||||
_LOGGER.error("No route to device at %s. "
|
||||
"Please check the IP address in the configuration file.",
|
||||
resource)
|
||||
return False
|
||||
|
||||
dev = []
|
||||
|
|
|
@ -1,37 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
homeassistant.components.switch.command_switch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure custom shell commands to turn a switch on/off.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the command_line switch you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: command_switch
|
||||
switches:
|
||||
name_of_the_switch:
|
||||
oncmd: switch_command on for name_of_the_switch
|
||||
offcmd: switch_command off for name_of_the_switch
|
||||
|
||||
Variables:
|
||||
|
||||
These are the variables for the switches array:
|
||||
|
||||
name_of_the_switch
|
||||
*Required
|
||||
Name of the command switch. Multiple entries are possible.
|
||||
|
||||
oncmd
|
||||
*Required
|
||||
The action to take for on.
|
||||
|
||||
offcmd
|
||||
*Required
|
||||
The action to take for off.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.command_switch.html
|
||||
"""
|
||||
|
|
|
@ -3,35 +3,8 @@ homeassistant.components.switch.edimax
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Edimax switches.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Edimax switch you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: edimax
|
||||
host: 192.168.1.32
|
||||
username: YOUR_USERNAME
|
||||
password: YOUR_PASSWORD
|
||||
name: Edimax Smart Plug
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
This is the IP address of your Edimax switch. Example: 192.168.1.32
|
||||
|
||||
username
|
||||
*Required
|
||||
Your username to access your Edimax switch.
|
||||
|
||||
password
|
||||
*Required
|
||||
Your password.
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name to use when displaying this switch instance.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.edimax.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,39 +3,8 @@ homeassistant.components.switch.hikvision
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support turning on/off motion detection on Hikvision cameras.
|
||||
|
||||
Note: Currently works using default https port only.
|
||||
|
||||
CGI API Guide: http://bit.ly/1RuyUuF
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Hikvision motion detection switch you will need to add something
|
||||
like the following to your config/configuration.yaml
|
||||
|
||||
switch:
|
||||
platform: hikvisioncam
|
||||
name: Hikvision Cam 1 Motion Detection
|
||||
host: 192.168.1.32
|
||||
username: YOUR_USERNAME
|
||||
password: YOUR_PASSWORD
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
This is the IP address of your Hikvision camera. Example: 192.168.1.32
|
||||
|
||||
username
|
||||
*Required
|
||||
Your Hikvision camera username.
|
||||
|
||||
password
|
||||
*Required
|
||||
Your Hikvision camera username.
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name to use when displaying this switch instance.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.hikvision.html
|
||||
"""
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.const import STATE_ON, STATE_OFF
|
||||
|
@ -55,7 +24,7 @@ REQUIREMENTS = ['hikvision==0.4']
|
|||
|
||||
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Setup Hikvision Camera config. """
|
||||
""" Setup Hikvision camera. """
|
||||
|
||||
host = config.get(CONF_HOST, None)
|
||||
port = config.get('port', "80")
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.switch.isy994
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Support for ISY994 switches.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/isy994.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -3,35 +3,9 @@ homeassistant.components.switch.modbus
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Modbus switches.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Modbus switches you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
sensor:
|
||||
platform: modbus
|
||||
slave: 1
|
||||
registers:
|
||||
24:
|
||||
bits:
|
||||
0:
|
||||
name: My switch
|
||||
2:
|
||||
name: My other switch
|
||||
coils:
|
||||
0:
|
||||
name: My coil switch
|
||||
|
||||
VARIABLES:
|
||||
|
||||
- "slave" = slave number (ignored and can be omitted if not serial Modbus)
|
||||
- "registers" contains a list of relevant registers to read from
|
||||
- it must contain a "bits" section, listing relevant bits
|
||||
- "coils" contains a list of relevant coils to read from/write to
|
||||
|
||||
- each named bit will create a switch
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.modbus.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import homeassistant.components.modbus as modbus
|
||||
|
|
|
@ -1,70 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
homeassistant.components.switch.mqtt
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure a MQTT switch.
|
||||
|
||||
In an ideal scenario, the MQTT device will have a state topic to publish
|
||||
state changes. If these messages are published with RETAIN flag, the MQTT
|
||||
switch will receive an instant state update after subscription and will
|
||||
start with correct state. Otherwise, the initial state of the switch will
|
||||
be false/off.
|
||||
|
||||
When a state topic is not available, the switch will work in optimistic mode.
|
||||
In this mode, the switch will immediately change state after every command.
|
||||
Otherwise, the switch will wait for state confirmation from device
|
||||
(message from state_topic).
|
||||
|
||||
Optimistic mode can be forced, even if state topic is available.
|
||||
Try to enable it, if experiencing incorrect switch operation.
|
||||
|
||||
|
||||
Configuration:
|
||||
|
||||
switch:
|
||||
platform: mqtt
|
||||
name: "Bedroom Switch"
|
||||
state_topic: "home/bedroom/switch1"
|
||||
command_topic: "home/bedroom/switch1/set"
|
||||
qos: 0
|
||||
payload_on: "ON"
|
||||
payload_off: "OFF"
|
||||
optimistic: false
|
||||
|
||||
Variables:
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the switch. Default is 'MQTT Switch'.
|
||||
|
||||
state_topic
|
||||
*Optional
|
||||
The MQTT topic subscribed to receive state updates.
|
||||
If not specified, optimistic mode will be forced.
|
||||
|
||||
command_topic
|
||||
*Required
|
||||
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
|
||||
*Optional
|
||||
The payload that represents enabled state. Default is "ON".
|
||||
|
||||
payload_off
|
||||
*Optional
|
||||
The payload that represents disabled state. Default is "OFF".
|
||||
|
||||
optimistic
|
||||
*Optional
|
||||
Flag that defines if switch works in optimistic mode. Default is false.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.mqtt.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
@ -82,7 +23,7 @@ DEPENDENCIES = ['mqtt']
|
|||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Add MQTT Switch """
|
||||
""" Add MQTT Switch. """
|
||||
|
||||
if config.get('command_topic') is None:
|
||||
_LOGGER.error("Missing required variable: command_topic")
|
||||
|
@ -101,7 +42,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
|
||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||
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, qos,
|
||||
payload_on, payload_off, optimistic):
|
||||
self._state = False
|
||||
|
@ -133,12 +74,12 @@ class MqttSwitch(SwitchDevice):
|
|||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" No polling needed """
|
||||
""" No polling needed. """
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of the switch """
|
||||
""" The name of the switch. """
|
||||
return self._name
|
||||
|
||||
@property
|
||||
|
|
127
homeassistant/components/switch/rest.py
Normal file
127
homeassistant/components/switch/rest.py
Normal file
|
@ -0,0 +1,127 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
homeassistant.components.switch.rest
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to configure a REST switch.
|
||||
|
||||
Configuration:
|
||||
|
||||
switch:
|
||||
platform: rest
|
||||
name: "Bedroom Switch"
|
||||
resource: "http://IP_ADDRESS/ENDPOINT"
|
||||
body_on: "ON"
|
||||
body_off: "OFF"
|
||||
|
||||
Variables:
|
||||
|
||||
resource
|
||||
*Required*
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name of the switch. Default is 'REST Switch'.
|
||||
|
||||
body_on
|
||||
*Optional
|
||||
The body that represents enabled state. Default is "ON".
|
||||
|
||||
body_off
|
||||
*Optional
|
||||
The body that represents disabled state. Default is "OFF".
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
import requests
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_NAME = "REST Switch"
|
||||
DEFAULT_BODY_ON = "ON"
|
||||
DEFAULT_BODY_OFF = "OFF"
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Add REST Switch """
|
||||
|
||||
resource = config.get('resource')
|
||||
|
||||
if resource is None:
|
||||
_LOGGER.error("Missing required variable: resource")
|
||||
return False
|
||||
|
||||
try:
|
||||
requests.get(resource, timeout=10)
|
||||
except requests.exceptions.MissingSchema:
|
||||
_LOGGER.error("Missing resource or schema in configuration. "
|
||||
"Add http:// to your URL.")
|
||||
return False
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.error("No route to device. "
|
||||
"Please check the IP address in the configuration file.")
|
||||
return False
|
||||
|
||||
add_devices_callback([RestSwitch(
|
||||
hass,
|
||||
config.get('name', DEFAULT_NAME),
|
||||
config.get('resource'),
|
||||
config.get('body_on', DEFAULT_BODY_ON),
|
||||
config.get('body_off', DEFAULT_BODY_OFF))])
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
class RestSwitch(SwitchDevice):
|
||||
""" Represents a switch that can be togggled using REST """
|
||||
def __init__(self, hass, name, resource, body_on, body_off):
|
||||
self._state = None
|
||||
self._hass = hass
|
||||
self._name = name
|
||||
self._resource = resource
|
||||
self._body_on = body_on
|
||||
self._body_off = body_off
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of the switch. """
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
""" True if device is on. """
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
""" Turn the device on. """
|
||||
request = requests.post(self._resource,
|
||||
data=self._body_on,
|
||||
timeout=10)
|
||||
if request.status_code == 200:
|
||||
self._state = True
|
||||
else:
|
||||
_LOGGER.error("Can't turn on %s. Is device offline?",
|
||||
self._resource)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
""" Turn the device off. """
|
||||
request = requests.post(self._resource,
|
||||
data=self._body_off,
|
||||
timeout=10)
|
||||
if request.status_code == 200:
|
||||
self._state = False
|
||||
else:
|
||||
_LOGGER.error("Can't turn off %s. Is device offline?",
|
||||
self._resource)
|
||||
|
||||
def update(self):
|
||||
""" Gets the latest data from REST API and updates the state. """
|
||||
request = requests.get(self._resource, timeout=10)
|
||||
if request.text == self._body_on:
|
||||
self._state = True
|
||||
elif request.text == self._body_off:
|
||||
self._state = False
|
||||
else:
|
||||
self._state = None
|
|
@ -3,31 +3,9 @@ homeassistant.components.switch.rpi_gpio
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Allows to control the GPIO pins of a Raspberry Pi.
|
||||
|
||||
Note: To use RPi GPIO, Home Assistant must be run as root.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Raspberry GPIO switches you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: rpi_gpio
|
||||
invert_logic: false
|
||||
ports:
|
||||
11: Fan Office
|
||||
12: Light Desk
|
||||
|
||||
Variables:
|
||||
|
||||
invert_logic
|
||||
*Optional
|
||||
If true, inverts the output logic to ACTIVE LOW. Default is false (ACTIVE HIGH)
|
||||
|
||||
ports
|
||||
*Required
|
||||
An array specifying the GPIO ports to use and the name to use in the frontend.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.rpi_gpio.html
|
||||
"""
|
||||
|
||||
import logging
|
||||
try:
|
||||
import RPi.GPIO as GPIO
|
||||
|
|
|
@ -3,11 +3,8 @@ homeassistant.components.switch.tellstick
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Tellstick switches.
|
||||
|
||||
Because the tellstick sends its actions via radio and from most
|
||||
receivers it's impossible to know if the signal was received or not.
|
||||
Therefore you can configure the switch to try to send each signal repeatedly
|
||||
with the config parameter signal_repetitions (default is 1).
|
||||
signal_repetitions: 3
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.tellstick.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -16,9 +13,10 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
|
|||
from homeassistant.helpers.entity import ToggleEntity
|
||||
import tellcore.constants as tellcore_constants
|
||||
from tellcore.library import DirectCallbackDispatcher
|
||||
SINGAL_REPETITIONS = 1
|
||||
|
||||
SIGNAL_REPETITIONS = 1
|
||||
REQUIREMENTS = ['tellcore-py==1.1.2']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
@ -27,13 +25,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
try:
|
||||
import tellcore.telldus as telldus
|
||||
except ImportError:
|
||||
logging.getLogger(__name__).exception(
|
||||
"Failed to import tellcore")
|
||||
_LOGGER.exception("Failed to import tellcore")
|
||||
return
|
||||
|
||||
core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher())
|
||||
|
||||
signal_repetitions = config.get('signal_repetitions', SINGAL_REPETITIONS)
|
||||
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
||||
|
||||
switches_and_lights = core.devices()
|
||||
|
||||
|
|
|
@ -3,40 +3,8 @@ homeassistant.components.switch.transmission
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Enable or disable Transmission BitTorrent client Turtle Mode.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Transmission switch you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: transmission
|
||||
name: Transmission
|
||||
host: 192.168.1.26
|
||||
port: 9091
|
||||
username: YOUR_USERNAME
|
||||
password: YOUR_PASSWORD
|
||||
|
||||
Variables:
|
||||
|
||||
host
|
||||
*Required
|
||||
This is the IP address of your Transmission daemon. Example: 192.168.1.32
|
||||
|
||||
port
|
||||
*Optional
|
||||
The port your Transmission daemon uses, defaults to 9091. Example: 8080
|
||||
|
||||
username
|
||||
*Optional
|
||||
Your Transmission username, if you use authentication.
|
||||
|
||||
password
|
||||
*Optional
|
||||
Your Transmission username, if you use authentication.
|
||||
|
||||
name
|
||||
*Optional
|
||||
The name to use when displaying this Transmission instance.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.transmission.html
|
||||
"""
|
||||
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
|
||||
from homeassistant.const import STATE_ON, STATE_OFF
|
||||
|
|
|
@ -3,46 +3,8 @@ homeassistant.components.switch.vera
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Vera switches.
|
||||
|
||||
Configuration:
|
||||
To use the Vera lights you will need to add something like the following to
|
||||
your configuration.yaml file.
|
||||
|
||||
switch:
|
||||
platform: vera
|
||||
vera_controller_url: http://YOUR_VERA_IP:3480/
|
||||
device_data:
|
||||
12:
|
||||
name: My awesome switch
|
||||
exclude: true
|
||||
13:
|
||||
name: Another Switch
|
||||
|
||||
Variables:
|
||||
|
||||
vera_controller_url
|
||||
*Required
|
||||
This is the base URL of your vera controller including the port number if not
|
||||
running on 80. Example: http://192.168.1.21:3480/
|
||||
|
||||
device_data
|
||||
*Optional
|
||||
This contains an array additional device info for your Vera devices. It is not
|
||||
required and if not specified all lights configured in your Vera controller
|
||||
will be added with default values. You should use the id of your vera device
|
||||
as the key for the device within device_data.
|
||||
|
||||
These are the variables for the device_data array:
|
||||
|
||||
name
|
||||
*Optional
|
||||
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
|
||||
will be used.
|
||||
|
||||
exclude
|
||||
*Optional
|
||||
This parameter allows you to exclude the specified device from homeassistant,
|
||||
it should be set to "true" if you want this device excluded.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.vera.html
|
||||
"""
|
||||
import logging
|
||||
import time
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.switch.wemo
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Support for WeMo switches.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.wemo.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -10,6 +12,7 @@ from homeassistant.components.switch import SwitchDevice
|
|||
from homeassistant.const import STATE_ON, STATE_OFF, STATE_STANDBY
|
||||
|
||||
REQUIREMENTS = ['pywemo==0.3.1']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
@ -26,7 +29,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
|
||||
return
|
||||
|
||||
logging.getLogger(__name__).info("Scanning for WeMo devices")
|
||||
_LOGGER.info("Scanning for WeMo devices.")
|
||||
switches = pywemo.discover_devices()
|
||||
|
||||
# Filter out the switches and wrap in WemoSwitch object
|
||||
|
@ -132,5 +135,4 @@ class WemoSwitch(SwitchDevice):
|
|||
elif self.wemo.model_name == 'Maker':
|
||||
self.maker_params = self.wemo.maker_params
|
||||
except AttributeError:
|
||||
logging.getLogger(__name__).warning(
|
||||
'Could not update status for %s', self.name)
|
||||
_LOGGER.warning('Could not update status for %s', self.name)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.switch.wink
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Support for Wink switches.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.wink.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -23,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
if token is None:
|
||||
logging.getLogger(__name__).error(
|
||||
"Missing wink access_token - "
|
||||
"get one at https://winkbearertoken.appspot.com/")
|
||||
"Missing wink access_token. "
|
||||
"Get one at https://winkbearertoken.appspot.com/")
|
||||
return
|
||||
|
||||
pywink.set_bearer_token(token)
|
||||
|
|
|
@ -14,7 +14,8 @@ import homeassistant.util as util
|
|||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.temperature import convert
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, TEMP_CELCIUS)
|
||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, STATE_UNKNOWN,
|
||||
TEMP_CELCIUS)
|
||||
|
||||
DOMAIN = "thermostat"
|
||||
DEPENDENCIES = []
|
||||
|
@ -125,7 +126,7 @@ class ThermostatDevice(Entity):
|
|||
@property
|
||||
def state(self):
|
||||
""" Returns the current state. """
|
||||
return self.target_temperature
|
||||
return self.target_temperature or STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -1,216 +1,155 @@
|
|||
"""
|
||||
homeassistant.components.thermostat.heat_control
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for a thermostat.
|
||||
|
||||
Specify a start time, end time and a target temperature.
|
||||
If the the current temperature is lower than the target temperature,
|
||||
and the time is between start time and end time, the heater will
|
||||
be turned on. Opposite if the the temperature is higher than the
|
||||
target temperature the heater will be turned off.
|
||||
|
||||
If away mode is activated the target temperature is sat to a min
|
||||
temperature (min_temp in config). The min temperature is also used
|
||||
as target temperature when no other temperature is specified.
|
||||
|
||||
If the heater is manually turned on, the target temperature will
|
||||
be sat to 100*C. Meaning the thermostat probably will never turn
|
||||
off the heater.
|
||||
If the heater is manually turned off, the target temperature will
|
||||
be sat according to normal rules. (Based on target temperature
|
||||
for given time intervals and the min temperature.)
|
||||
|
||||
A target temperature sat with the set_temperature function will
|
||||
override all other rules for the target temperature.
|
||||
|
||||
Config:
|
||||
|
||||
[thermostat]
|
||||
platform=heat_control
|
||||
|
||||
name = Name of thermostat
|
||||
|
||||
heater = entity_id for heater switch,
|
||||
must be a toggle device
|
||||
|
||||
target_sensor = entity_id for temperature sensor,
|
||||
target_sensor.state must be temperature
|
||||
|
||||
time_temp = start_time-end_time:target_temp,
|
||||
|
||||
min_temp = minimum temperature, used when away mode is
|
||||
active or no other temperature specified.
|
||||
|
||||
Example:
|
||||
[thermostat]
|
||||
platform=heat_control
|
||||
name = Stue
|
||||
heater = switch.Ovn_stue
|
||||
target_sensor = tellstick_sensor.Stue_temperature
|
||||
time_temp = 0700-0745:17,1500-1850:20
|
||||
min_temp = 10
|
||||
|
||||
For the example the heater will turn on at 0700 if the temperature
|
||||
is lower than 17*C away mode is false. Between 0700 and 0745 the
|
||||
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
|
||||
the target temperature is 20*, but if away mode is true the target
|
||||
temperature will be sat to 10*C
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.heat_control.html
|
||||
"""
|
||||
import logging
|
||||
import datetime
|
||||
import homeassistant.components as core
|
||||
|
||||
import homeassistant.util as util
|
||||
from homeassistant.components.thermostat import ThermostatDevice
|
||||
from homeassistant.components import switch
|
||||
from homeassistant.components.thermostat import (ThermostatDevice, STATE_IDLE,
|
||||
STATE_HEAT)
|
||||
from homeassistant.helpers.event import track_state_change
|
||||
from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
||||
|
||||
DEPENDENCIES = ['switch', 'sensor']
|
||||
|
||||
TOL_TEMP = 0.3
|
||||
|
||||
CONF_NAME = 'name'
|
||||
DEFAULT_NAME = 'Heat Control'
|
||||
CONF_HEATER = 'heater'
|
||||
CONF_SENSOR = 'target_sensor'
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the heat control thermostat. """
|
||||
logger = logging.getLogger(__name__)
|
||||
name = config.get(CONF_NAME, DEFAULT_NAME)
|
||||
heater_entity_id = config.get(CONF_HEATER)
|
||||
sensor_entity_id = config.get(CONF_SENSOR)
|
||||
|
||||
add_devices([HeatControl(hass, config, logger)])
|
||||
if None in (heater_entity_id, sensor_entity_id):
|
||||
_LOGGER.error('Missing required key %s or %s', CONF_HEATER,
|
||||
CONF_SENSOR)
|
||||
return False
|
||||
|
||||
add_devices([HeatControl(hass, name, heater_entity_id, sensor_entity_id)])
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class HeatControl(ThermostatDevice):
|
||||
""" Represents a HeatControl device. """
|
||||
|
||||
def __init__(self, hass, config, logger):
|
||||
|
||||
self.logger = logger
|
||||
def __init__(self, hass, name, heater_entity_id, sensor_entity_id):
|
||||
self.hass = hass
|
||||
self.heater_entity_id = config.get("heater")
|
||||
self._name = name
|
||||
self.heater_entity_id = heater_entity_id
|
||||
|
||||
self.name_device = config.get("name")
|
||||
self.target_sensor_entity_id = config.get("target_sensor")
|
||||
self._active = False
|
||||
self._cur_temp = None
|
||||
self._target_temp = None
|
||||
self._unit = None
|
||||
|
||||
self.time_temp = []
|
||||
if config.get("time_temp"):
|
||||
for time_temp in list(config.get("time_temp").split(",")):
|
||||
time, temp = time_temp.split(':')
|
||||
time_start, time_end = time.split('-')
|
||||
start_time = datetime.datetime.time(
|
||||
datetime.datetime.strptime(time_start, '%H%M'))
|
||||
end_time = datetime.datetime.time(
|
||||
datetime.datetime.strptime(time_end, '%H%M'))
|
||||
self.time_temp.append((start_time, end_time, float(temp)))
|
||||
track_state_change(hass, sensor_entity_id, self._sensor_changed)
|
||||
|
||||
self._min_temp = util.convert(config.get("min_temp"), float, 0)
|
||||
self._max_temp = util.convert(config.get("max_temp"), float, 100)
|
||||
sensor_state = hass.states.get(sensor_entity_id)
|
||||
if sensor_state:
|
||||
self._update_temp(sensor_state)
|
||||
|
||||
self._manual_sat_temp = None
|
||||
self._away = False
|
||||
self._heater_manual_changed = True
|
||||
|
||||
track_state_change(hass, self.heater_entity_id,
|
||||
self._heater_turned_on,
|
||||
STATE_OFF, STATE_ON)
|
||||
track_state_change(hass, self.heater_entity_id,
|
||||
self._heater_turned_off,
|
||||
STATE_ON, STATE_OFF)
|
||||
@property
|
||||
def should_poll(self):
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name. """
|
||||
return self.name_device
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Returns the unit of measurement. """
|
||||
return TEMP_CELCIUS
|
||||
return self._unit
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
target_sensor = self.hass.states.get(self.target_sensor_entity_id)
|
||||
if target_sensor:
|
||||
return float(target_sensor.state)
|
||||
else:
|
||||
return None
|
||||
return self._cur_temp
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns current operation ie. heat, cool, idle """
|
||||
return STATE_HEAT if self._active and self._is_heating else STATE_IDLE
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
if self._manual_sat_temp:
|
||||
return self._manual_sat_temp
|
||||
elif self._away:
|
||||
return self.min_temp
|
||||
else:
|
||||
now = datetime.datetime.time(datetime.datetime.now())
|
||||
for (start_time, end_time, temp) in self.time_temp:
|
||||
if start_time < now and end_time > now:
|
||||
return temp
|
||||
return self.min_temp
|
||||
return self._target_temp
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature. """
|
||||
if temperature is None:
|
||||
self._manual_sat_temp = None
|
||||
else:
|
||||
self._manual_sat_temp = float(temperature)
|
||||
self._target_temp = temperature
|
||||
self._control_heating()
|
||||
self.update_ha_state()
|
||||
|
||||
def update(self):
|
||||
""" Update current thermostat. """
|
||||
heater = self.hass.states.get(self.heater_entity_id)
|
||||
if heater is None:
|
||||
self.logger.error("No heater available")
|
||||
def _sensor_changed(self, entity_id, old_state, new_state):
|
||||
""" Called when temperature changes. """
|
||||
if new_state is None:
|
||||
return
|
||||
|
||||
current_temperature = self.current_temperature
|
||||
if current_temperature is None:
|
||||
self.logger.error("No temperature available")
|
||||
self._update_temp(new_state)
|
||||
self._control_heating()
|
||||
self.update_ha_state()
|
||||
|
||||
def _update_temp(self, state):
|
||||
""" Update thermostat with latest state from sensor. """
|
||||
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||
|
||||
if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT):
|
||||
self._cur_temp = None
|
||||
self._unit = None
|
||||
_LOGGER.error('Sensor has unsupported unit: %s (allowed: %s, %s)',
|
||||
unit, TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
||||
return
|
||||
|
||||
if (current_temperature - self.target_temperature) > \
|
||||
TOL_TEMP and heater.state is STATE_ON:
|
||||
self._heater_manual_changed = False
|
||||
core.turn_off(self.hass, self.heater_entity_id)
|
||||
elif (self.target_temperature - self.current_temperature) > TOL_TEMP \
|
||||
and heater.state is STATE_OFF:
|
||||
self._heater_manual_changed = False
|
||||
core.turn_on(self.hass, self.heater_entity_id)
|
||||
temp = util.convert(state.state, float)
|
||||
|
||||
def _heater_turned_on(self, entity_id, old_state, new_state):
|
||||
""" Heater is turned on. """
|
||||
if not self._heater_manual_changed:
|
||||
pass
|
||||
else:
|
||||
self.set_temperature(self.max_temp)
|
||||
if temp is None:
|
||||
self._cur_temp = None
|
||||
self._unit = None
|
||||
_LOGGER.error('Unable to parse sensor temperature: %s',
|
||||
state.state)
|
||||
return
|
||||
|
||||
self._heater_manual_changed = True
|
||||
self._cur_temp = temp
|
||||
self._unit = unit
|
||||
|
||||
def _heater_turned_off(self, entity_id, old_state, new_state):
|
||||
""" Heater is turned off. """
|
||||
if self._heater_manual_changed:
|
||||
self.set_temperature(None)
|
||||
def _control_heating(self):
|
||||
""" Check if we need to turn heating on or off. """
|
||||
if not self._active and None not in (self._cur_temp,
|
||||
self._target_temp):
|
||||
self._active = True
|
||||
_LOGGER.info('Obtained current and target temperature. '
|
||||
'Heat control active.')
|
||||
|
||||
if not self._active:
|
||||
return
|
||||
|
||||
too_cold = self._target_temp - self._cur_temp > TOL_TEMP
|
||||
is_heating = self._is_heating
|
||||
|
||||
if too_cold and not is_heating:
|
||||
_LOGGER.info('Turning on heater %s', self.heater_entity_id)
|
||||
switch.turn_on(self.hass, self.heater_entity_id)
|
||||
elif not too_cold and is_heating:
|
||||
_LOGGER.info('Turning off heater %s', self.heater_entity_id)
|
||||
switch.turn_off(self.hass, self.heater_entity_id)
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
"""
|
||||
Returns if away mode is on.
|
||||
"""
|
||||
return self._away
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
""" Turns away mode on. """
|
||||
self._away = True
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away mode off. """
|
||||
self._away = False
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
""" Return minimum temperature. """
|
||||
return self._min_temp
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
""" Return maxmum temperature. """
|
||||
return self._max_temp
|
||||
def _is_heating(self):
|
||||
""" If the heater is currently heating. """
|
||||
return switch.is_on(self.hass, self.heater_entity_id)
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.thermostat.nest
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Nest thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.nest.html
|
||||
"""
|
||||
import socket
|
||||
import logging
|
||||
|
@ -44,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
])
|
||||
except socket.error:
|
||||
logger.error(
|
||||
"Connection error logging into the nest web service"
|
||||
"Connection error logging into the nest web service."
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.thermostat.radiotherm
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Radio Thermostat wifi-enabled home thermostats
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Radio Thermostat wifi-enabled home thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.radiotherm.html
|
||||
"""
|
||||
import logging
|
||||
import datetime
|
||||
|
@ -12,33 +15,40 @@ from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
|||
from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT)
|
||||
|
||||
REQUIREMENTS = ['radiotherm==1.2']
|
||||
HOLD_TEMP = 'hold_temp'
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the Radio Thermostat. """
|
||||
import radiotherm
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
try:
|
||||
import radiotherm
|
||||
except ImportError:
|
||||
_LOGGER.exception(
|
||||
"Unable to import radiotherm. "
|
||||
"Did you maybe not install the 'radiotherm' package?")
|
||||
return False
|
||||
|
||||
hosts = []
|
||||
if CONF_HOST in config:
|
||||
hosts = [config[CONF_HOST]]
|
||||
hosts = config[CONF_HOST]
|
||||
else:
|
||||
hosts.append(radiotherm.discover.discover_address())
|
||||
|
||||
if hosts is None:
|
||||
logger.error("no radiotherm thermostats detected")
|
||||
return
|
||||
_LOGGER.error("No radiotherm thermostats detected.")
|
||||
return False
|
||||
|
||||
hold_temp = config.get(HOLD_TEMP, False)
|
||||
tstats = []
|
||||
|
||||
for host in hosts:
|
||||
try:
|
||||
tstat = radiotherm.get_thermostat(host)
|
||||
tstats.append(RadioThermostat(tstat))
|
||||
tstats.append(RadioThermostat(tstat, hold_temp))
|
||||
except (URLError, OSError):
|
||||
logger.exception(
|
||||
"Unable to connect to Radio Thermostat: %s", host)
|
||||
_LOGGER.exception("Unable to connect to Radio Thermostat: %s",
|
||||
host)
|
||||
|
||||
add_devices(tstats)
|
||||
|
||||
|
@ -46,13 +56,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class RadioThermostat(ThermostatDevice):
|
||||
""" Represent a Radio Thermostat. """
|
||||
|
||||
def __init__(self, device):
|
||||
def __init__(self, device, hold_temp):
|
||||
self.device = device
|
||||
self.set_time()
|
||||
self._target_temperature = None
|
||||
self._current_temperature = None
|
||||
self._operation = STATE_IDLE
|
||||
self._name = None
|
||||
self.hold_temp = hold_temp
|
||||
self.update()
|
||||
|
||||
@property
|
||||
|
@ -107,7 +118,10 @@ class RadioThermostat(ThermostatDevice):
|
|||
self.device.t_cool = temperature
|
||||
elif self._operation == STATE_HEAT:
|
||||
self.device.t_heat = temperature
|
||||
self.device.hold = 1
|
||||
if self.hold_temp:
|
||||
self.device.hold = 1
|
||||
else:
|
||||
self.device.hold = 0
|
||||
|
||||
def set_time(self):
|
||||
""" Set device time """
|
||||
|
|
|
@ -3,44 +3,8 @@ components.verisure
|
|||
~~~~~~~~~~~~~~~~~~~
|
||||
Provides support for verisure components.
|
||||
|
||||
Configuration:
|
||||
|
||||
To use the Verisure component you will need to add something like the
|
||||
following to your configuration.yaml file.
|
||||
|
||||
verisure:
|
||||
username: user@example.com
|
||||
password: password
|
||||
alarm: 1
|
||||
hygrometers: 0
|
||||
smartplugs: 1
|
||||
thermometers: 0
|
||||
|
||||
Variables:
|
||||
|
||||
username
|
||||
*Required
|
||||
Username to Verisure mypages.
|
||||
|
||||
password
|
||||
*Required
|
||||
Password to Verisure mypages.
|
||||
|
||||
alarm
|
||||
*Optional
|
||||
Set to 1 to show alarm, 0 to disable. Default 1.
|
||||
|
||||
hygrometers
|
||||
*Optional
|
||||
Set to 1 to show hygrometers, 0 to disable. Default 1.
|
||||
|
||||
smartplugs
|
||||
*Optional
|
||||
Set to 1 to show smartplugs, 0 to disable. Default 1.
|
||||
|
||||
thermometers
|
||||
*Optional
|
||||
Set to 1 to show thermometers, 0 to disable. Default 1.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/verisure.html
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -3,20 +3,8 @@ homeassistant.components.wink
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
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.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/wink.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -71,7 +59,7 @@ def setup(hass, config):
|
|||
|
||||
|
||||
class WinkToggleDevice(ToggleEntity):
|
||||
""" Represents a Wink switch within Home Assistant. """
|
||||
""" Represents a Wink toogle (switch) device. """
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
|
|
|
@ -1,25 +1,10 @@
|
|||
"""
|
||||
homeassistant.components.zone
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Allows defintion of zones in Home Assistant.
|
||||
|
||||
zone:
|
||||
name: School
|
||||
latitude: 32.8773367
|
||||
longitude: -117.2494053
|
||||
# Optional radius in meters (default: 100)
|
||||
radius: 250
|
||||
# Optional icon to show instead of name
|
||||
# See https://www.google.com/design/icons/
|
||||
# Example: home, work, group-work, shopping-cart, social:people
|
||||
icon: group-work
|
||||
|
||||
zone 2:
|
||||
name: Work
|
||||
latitude: 32.8753367
|
||||
longitude: -117.2474053
|
||||
|
||||
For configuration details please visit the documentation for this component at
|
||||
https://home-assistant.io/components/zone.html
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
homeassistant.components.zwave
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Connects Home Assistant to a Z-Wave network.
|
||||
|
||||
For configuration details please visit the documentation for this component at
|
||||
https://home-assistant.io/components/zwave.html
|
||||
"""
|
||||
from pprint import pprint
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import homeassistant.util.temperature as temp_util
|
|||
|
||||
def convert(temperature, unit, to_unit):
|
||||
""" Converts temperature to correct unit. """
|
||||
if unit == to_unit:
|
||||
if unit == to_unit or unit is None or to_unit is None:
|
||||
return temperature
|
||||
elif unit == TEMP_CELCIUS:
|
||||
return temp_util.celcius_to_fahrenheit(temperature)
|
||||
|
|
|
@ -87,7 +87,7 @@ https://github.com/theolind/pymysensors/archive/d4b809c2167650691058d1e29bfd2c4b
|
|||
pynetgear==0.3
|
||||
|
||||
# Netdisco (discovery)
|
||||
netdisco==0.4.2
|
||||
netdisco==0.5
|
||||
|
||||
# Wemo (switch.wemo)
|
||||
pywemo==0.3.1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Sets up and builds python open zwave to be used with Home Assistant
|
||||
# Dependencies that need to be installed:
|
||||
# Dependencies that need to be installed:
|
||||
# apt-get install cython3 libudev-dev python-sphinx python3-setuptools
|
||||
# pip3 install cython
|
||||
# pip3 install "cython<0.23"
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestShellCommand(unittest.TestCase):
|
|||
path = os.path.join(tempdirname, 'called.txt')
|
||||
self.assertTrue(shell_command.setup(self.hass, {
|
||||
'shell_command': {
|
||||
'test_service': "touch {}".format(path)
|
||||
'test_service': "date > {}".format(path)
|
||||
}
|
||||
}))
|
||||
|
||||
|
|
0
tests/components/thermostat/__init__.py
Normal file
0
tests/components/thermostat/__init__.py
Normal file
115
tests/components/thermostat/test_heat_control.py
Normal file
115
tests/components/thermostat/test_heat_control.py
Normal file
|
@ -0,0 +1,115 @@
|
|||
"""
|
||||
tests.components.thermostat.test_heat_control
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests heat control thermostat.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_ON,
|
||||
STATE_OFF,
|
||||
TEMP_CELCIUS,
|
||||
)
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import switch, thermostat
|
||||
|
||||
|
||||
entity = 'thermostat.test'
|
||||
ent_sensor = 'sensor.test'
|
||||
ent_switch = 'switch.test'
|
||||
|
||||
|
||||
class TestThermostatHeatControl(unittest.TestCase):
|
||||
""" Test the Heat Control thermostat. """
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
self.hass = ha.HomeAssistant()
|
||||
self.hass.config.temperature_unit = TEMP_CELCIUS
|
||||
thermostat.setup(self.hass, {'thermostat': {
|
||||
'platform': 'heat_control',
|
||||
'name': 'test',
|
||||
'heater': ent_switch,
|
||||
'target_sensor': ent_sensor
|
||||
}})
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
self.hass.stop()
|
||||
|
||||
def test_setup_defaults_to_unknown(self):
|
||||
self.assertEqual('unknown', self.hass.states.get(entity).state)
|
||||
|
||||
def test_set_target_temp(self):
|
||||
thermostat.set_temperature(self.hass, 30)
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual('30.0', self.hass.states.get(entity).state)
|
||||
|
||||
def test_set_target_temp_turns_on_heater(self):
|
||||
self._setup_switch(False)
|
||||
self._setup_sensor(25)
|
||||
self.hass.pool.block_till_done()
|
||||
thermostat.set_temperature(self.hass, 30)
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
call = self.calls[0]
|
||||
self.assertEqual('switch', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ent_switch, call.data['entity_id'])
|
||||
|
||||
def test_set_target_temp_turns_off_heater(self):
|
||||
self._setup_switch(True)
|
||||
self._setup_sensor(30)
|
||||
self.hass.pool.block_till_done()
|
||||
thermostat.set_temperature(self.hass, 25)
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
call = self.calls[0]
|
||||
self.assertEqual('switch', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ent_switch, call.data['entity_id'])
|
||||
|
||||
def test_set_temp_change_turns_on_heater(self):
|
||||
self._setup_switch(False)
|
||||
thermostat.set_temperature(self.hass, 30)
|
||||
self.hass.pool.block_till_done()
|
||||
self._setup_sensor(25)
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
call = self.calls[0]
|
||||
self.assertEqual('switch', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_ON, call.service)
|
||||
self.assertEqual(ent_switch, call.data['entity_id'])
|
||||
|
||||
def test_temp_change_turns_off_heater(self):
|
||||
self._setup_switch(True)
|
||||
thermostat.set_temperature(self.hass, 25)
|
||||
self.hass.pool.block_till_done()
|
||||
self._setup_sensor(30)
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
call = self.calls[0]
|
||||
self.assertEqual('switch', call.domain)
|
||||
self.assertEqual(SERVICE_TURN_OFF, call.service)
|
||||
self.assertEqual(ent_switch, call.data['entity_id'])
|
||||
|
||||
def _setup_sensor(self, temp, unit=TEMP_CELCIUS):
|
||||
""" Setup the test sensor. """
|
||||
self.hass.states.set(ent_sensor, temp, {
|
||||
ATTR_UNIT_OF_MEASUREMENT: unit
|
||||
})
|
||||
|
||||
def _setup_switch(self, is_on):
|
||||
""" Setup the test switch. """
|
||||
self.hass.states.set(ent_switch, STATE_ON if is_on else STATE_OFF)
|
||||
self.calls = []
|
||||
|
||||
def log_call(call):
|
||||
""" Log service calls. """
|
||||
self.calls.append(call)
|
||||
|
||||
self.hass.services.register('switch', SERVICE_TURN_ON, log_call)
|
||||
self.hass.services.register('switch', SERVICE_TURN_OFF, log_call)
|
Loading…
Add table
Reference in a new issue