mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Merge branch 'dev' of https://github.com/balloob/home-assistant into hyperion
This commit is contained in:
commit
e379e3d902
@ -92,6 +92,7 @@ omit =
|
|||||||
homeassistant/components/switch/command_switch.py
|
homeassistant/components/switch/command_switch.py
|
||||||
homeassistant/components/switch/edimax.py
|
homeassistant/components/switch/edimax.py
|
||||||
homeassistant/components/switch/hikvisioncam.py
|
homeassistant/components/switch/hikvisioncam.py
|
||||||
|
homeassistant/components/switch/rest.py
|
||||||
homeassistant/components/switch/rpi_gpio.py
|
homeassistant/components/switch/rpi_gpio.py
|
||||||
homeassistant/components/switch/transmission.py
|
homeassistant/components/switch/transmission.py
|
||||||
homeassistant/components/switch/wemo.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 install -y --no-install-recommends nmap net-tools && \
|
||||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
# Open Z-Wave disabled because broken
|
RUN apt-get update && \
|
||||||
#RUN apt-get update && \
|
apt-get install -y cython3 libudev-dev && \
|
||||||
# apt-get install -y cython3 libudev-dev && \
|
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||||
# apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
pip3 install "cython<0.23" && \
|
||||||
# pip3 install cython && \
|
script/build_python_openzwave
|
||||||
# scripts/build_python_openzwave
|
|
||||||
|
|
||||||
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
|
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
|
||||||
|
@ -4,26 +4,8 @@ components.arduino
|
|||||||
Arduino component that connects to a directly attached Arduino board which
|
Arduino component that connects to a directly attached Arduino board which
|
||||||
runs with the Firmata firmware.
|
runs with the Firmata firmware.
|
||||||
|
|
||||||
Configuration:
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/arduino.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
|||||||
|
|
||||||
DOMAIN = "discovery"
|
DOMAIN = "discovery"
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
REQUIREMENTS = ['netdisco==0.4.2']
|
REQUIREMENTS = ['netdisco==0.5']
|
||||||
|
|
||||||
SCAN_INTERVAL = 300 # seconds
|
SCAN_INTERVAL = 300 # seconds
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.light.tellstick
|
homeassistant.components.light.tellstick
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Tellstick lights.
|
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
|
import logging
|
||||||
# pylint: disable=no-name-in-module, import-error
|
# pylint: disable=no-name-in-module, import-error
|
||||||
|
@ -1,52 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.light.vera
|
homeassistant.components.light.vera
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Vera lights. This component is useful if you wish for switches
|
Support for Vera lights.
|
||||||
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.
|
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/light.vera.html
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.light.wink
|
homeassistant.components.light.wink
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Wink lights.
|
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
|
import logging
|
||||||
|
|
||||||
|
@ -3,22 +3,8 @@ homeassistant.components.media_player.chromecast
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides functionality to interact with Cast devices on the network.
|
Provides functionality to interact with Cast devices on the network.
|
||||||
|
|
||||||
WARNING: This platform is currently not working due to a changed Cast API.
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.cast.html
|
||||||
Configuration:
|
|
||||||
|
|
||||||
To use the chromecast integration you will need to add something like the
|
|
||||||
following to your configuration.yaml file.
|
|
||||||
|
|
||||||
media_player:
|
|
||||||
platform: chromecast
|
|
||||||
host: 192.168.1.9
|
|
||||||
|
|
||||||
Variables:
|
|
||||||
|
|
||||||
host
|
|
||||||
*Optional
|
|
||||||
Use only if you don't want to scan for devices.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -2,42 +2,9 @@
|
|||||||
homeassistant.components.media_player.denon
|
homeassistant.components.media_player.denon
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides an interface to Denon Network Receivers.
|
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:
|
For more details about this platform, please refer to the documentation at
|
||||||
- As long as this module is active and connected, the receiver does
|
https://home-assistant.io/components/media_player.denon.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import telnetlib
|
import telnetlib
|
||||||
import logging
|
import logging
|
||||||
@ -67,13 +34,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
CONF_HOST)
|
CONF_HOST)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
add_devices([
|
denon = DenonDevice(
|
||||||
DenonDevice(
|
config.get("name", "Music station"),
|
||||||
config.get('name', 'Music station'),
|
config.get("host")
|
||||||
config.get('host'))
|
)
|
||||||
])
|
if denon.update():
|
||||||
|
add_devices([denon])
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class DenonDevice(MediaPlayerDevice):
|
class DenonDevice(MediaPlayerDevice):
|
||||||
@ -84,28 +53,41 @@ class DenonDevice(MediaPlayerDevice):
|
|||||||
def __init__(self, name, host):
|
def __init__(self, name, host):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._host = host
|
self._host = host
|
||||||
self._telnet = telnetlib.Telnet(self._host)
|
self._pwstate = "PWSTANDBY"
|
||||||
|
self._volume = 0
|
||||||
|
self._muted = False
|
||||||
|
self._mediasource = ""
|
||||||
|
|
||||||
def query(self, message):
|
@classmethod
|
||||||
""" Send request and await response from server """
|
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:
|
try:
|
||||||
# unspecified command, should be ignored
|
telnet = telnetlib.Telnet(self._host)
|
||||||
self._telnet.write("?".encode('UTF-8') + b'\r')
|
except ConnectionRefusedError:
|
||||||
except (EOFError, BrokenPipeError, ConnectionResetError):
|
return False
|
||||||
self._telnet.open(self._host)
|
|
||||||
|
|
||||||
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')
|
volume_str = self.telnet_request(telnet, "MV?")[len("MV"):]
|
||||||
# timeout 200ms, defined by protocol
|
self._volume = int(volume_str) / 60
|
||||||
resp = self._telnet.read_until(b'\r', timeout=0.2)\
|
self._muted = (self.telnet_request(telnet, "MU?") == "MUON")
|
||||||
.decode('UTF-8').strip()
|
self._mediasource = self.telnet_request(telnet, "SI?")[len("SI"):]
|
||||||
|
|
||||||
if message == "PW?":
|
telnet.close()
|
||||||
# workaround; PW? sends also SISTATUS
|
return True
|
||||||
self._telnet.read_until(b'\r', timeout=0.2)
|
|
||||||
|
|
||||||
return resp
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -115,10 +97,9 @@ class DenonDevice(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
pwstate = self.query('PW?')
|
if self._pwstate == "PWSTANDBY":
|
||||||
if pwstate == "PWSTANDBY":
|
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
if pwstate == "PWON":
|
if self._pwstate == "PWON":
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
@ -126,17 +107,17 @@ class DenonDevice(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def volume_level(self):
|
def volume_level(self):
|
||||||
""" Volume level of the media player (0..1). """
|
""" Volume level of the media player (0..1). """
|
||||||
return int(self.query('MV?')[len('MV'):]) / 60
|
return self._volume
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
""" Boolean if volume is currently muted. """
|
""" Boolean if volume is currently muted. """
|
||||||
return self.query('MU?') == "MUON"
|
return self._muted
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
""" Current media source. """
|
""" Current media source. """
|
||||||
return self.query('SI?')[len('SI'):]
|
return self._mediasource
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_media_commands(self):
|
def supported_media_commands(self):
|
||||||
@ -145,24 +126,24 @@ class DenonDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self):
|
||||||
""" turn_off media player. """
|
""" turn_off media player. """
|
||||||
self.query('PWSTANDBY')
|
self.telnet_command("PWSTANDBY")
|
||||||
|
|
||||||
def volume_up(self):
|
def volume_up(self):
|
||||||
""" volume_up media player. """
|
""" volume_up media player. """
|
||||||
self.query('MVUP')
|
self.telnet_command("MVUP")
|
||||||
|
|
||||||
def volume_down(self):
|
def volume_down(self):
|
||||||
""" volume_down media player. """
|
""" volume_down media player. """
|
||||||
self.query('MVDOWN')
|
self.telnet_command("MVDOWN")
|
||||||
|
|
||||||
def set_volume_level(self, volume):
|
def set_volume_level(self, volume):
|
||||||
""" set volume level, range 0..1. """
|
""" set volume level, range 0..1. """
|
||||||
# 60dB max
|
# 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):
|
def mute_volume(self, mute):
|
||||||
""" mute (true) or unmute (false) media player. """
|
""" 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):
|
def media_play_pause(self):
|
||||||
""" media_play_pause media player. """
|
""" media_play_pause media player. """
|
||||||
@ -170,22 +151,22 @@ class DenonDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
def media_play(self):
|
def media_play(self):
|
||||||
""" media_play media player. """
|
""" media_play media player. """
|
||||||
self.query('NS9A')
|
self.telnet_command("NS9A")
|
||||||
|
|
||||||
def media_pause(self):
|
def media_pause(self):
|
||||||
""" media_pause media player. """
|
""" media_pause media player. """
|
||||||
self.query('NS9B')
|
self.telnet_command("NS9B")
|
||||||
|
|
||||||
def media_next_track(self):
|
def media_next_track(self):
|
||||||
""" Send next track command. """
|
""" Send next track command. """
|
||||||
self.query('NS9D')
|
self.telnet_command("NS9D")
|
||||||
|
|
||||||
def media_previous_track(self):
|
def media_previous_track(self):
|
||||||
self.query('NS9E')
|
self.telnet_command("NS9E")
|
||||||
|
|
||||||
def media_seek(self, position):
|
def media_seek(self, position):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self):
|
||||||
""" turn the media player on. """
|
""" turn the media player on. """
|
||||||
self.query('PWON')
|
self.telnet_command("PWON")
|
||||||
|
@ -1,47 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.media_player.firetv
|
homeassistant.components.media_player.firetv
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Provides functionality to interact with FireTV devices.
|
||||||
|
|
||||||
Provides control over an Amazon Fire TV (/stick) via
|
For more details about this platform, please refer to the documentation at
|
||||||
python-firetv, a Python 2.x module with a helper script
|
https://home-assistant.io/components/media_player.firetv.html
|
||||||
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)
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -69,7 +33,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the firetv platform. """
|
""" Sets up the FireTV platform. """
|
||||||
host = config.get('host', 'localhost:5556')
|
host = config.get('host', 'localhost:5556')
|
||||||
device_id = config.get('device', 'default')
|
device_id = config.get('device', 'default')
|
||||||
try:
|
try:
|
||||||
@ -94,12 +58,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class FireTV(object):
|
class FireTV(object):
|
||||||
""" firetv-server client.
|
""" firetv-server client.
|
||||||
|
|
||||||
Should a native Python 3 ADB module become available,
|
Should a native Python 3 ADB module become available, python-firetv can
|
||||||
python-firetv can support Python 3, it can be added
|
support Python 3, it can be added as a dependency, and this class can be
|
||||||
as a dependency, and this class can be dispensed of.
|
dispensed of.
|
||||||
|
|
||||||
For now, it acts as a client to the firetv-server
|
For now, it acts as a client to the firetv-server HTTP server (which must
|
||||||
HTTP server (which must be running via Python 2).
|
be running via Python 2).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host, device_id):
|
def __init__(self, host, device_id):
|
||||||
@ -108,10 +72,7 @@ class FireTV(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Get the device state.
|
""" Get the device state. An exception means UNKNOWN state. """
|
||||||
|
|
||||||
An exception means UNKNOWN state.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
DEVICE_STATE_URL.format(
|
DEVICE_STATE_URL.format(
|
||||||
@ -126,11 +87,7 @@ class FireTV(object):
|
|||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
|
|
||||||
def action(self, action_id):
|
def action(self, action_id):
|
||||||
""" Perform an action on the device.
|
""" Perform an action on the device. """
|
||||||
|
|
||||||
There is no action acknowledgment, so exceptions
|
|
||||||
result in a pass.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
requests.get(
|
requests.get(
|
||||||
DEVICE_ACTION_URL.format(
|
DEVICE_ACTION_URL.format(
|
||||||
@ -193,7 +150,7 @@ class FireTVDevice(MediaPlayerDevice):
|
|||||||
self._firetv.action('turn_off')
|
self._firetv.action('turn_off')
|
||||||
|
|
||||||
def media_play(self):
|
def media_play(self):
|
||||||
""" Send play commmand. """
|
""" Send play command. """
|
||||||
self._firetv.action('media_play')
|
self._firetv.action('media_play')
|
||||||
|
|
||||||
def media_pause(self):
|
def media_pause(self):
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.media_player.itunes
|
homeassistant.components.media_player.itunes
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides an interface to iTunes-API (https://github.com/maddox/itunes-api)
|
Provides an interface to 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
|
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.itunes.html
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -157,11 +131,9 @@ class Itunes(object):
|
|||||||
path = '/airplay_devices/' + device_id + '/volume'
|
path = '/airplay_devices/' + device_id + '/volume'
|
||||||
return self._request('PUT', path, {'level': level})
|
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
|
# pylint: disable=too-many-instance-attributes
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the itunes platform. """
|
""" Sets up the itunes platform. """
|
||||||
|
|
||||||
@ -179,7 +151,6 @@ class ItunesDevice(MediaPlayerDevice):
|
|||||||
""" Represents a iTunes-API instance. """
|
""" Represents a iTunes-API instance. """
|
||||||
|
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
|
|
||||||
def __init__(self, name, host, port, add_devices):
|
def __init__(self, name, host, port, add_devices):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._host = host
|
self._host = host
|
||||||
|
@ -3,35 +3,8 @@ homeassistant.components.media_player.kodi
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides an interface to the XBMC/Kodi JSON-RPC API
|
Provides an interface to the XBMC/Kodi JSON-RPC API
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.kodi.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import urllib
|
import urllib
|
||||||
import logging
|
import logging
|
||||||
|
@ -3,35 +3,8 @@ homeassistant.components.media_player.mpd
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides functionality to interact with a Music Player Daemon.
|
Provides functionality to interact with a Music Player Daemon.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.mpd.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.media_player.sonos
|
homeassistant.components.media_player.sonos
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Provides an interface to Sonos players (via SoCo)
|
Provides an interface to Sonos players (via SoCo)
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.sonos.html
|
||||||
To use SoCo, add something like this to your configuration:
|
|
||||||
|
|
||||||
media_player:
|
|
||||||
platform: sonos
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
@ -56,8 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes, too-many-public-methods
|
||||||
# pylint: disable=too-many-public-methods
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
class SonosDevice(MediaPlayerDevice):
|
class SonosDevice(MediaPlayerDevice):
|
||||||
""" Represents a Sonos device. """
|
""" Represents a Sonos device. """
|
||||||
@ -74,7 +67,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def update_sonos(self, now):
|
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)
|
self.update_ha_state(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -162,31 +155,31 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
return SUPPORT_SONOS
|
return SUPPORT_SONOS
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self):
|
||||||
""" turn_off media player. """
|
""" Turn off media player. """
|
||||||
self._player.pause()
|
self._player.pause()
|
||||||
|
|
||||||
def volume_up(self):
|
def volume_up(self):
|
||||||
""" volume_up media player. """
|
""" Volume up media player. """
|
||||||
self._player.volume += 1
|
self._player.volume += 1
|
||||||
|
|
||||||
def volume_down(self):
|
def volume_down(self):
|
||||||
""" volume_down media player. """
|
""" Volume down media player. """
|
||||||
self._player.volume -= 1
|
self._player.volume -= 1
|
||||||
|
|
||||||
def set_volume_level(self, volume):
|
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))
|
self._player.volume = str(int(volume * 100))
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
""" mute (true) or unmute (false) media player. """
|
""" Mute (true) or unmute (false) media player. """
|
||||||
self._player.mute = mute
|
self._player.mute = mute
|
||||||
|
|
||||||
def media_play(self):
|
def media_play(self):
|
||||||
""" media_play media player. """
|
""" Send paly command. """
|
||||||
self._player.play()
|
self._player.play()
|
||||||
|
|
||||||
def media_pause(self):
|
def media_pause(self):
|
||||||
""" media_pause media player. """
|
""" Send pause command. """
|
||||||
self._player.pause()
|
self._player.pause()
|
||||||
|
|
||||||
def media_next_track(self):
|
def media_next_track(self):
|
||||||
@ -202,5 +195,5 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
self._player.seek(str(datetime.timedelta(seconds=int(position))))
|
self._player.seek(str(datetime.timedelta(seconds=int(position))))
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self):
|
||||||
""" turn the media player on. """
|
""" Turn the media player on. """
|
||||||
self._player.play()
|
self._player.play()
|
||||||
|
@ -1,39 +1,11 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.media_player.squeezebox
|
homeassistant.components.media_player.squeezebox
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides an interface to the Logitech SqueezeBox API
|
Provides an interface to the Logitech SqueezeBox API
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/media_player.squeezebox.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import telnetlib
|
import telnetlib
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
@ -3,27 +3,8 @@ homeassistant.components.modbus
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Modbus component, using pymodbus (python3 branch).
|
Modbus component, using pymodbus (python3 branch).
|
||||||
|
|
||||||
Configuration:
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/modbus.html
|
||||||
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
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -1,52 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.mqtt
|
homeassistant.components.mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
MQTT component, using paho-mqtt. This component needs a MQTT broker like
|
MQTT component, using paho-mqtt.
|
||||||
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.
|
|
||||||
|
|
||||||
Configuration:
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/mqtt.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -3,7 +3,7 @@ homeassistant.components.rfxtrx
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Provides support for RFXtrx components.
|
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
|
https://home-assistant.io/components/rfxtrx.html
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
@ -4,36 +4,8 @@ homeassistant.components.sensor.arduino
|
|||||||
Support for getting information from Arduino pins. Only analog pins are
|
Support for getting information from Arduino pins. Only analog pins are
|
||||||
supported.
|
supported.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.arduino.html
|
||||||
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'.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -3,41 +3,6 @@ homeassistant.components.sensor.command_sensor
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure custom shell commands to turn a value for a 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
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.command_sensor.html
|
https://home-assistant.io/components/sensor.command_sensor.html
|
||||||
"""
|
"""
|
||||||
@ -133,7 +98,7 @@ class CommandSensorData(object):
|
|||||||
_LOGGER.info('Running command: %s', self.command)
|
_LOGGER.info('Running command: %s', self.command)
|
||||||
|
|
||||||
try:
|
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')
|
self.value = return_value.strip().decode('utf-8')
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
_LOGGER.error('Command failed: %s', self.command)
|
_LOGGER.error('Command failed: %s', self.command)
|
||||||
|
@ -2,39 +2,9 @@
|
|||||||
homeassistant.components.sensor.dht
|
homeassistant.components.sensor.dht
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Adafruit DHT temperature and humidity sensor.
|
Adafruit DHT temperature and humidity sensor.
|
||||||
You need a Python3 compatible version of the Adafruit_Python_DHT library
|
|
||||||
(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:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.dht.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
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
|
Monitors home energy use as measured by an efergy engage hub using its
|
||||||
(unofficial, undocumented) API.
|
(unofficial, undocumented) API.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.efergy.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from requests import get
|
from requests import get
|
||||||
|
@ -3,46 +3,8 @@ homeassistant.components.sensor.forecast
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Forecast.io weather service.
|
Forecast.io weather service.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.forecast.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -55,23 +17,34 @@ except ImportError:
|
|||||||
forecastio = None
|
forecastio = None
|
||||||
|
|
||||||
from homeassistant.util import Throttle
|
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
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Sensor types are defined like so:
|
||||||
|
# Name, si unit, us unit, ca unit, uk unit, uk2 unit
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
'summary': ['Summary', ''],
|
'summary': ['Summary', '', '', '', '', ''],
|
||||||
'precip_type': ['Precip', ''],
|
'icon': ['Icon', '', '', '', '', ''],
|
||||||
'precip_intensity': ['Precip intensity', 'mm'],
|
'nearest_storm_distance': ['Nearest Storm Distance',
|
||||||
'temperature': ['Temperature', ''],
|
'km', 'm', 'km', 'km', 'm'],
|
||||||
'dew_point': ['Dew point', '°C'],
|
'nearest_storm_bearing': ['Nearest Storm Bearing',
|
||||||
'wind_speed': ['Wind Speed', 'm/s'],
|
'°', '°', '°', '°', '°'],
|
||||||
'wind_bearing': ['Wind Bearing', '°'],
|
'precip_type': ['Precip', '', '', '', '', ''],
|
||||||
'cloud_cover': ['Cloud coverage', '%'],
|
'precip_intensity': ['Precip Intensity', 'mm', 'in', 'mm', 'mm', 'mm'],
|
||||||
'humidity': ['Humidity', '%'],
|
'precip_probability': ['Precip Probability', '%', '%', '%', '%', '%'],
|
||||||
'pressure': ['Pressure', 'mBar'],
|
'temperature': ['Temperature', '°C', '°F', '°C', '°C', '°C'],
|
||||||
'visibility': ['Visibility', 'km'],
|
'apparent_temperature': ['Apparent Temperature',
|
||||||
'ozone': ['Ozone', 'DU'],
|
'°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
|
# 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")
|
_LOGGER.error("Latitude or longitude not set in Home Assistant config")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
SENSOR_TYPES['temperature'][1] = hass.config.temperature_unit
|
|
||||||
unit = hass.config.temperature_unit
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
forecast = forecastio.load_forecast(config.get(CONF_API_KEY, None),
|
forecast = forecastio.load_forecast(config.get(CONF_API_KEY, None),
|
||||||
hass.config.latitude,
|
hass.config.latitude,
|
||||||
@ -104,16 +74,24 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"Please check your settings for Forecast.io.")
|
"Please check your settings for Forecast.io.")
|
||||||
return False
|
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),
|
data = ForeCastData(config.get(CONF_API_KEY, None),
|
||||||
hass.config.latitude,
|
hass.config.latitude,
|
||||||
hass.config.longitude)
|
hass.config.longitude,
|
||||||
|
units)
|
||||||
|
|
||||||
dev = []
|
dev = []
|
||||||
for variable in config['monitored_conditions']:
|
for variable in config['monitored_conditions']:
|
||||||
if variable not in SENSOR_TYPES:
|
if variable not in SENSOR_TYPES:
|
||||||
_LOGGER.error('Sensor type: "%s" does not exist', variable)
|
_LOGGER.error('Sensor type: "%s" does not exist', variable)
|
||||||
else:
|
else:
|
||||||
dev.append(ForeCastSensor(data, variable, unit))
|
dev.append(ForeCastSensor(data, variable))
|
||||||
|
|
||||||
add_devices(dev)
|
add_devices(dev)
|
||||||
|
|
||||||
@ -122,14 +100,23 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class ForeCastSensor(Entity):
|
class ForeCastSensor(Entity):
|
||||||
""" Implements an Forecast.io sensor. """
|
""" 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.client_name = 'Weather'
|
||||||
self._name = SENSOR_TYPES[sensor_type][0]
|
self._name = SENSOR_TYPES[sensor_type][0]
|
||||||
self.forecast_client = weather_data
|
self.forecast_client = weather_data
|
||||||
self._unit = unit
|
|
||||||
self.type = sensor_type
|
self.type = sensor_type
|
||||||
self._state = None
|
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()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -146,6 +133,11 @@ class ForeCastSensor(Entity):
|
|||||||
""" Unit of measurement of this entity, if any. """
|
""" Unit of measurement of this entity, if any. """
|
||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_system(self):
|
||||||
|
""" Unit system of this entity. """
|
||||||
|
return self._unit_system
|
||||||
|
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from Forecast.io and updates the states. """
|
""" Gets the latest data from Forecast.io and updates the states. """
|
||||||
@ -156,7 +148,14 @@ class ForeCastSensor(Entity):
|
|||||||
try:
|
try:
|
||||||
if self.type == 'summary':
|
if self.type == 'summary':
|
||||||
self._state = data.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':
|
elif self.type == 'precip_intensity':
|
||||||
|
self._state = data.precipIntensity
|
||||||
if data.precipIntensity == 0:
|
if data.precipIntensity == 0:
|
||||||
self._state = 'None'
|
self._state = 'None'
|
||||||
self._unit_of_measurement = ''
|
self._unit_of_measurement = ''
|
||||||
@ -168,20 +167,14 @@ class ForeCastSensor(Entity):
|
|||||||
self._unit_of_measurement = ''
|
self._unit_of_measurement = ''
|
||||||
else:
|
else:
|
||||||
self._state = data.precipType
|
self._state = data.precipType
|
||||||
|
elif self.type == 'precip_probability':
|
||||||
|
self._state = round(data.precipProbability * 100, 1)
|
||||||
elif self.type == 'dew_point':
|
elif self.type == 'dew_point':
|
||||||
if self._unit == TEMP_CELCIUS:
|
self._state = round(data.dewPoint, 1)
|
||||||
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)
|
|
||||||
elif self.type == 'temperature':
|
elif self.type == 'temperature':
|
||||||
if self._unit == TEMP_CELCIUS:
|
self._state = round(data.temperature, 1)
|
||||||
self._state = round(data.temperature, 1)
|
elif self.type == 'apparent_temperature':
|
||||||
elif self._unit == TEMP_FAHRENHEIT:
|
self._state = round(data.apparentTemperature, 1)
|
||||||
self._state = round(data.temperature * 1.8 + 32.0, 1)
|
|
||||||
else:
|
|
||||||
self._state = round(data.temperature, 1)
|
|
||||||
elif self.type == 'wind_speed':
|
elif self.type == 'wind_speed':
|
||||||
self._state = data.windSpeed
|
self._state = data.windSpeed
|
||||||
elif self.type == 'wind_bearing':
|
elif self.type == 'wind_bearing':
|
||||||
@ -196,6 +189,7 @@ class ForeCastSensor(Entity):
|
|||||||
self._state = data.visibility
|
self._state = data.visibility
|
||||||
elif self.type == 'ozone':
|
elif self.type == 'ozone':
|
||||||
self._state = round(data.ozone, 1)
|
self._state = round(data.ozone, 1)
|
||||||
|
|
||||||
except forecastio.utils.PropertyUnavailable:
|
except forecastio.utils.PropertyUnavailable:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -203,11 +197,14 @@ class ForeCastSensor(Entity):
|
|||||||
class ForeCastData(object):
|
class ForeCastData(object):
|
||||||
""" Gets the latest data from Forecast.io. """
|
""" 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._api_key = api_key
|
||||||
self.latitude = latitude
|
self.latitude = latitude
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
self.data = None
|
self.data = None
|
||||||
|
self.unit_system = None
|
||||||
|
self.units = units
|
||||||
|
self.update()
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
@ -216,5 +213,6 @@ class ForeCastData(object):
|
|||||||
forecast = forecastio.load_forecast(self._api_key,
|
forecast = forecastio.load_forecast(self._api_key,
|
||||||
self.latitude,
|
self.latitude,
|
||||||
self.longitude,
|
self.longitude,
|
||||||
units='si')
|
units=self.units)
|
||||||
self.data = forecast.currently()
|
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.
|
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
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.glances.html
|
https://home-assistant.io/components/sensor.glances.html
|
||||||
"""
|
"""
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.sensor.isy994
|
homeassistant.components.sensor.isy994
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for ISY994 sensors.
|
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
|
import logging
|
||||||
|
|
||||||
|
@ -3,50 +3,8 @@ homeassistant.components.modbus
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Modbus sensors.
|
Support for Modbus sensors.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.modbus.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -1,41 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
homeassistant.components.sensor.mqtt
|
homeassistant.components.sensor.mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure a MQTT sensor.
|
Allows to configure a MQTT sensor.
|
||||||
|
|
||||||
This generic sensor implementation uses the MQTT message payload
|
For more details about this platform, please refer to the documentation at
|
||||||
as the sensor value. If messages in this state_topic are published
|
https://home-assistant.io/components/sensor.mqtt.html
|
||||||
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.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
@ -50,7 +20,7 @@ DEPENDENCIES = ['mqtt']
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Add MQTT Sensor """
|
""" Add MQTT Sensor. """
|
||||||
|
|
||||||
if config.get('state_topic') is None:
|
if config.get('state_topic') is None:
|
||||||
_LOGGER.error("Missing required variable: state_topic")
|
_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
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
class MqttSensor(Entity):
|
class MqttSensor(Entity):
|
||||||
""" Represents a sensor that can be updated using MQTT """
|
""" Represents a sensor that can be updated using MQTT. """
|
||||||
def __init__(self, hass, name, state_topic, qos, unit_of_measurement):
|
def __init__(self, hass, name, state_topic, qos, unit_of_measurement):
|
||||||
self._state = "-"
|
self._state = "-"
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
@ -3,40 +3,8 @@ homeassistant.components.sensor.mysensors
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for MySensors sensors.
|
Support for MySensors sensors.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.mysensors.html
|
||||||
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).
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -3,43 +3,8 @@ homeassistant.components.sensor.openweathermap
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
OpenWeatherMap (OWM) service.
|
OpenWeatherMap (OWM) service.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.openweathermap.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -1,41 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
homeassistant.components.sensor.rpi_gpio
|
homeassistant.components.sensor.rpi_gpio
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure a binary state sensor using RPi GPIO.
|
Allows to configure a binary state sensor using RPi GPIO.
|
||||||
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:
|
For more details about this platform, please refer to the documentation at
|
||||||
platform: rpi_gpio
|
https://home-assistant.io/components/sensor.rpi_gpio.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -4,7 +4,7 @@ homeassistant.components.sensor.sabnzbd
|
|||||||
Monitors SABnzbd NZB client API.
|
Monitors SABnzbd NZB client API.
|
||||||
|
|
||||||
For more details about this platform, please refer to the documentation at
|
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 homeassistant.util import Throttle
|
||||||
from datetime import timedelta
|
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
|
The Swiss public transport sensor will give you the next two departure times
|
||||||
from a given location to another one. This sensor is limited to Switzerland.
|
from a given location to another one. This sensor is limited to Switzerland.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.swiss_public_transport.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -40,6 +18,12 @@ from homeassistant.helpers.entity import Entity
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
_RESOURCE = 'http://transport.opendata.ch/v1/'
|
_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
|
# Return cached results if last scan was less then this time ago
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||||
|
|
||||||
@ -60,8 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
_LOGGER.exception(
|
_LOGGER.exception(
|
||||||
"Unable to determine stations. "
|
"Unable to determine stations. "
|
||||||
"Check your settings and/or the availability of opendata.ch")
|
"Check your settings and/or the availability of opendata.ch")
|
||||||
|
return False
|
||||||
return None
|
|
||||||
|
|
||||||
dev = []
|
dev = []
|
||||||
data = PublicTransportData(journey)
|
data = PublicTransportData(journey)
|
||||||
@ -75,7 +58,9 @@ class SwissPublicTransportSensor(Entity):
|
|||||||
|
|
||||||
def __init__(self, data, journey):
|
def __init__(self, data, journey):
|
||||||
self.data = data
|
self.data = data
|
||||||
self._name = '{}-{}'.format(journey[2], journey[3])
|
self._name = 'Next Departure'
|
||||||
|
self._from = journey[2]
|
||||||
|
self._to = journey[3]
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -88,12 +73,26 @@ class SwissPublicTransportSensor(Entity):
|
|||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
return self._state
|
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
|
# pylint: disable=too-many-branches
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from opendata.ch and updates the states. """
|
""" Gets the latest data from opendata.ch and updates the states. """
|
||||||
times = self.data.update()
|
self.data.update()
|
||||||
|
self._times = self.data.times
|
||||||
try:
|
try:
|
||||||
self._state = ', '.join(times)
|
self._state = self._times[0]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -105,6 +104,7 @@ class PublicTransportData(object):
|
|||||||
def __init__(self, journey):
|
def __init__(self, journey):
|
||||||
self.start = journey[0]
|
self.start = journey[0]
|
||||||
self.destination = journey[1]
|
self.destination = journey[1]
|
||||||
|
self.times = {}
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
@ -117,16 +117,21 @@ class PublicTransportData(object):
|
|||||||
'to=' + self.destination + '&' +
|
'to=' + self.destination + '&' +
|
||||||
'fields[]=connections/from/departureTimestamp/&' +
|
'fields[]=connections/from/departureTimestamp/&' +
|
||||||
'fields[]=connections/',
|
'fields[]=connections/',
|
||||||
timeout=10)
|
timeout=30)
|
||||||
connections = response.json()['connections'][:2]
|
connections = response.json()['connections'][:2]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return [
|
self.times = [
|
||||||
dt_util.datetime_to_time_str(
|
dt_util.datetime_to_time_str(
|
||||||
dt_util.as_local(dt_util.utc_from_timestamp(
|
dt_util.as_local(dt_util.utc_from_timestamp(
|
||||||
item['from']['departureTimestamp']))
|
item['from']['departureTimestamp']))
|
||||||
)
|
)
|
||||||
for item in connections
|
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:
|
except KeyError:
|
||||||
return ['n/a']
|
self.times = ['n/a']
|
||||||
|
@ -3,24 +3,8 @@ homeassistant.components.sensor.tellstick
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Shows sensor values from Tellstick sensors.
|
Shows sensor values from Tellstick sensors.
|
||||||
|
|
||||||
Possible config keys:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.tellstick.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
@ -3,13 +3,8 @@ homeassistant.components.sensor.temper
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for getting temperature from TEMPer devices.
|
Support for getting temperature from TEMPer devices.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.temper.html
|
||||||
To use the temper sensors you will need to add something like the following to
|
|
||||||
your configuration.yaml file.
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
platform: temper
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -3,27 +3,8 @@ homeassistant.components.sensor.time_date
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Date and Time service.
|
Date and Time service.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.time_date.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -3,49 +3,8 @@ homeassistant.components.sensor.transmission
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Monitors Transmission BitTorrent client API.
|
Monitors Transmission BitTorrent client API.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.transmission.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -3,48 +3,8 @@ homeassistant.components.sensor.vera
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Vera sensors.
|
Support for Vera sensors.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/sensor.vera.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.sensor.verisure
|
homeassistant.components.sensor.verisure
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Interfaces with Verisure sensors.
|
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
|
import logging
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.sensor.wink
|
homeassistant.components.sensor.wink
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Wink sensors.
|
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
|
import logging
|
||||||
|
|
||||||
@ -22,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
if token is None:
|
if token is None:
|
||||||
logging.getLogger(__name__).error(
|
logging.getLogger(__name__).error(
|
||||||
"Missing wink access_token - "
|
"Missing wink access_token. "
|
||||||
"get one at https://winkbearertoken.appspot.com/")
|
"Get one at https://winkbearertoken.appspot.com/")
|
||||||
return
|
return
|
||||||
|
|
||||||
pywink.set_bearer_token(token)
|
pywink.set_bearer_token(token)
|
||||||
@ -32,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
|
|
||||||
class WinkSensorDevice(Entity):
|
class WinkSensorDevice(Entity):
|
||||||
""" Represents a wink sensor. """
|
""" Represents a Wink sensor. """
|
||||||
|
|
||||||
def __init__(self, wink):
|
def __init__(self, wink):
|
||||||
self.wink = 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
|
The Worldclock sensor let you display the current time of a different time
|
||||||
zone.
|
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
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.worldclock.html
|
https://home-assistant.io/components/sensor.worldclock.html
|
||||||
"""
|
"""
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.sensor.zwave
|
homeassistant.components.sensor.zwave
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Interfaces with Z-Wave sensors.
|
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
|
# pylint: disable=import-error
|
||||||
from openzwave.network import ZWaveNetwork
|
from openzwave.network import ZWaveNetwork
|
||||||
|
@ -34,7 +34,7 @@ def setup(hass, config):
|
|||||||
def service_handler(call):
|
def service_handler(call):
|
||||||
""" Execute a shell command service. """
|
""" Execute a shell command service. """
|
||||||
try:
|
try:
|
||||||
subprocess.call(conf[call.service].split(' '),
|
subprocess.call(conf[call.service], shell=True,
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
except subprocess.SubprocessError:
|
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
|
Support for switching Arduino pins on and off. So far only digital pins are
|
||||||
supported.
|
supported.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.arduino.html
|
||||||
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'.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -28,8 +28,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
"Add http:// to your URL.")
|
"Add http:// to your URL.")
|
||||||
return False
|
return False
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
_LOGGER.error("No route to device. "
|
_LOGGER.error("No route to device at %s. "
|
||||||
"Please check the IP address in the configuration file.")
|
"Please check the IP address in the configuration file.",
|
||||||
|
resource)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
dev = []
|
dev = []
|
||||||
|
@ -1,37 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
homeassistant.components.switch.command_switch
|
homeassistant.components.switch.command_switch
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure custom shell commands to turn a switch on/off.
|
Allows to configure custom shell commands to turn a switch on/off.
|
||||||
|
|
||||||
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
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/switch.command_switch.html
|
https://home-assistant.io/components/switch.command_switch.html
|
||||||
"""
|
"""
|
||||||
|
@ -3,35 +3,8 @@ homeassistant.components.switch.edimax
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Edimax switches.
|
Support for Edimax switches.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.edimax.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -3,39 +3,8 @@ homeassistant.components.switch.hikvision
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support turning on/off motion detection on Hikvision cameras.
|
Support turning on/off motion detection on Hikvision cameras.
|
||||||
|
|
||||||
Note: Currently works using default https port only.
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.hikvision.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF
|
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):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Setup Hikvision Camera config. """
|
""" Setup Hikvision camera. """
|
||||||
|
|
||||||
host = config.get(CONF_HOST, None)
|
host = config.get(CONF_HOST, None)
|
||||||
port = config.get('port', "80")
|
port = config.get('port', "80")
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.switch.isy994
|
homeassistant.components.switch.isy994
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Support for ISY994 switches.
|
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
|
import logging
|
||||||
|
|
||||||
|
@ -3,35 +3,9 @@ homeassistant.components.switch.modbus
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Modbus switches.
|
Support for Modbus switches.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.modbus.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import homeassistant.components.modbus as modbus
|
import homeassistant.components.modbus as modbus
|
||||||
|
@ -1,70 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
homeassistant.components.switch.mqtt
|
homeassistant.components.switch.mqtt
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Allows to configure a MQTT switch.
|
Allows to configure a MQTT switch.
|
||||||
|
|
||||||
In an ideal scenario, the MQTT device will have a state topic to publish
|
For more details about this platform, please refer to the documentation at
|
||||||
state changes. If these messages are published with RETAIN flag, the MQTT
|
https://home-assistant.io/components/switch.mqtt.html
|
||||||
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.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
@ -82,7 +23,7 @@ DEPENDENCIES = ['mqtt']
|
|||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Add MQTT Switch """
|
""" Add MQTT Switch. """
|
||||||
|
|
||||||
if config.get('command_topic') is None:
|
if config.get('command_topic') is None:
|
||||||
_LOGGER.error("Missing required variable: command_topic")
|
_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
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
class MqttSwitch(SwitchDevice):
|
class MqttSwitch(SwitchDevice):
|
||||||
""" Represents a switch that can be togggled using MQTT """
|
""" Represents a switch that can be togggled using MQTT. """
|
||||||
def __init__(self, hass, name, state_topic, command_topic, qos,
|
def __init__(self, hass, name, state_topic, command_topic, qos,
|
||||||
payload_on, payload_off, optimistic):
|
payload_on, payload_off, optimistic):
|
||||||
self._state = False
|
self._state = False
|
||||||
@ -133,12 +74,12 @@ class MqttSwitch(SwitchDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" No polling needed """
|
""" No polling needed. """
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" The name of the switch """
|
""" The name of the switch. """
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
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.
|
Allows to control the GPIO pins of a Raspberry Pi.
|
||||||
|
|
||||||
Note: To use RPi GPIO, Home Assistant must be run as root.
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.rpi_gpio.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
try:
|
try:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
@ -3,11 +3,8 @@ homeassistant.components.switch.tellstick
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Tellstick switches.
|
Support for Tellstick switches.
|
||||||
|
|
||||||
Because the tellstick sends its actions via radio and from most
|
For more details about this platform, please refer to the documentation at
|
||||||
receivers it's impossible to know if the signal was received or not.
|
https://home-assistant.io/components/switch.tellstick.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -16,9 +13,10 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
|
|||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
import tellcore.constants as tellcore_constants
|
import tellcore.constants as tellcore_constants
|
||||||
from tellcore.library import DirectCallbackDispatcher
|
from tellcore.library import DirectCallbackDispatcher
|
||||||
SINGAL_REPETITIONS = 1
|
|
||||||
|
|
||||||
|
SIGNAL_REPETITIONS = 1
|
||||||
REQUIREMENTS = ['tellcore-py==1.1.2']
|
REQUIREMENTS = ['tellcore-py==1.1.2']
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -27,13 +25,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
try:
|
try:
|
||||||
import tellcore.telldus as telldus
|
import tellcore.telldus as telldus
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logging.getLogger(__name__).exception(
|
_LOGGER.exception("Failed to import tellcore")
|
||||||
"Failed to import tellcore")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher())
|
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()
|
switches_and_lights = core.devices()
|
||||||
|
|
||||||
|
@ -3,40 +3,8 @@ homeassistant.components.switch.transmission
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Enable or disable Transmission BitTorrent client Turtle Mode.
|
Enable or disable Transmission BitTorrent client Turtle Mode.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.transmission.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
|
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF
|
from homeassistant.const import STATE_ON, STATE_OFF
|
||||||
|
@ -3,46 +3,8 @@ homeassistant.components.switch.vera
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Support for Vera switches.
|
Support for Vera switches.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
To use the Vera lights you will need to add something like the following to
|
https://home-assistant.io/components/switch.vera.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.switch.wemo
|
homeassistant.components.switch.wemo
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Support for WeMo switches.
|
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
|
import logging
|
||||||
|
|
||||||
@ -10,6 +12,7 @@ from homeassistant.components.switch import SwitchDevice
|
|||||||
from homeassistant.const import STATE_ON, STATE_OFF, STATE_STANDBY
|
from homeassistant.const import STATE_ON, STATE_OFF, STATE_STANDBY
|
||||||
|
|
||||||
REQUIREMENTS = ['pywemo==0.3.1']
|
REQUIREMENTS = ['pywemo==0.3.1']
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -26,7 +29,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.getLogger(__name__).info("Scanning for WeMo devices")
|
_LOGGER.info("Scanning for WeMo devices.")
|
||||||
switches = pywemo.discover_devices()
|
switches = pywemo.discover_devices()
|
||||||
|
|
||||||
# Filter out the switches and wrap in WemoSwitch object
|
# Filter out the switches and wrap in WemoSwitch object
|
||||||
@ -132,5 +135,4 @@ class WemoSwitch(SwitchDevice):
|
|||||||
elif self.wemo.model_name == 'Maker':
|
elif self.wemo.model_name == 'Maker':
|
||||||
self.maker_params = self.wemo.maker_params
|
self.maker_params = self.wemo.maker_params
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logging.getLogger(__name__).warning(
|
_LOGGER.warning('Could not update status for %s', self.name)
|
||||||
'Could not update status for %s', self.name)
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.switch.wink
|
homeassistant.components.switch.wink
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Support for Wink switches.
|
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
|
import logging
|
||||||
|
|
||||||
@ -23,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
if token is None:
|
if token is None:
|
||||||
logging.getLogger(__name__).error(
|
logging.getLogger(__name__).error(
|
||||||
"Missing wink access_token - "
|
"Missing wink access_token. "
|
||||||
"get one at https://winkbearertoken.appspot.com/")
|
"Get one at https://winkbearertoken.appspot.com/")
|
||||||
return
|
return
|
||||||
|
|
||||||
pywink.set_bearer_token(token)
|
pywink.set_bearer_token(token)
|
||||||
|
@ -14,7 +14,8 @@ import homeassistant.util as util
|
|||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.temperature import convert
|
from homeassistant.helpers.temperature import convert
|
||||||
from homeassistant.const import (
|
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"
|
DOMAIN = "thermostat"
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
@ -125,7 +126,7 @@ class ThermostatDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the current state. """
|
""" Returns the current state. """
|
||||||
return self.target_temperature
|
return self.target_temperature or STATE_UNKNOWN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
@ -1,216 +1,155 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.thermostat.heat_control
|
homeassistant.components.thermostat.heat_control
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Adds support for a thermostat.
|
|
||||||
|
|
||||||
Specify a start time, end time and a target temperature.
|
For more details about this platform, please refer to the documentation at
|
||||||
If the the current temperature is lower than the target temperature,
|
https://home-assistant.io/components/thermostat.heat_control.html
|
||||||
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
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
|
||||||
import homeassistant.components as core
|
|
||||||
|
|
||||||
import homeassistant.util as util
|
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.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
|
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
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the heat control thermostat. """
|
""" 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
|
# pylint: disable=too-many-instance-attributes
|
||||||
class HeatControl(ThermostatDevice):
|
class HeatControl(ThermostatDevice):
|
||||||
""" Represents a HeatControl device. """
|
""" Represents a HeatControl device. """
|
||||||
|
|
||||||
def __init__(self, hass, config, logger):
|
def __init__(self, hass, name, heater_entity_id, sensor_entity_id):
|
||||||
|
|
||||||
self.logger = logger
|
|
||||||
self.hass = hass
|
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._active = False
|
||||||
self.target_sensor_entity_id = config.get("target_sensor")
|
self._cur_temp = None
|
||||||
|
self._target_temp = None
|
||||||
|
self._unit = None
|
||||||
|
|
||||||
self.time_temp = []
|
track_state_change(hass, sensor_entity_id, self._sensor_changed)
|
||||||
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)))
|
|
||||||
|
|
||||||
self._min_temp = util.convert(config.get("min_temp"), float, 0)
|
sensor_state = hass.states.get(sensor_entity_id)
|
||||||
self._max_temp = util.convert(config.get("max_temp"), float, 100)
|
if sensor_state:
|
||||||
|
self._update_temp(sensor_state)
|
||||||
|
|
||||||
self._manual_sat_temp = None
|
@property
|
||||||
self._away = False
|
def should_poll(self):
|
||||||
self._heater_manual_changed = True
|
return False
|
||||||
|
|
||||||
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
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name. """
|
""" Returns the name. """
|
||||||
return self.name_device
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
""" Returns the unit of measurement. """
|
""" Returns the unit of measurement. """
|
||||||
return TEMP_CELCIUS
|
return self._unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
""" Returns the current temperature. """
|
return self._cur_temp
|
||||||
target_sensor = self.hass.states.get(self.target_sensor_entity_id)
|
|
||||||
if target_sensor:
|
@property
|
||||||
return float(target_sensor.state)
|
def operation(self):
|
||||||
else:
|
""" Returns current operation ie. heat, cool, idle """
|
||||||
return None
|
return STATE_HEAT if self._active and self._is_heating else STATE_IDLE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
""" Returns the temperature we try to reach. """
|
""" Returns the temperature we try to reach. """
|
||||||
if self._manual_sat_temp:
|
return self._target_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
|
|
||||||
|
|
||||||
def set_temperature(self, temperature):
|
def set_temperature(self, temperature):
|
||||||
""" Set new target temperature. """
|
""" Set new target temperature. """
|
||||||
if temperature is None:
|
self._target_temp = temperature
|
||||||
self._manual_sat_temp = None
|
self._control_heating()
|
||||||
else:
|
self.update_ha_state()
|
||||||
self._manual_sat_temp = float(temperature)
|
|
||||||
|
|
||||||
def update(self):
|
def _sensor_changed(self, entity_id, old_state, new_state):
|
||||||
""" Update current thermostat. """
|
""" Called when temperature changes. """
|
||||||
heater = self.hass.states.get(self.heater_entity_id)
|
if new_state is None:
|
||||||
if heater is None:
|
|
||||||
self.logger.error("No heater available")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
current_temperature = self.current_temperature
|
self._update_temp(new_state)
|
||||||
if current_temperature is None:
|
self._control_heating()
|
||||||
self.logger.error("No temperature available")
|
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
|
return
|
||||||
|
|
||||||
if (current_temperature - self.target_temperature) > \
|
temp = util.convert(state.state, float)
|
||||||
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)
|
|
||||||
|
|
||||||
def _heater_turned_on(self, entity_id, old_state, new_state):
|
if temp is None:
|
||||||
""" Heater is turned on. """
|
self._cur_temp = None
|
||||||
if not self._heater_manual_changed:
|
self._unit = None
|
||||||
pass
|
_LOGGER.error('Unable to parse sensor temperature: %s',
|
||||||
else:
|
state.state)
|
||||||
self.set_temperature(self.max_temp)
|
return
|
||||||
|
|
||||||
self._heater_manual_changed = True
|
self._cur_temp = temp
|
||||||
|
self._unit = unit
|
||||||
|
|
||||||
def _heater_turned_off(self, entity_id, old_state, new_state):
|
def _control_heating(self):
|
||||||
""" Heater is turned off. """
|
""" Check if we need to turn heating on or off. """
|
||||||
if self._heater_manual_changed:
|
if not self._active and None not in (self._cur_temp,
|
||||||
self.set_temperature(None)
|
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
|
@property
|
||||||
def is_away_mode_on(self):
|
def _is_heating(self):
|
||||||
"""
|
""" If the heater is currently heating. """
|
||||||
Returns if away mode is on.
|
return switch.is_on(self.hass, self.heater_entity_id)
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.thermostat.nest
|
homeassistant.components.thermostat.nest
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Adds support for Nest thermostats.
|
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 socket
|
||||||
import logging
|
import logging
|
||||||
@ -44,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
])
|
])
|
||||||
except socket.error:
|
except socket.error:
|
||||||
logger.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
|
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 logging
|
||||||
import datetime
|
import datetime
|
||||||
@ -12,33 +15,40 @@ from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
|||||||
from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT)
|
from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT)
|
||||||
|
|
||||||
REQUIREMENTS = ['radiotherm==1.2']
|
REQUIREMENTS = ['radiotherm==1.2']
|
||||||
|
HOLD_TEMP = 'hold_temp'
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the Radio Thermostat. """
|
""" Sets up the Radio Thermostat. """
|
||||||
import radiotherm
|
try:
|
||||||
|
import radiotherm
|
||||||
logger = logging.getLogger(__name__)
|
except ImportError:
|
||||||
|
_LOGGER.exception(
|
||||||
|
"Unable to import radiotherm. "
|
||||||
|
"Did you maybe not install the 'radiotherm' package?")
|
||||||
|
return False
|
||||||
|
|
||||||
hosts = []
|
hosts = []
|
||||||
if CONF_HOST in config:
|
if CONF_HOST in config:
|
||||||
hosts = [config[CONF_HOST]]
|
hosts = config[CONF_HOST]
|
||||||
else:
|
else:
|
||||||
hosts.append(radiotherm.discover.discover_address())
|
hosts.append(radiotherm.discover.discover_address())
|
||||||
|
|
||||||
if hosts is None:
|
if hosts is None:
|
||||||
logger.error("no radiotherm thermostats detected")
|
_LOGGER.error("No radiotherm thermostats detected.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
|
hold_temp = config.get(HOLD_TEMP, False)
|
||||||
tstats = []
|
tstats = []
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
try:
|
try:
|
||||||
tstat = radiotherm.get_thermostat(host)
|
tstat = radiotherm.get_thermostat(host)
|
||||||
tstats.append(RadioThermostat(tstat))
|
tstats.append(RadioThermostat(tstat, hold_temp))
|
||||||
except (URLError, OSError):
|
except (URLError, OSError):
|
||||||
logger.exception(
|
_LOGGER.exception("Unable to connect to Radio Thermostat: %s",
|
||||||
"Unable to connect to Radio Thermostat: %s", host)
|
host)
|
||||||
|
|
||||||
add_devices(tstats)
|
add_devices(tstats)
|
||||||
|
|
||||||
@ -46,13 +56,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class RadioThermostat(ThermostatDevice):
|
class RadioThermostat(ThermostatDevice):
|
||||||
""" Represent a Radio Thermostat. """
|
""" Represent a Radio Thermostat. """
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device, hold_temp):
|
||||||
self.device = device
|
self.device = device
|
||||||
self.set_time()
|
self.set_time()
|
||||||
self._target_temperature = None
|
self._target_temperature = None
|
||||||
self._current_temperature = None
|
self._current_temperature = None
|
||||||
self._operation = STATE_IDLE
|
self._operation = STATE_IDLE
|
||||||
self._name = None
|
self._name = None
|
||||||
|
self.hold_temp = hold_temp
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -107,7 +118,10 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
self.device.t_cool = temperature
|
self.device.t_cool = temperature
|
||||||
elif self._operation == STATE_HEAT:
|
elif self._operation == STATE_HEAT:
|
||||||
self.device.t_heat = temperature
|
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):
|
def set_time(self):
|
||||||
""" Set device time """
|
""" Set device time """
|
||||||
|
@ -3,44 +3,8 @@ components.verisure
|
|||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
Provides support for verisure components.
|
Provides support for verisure components.
|
||||||
|
|
||||||
Configuration:
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/verisure.html
|
||||||
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.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -3,20 +3,8 @@ homeassistant.components.wink
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Connects to a Wink hub and loads relevant components to control its devices.
|
Connects to a Wink hub and loads relevant components to control its devices.
|
||||||
|
|
||||||
Configuration:
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/wink.html
|
||||||
To use the Wink component you will need to add something like the following
|
|
||||||
to your configuration.yaml file.
|
|
||||||
|
|
||||||
wink:
|
|
||||||
access_token: YOUR_ACCESS_TOKEN
|
|
||||||
|
|
||||||
Variables:
|
|
||||||
|
|
||||||
access_token
|
|
||||||
*Required
|
|
||||||
Please check https://home-assistant.io/components/wink.html for further
|
|
||||||
details.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -71,7 +59,7 @@ def setup(hass, config):
|
|||||||
|
|
||||||
|
|
||||||
class WinkToggleDevice(ToggleEntity):
|
class WinkToggleDevice(ToggleEntity):
|
||||||
""" Represents a Wink switch within Home Assistant. """
|
""" Represents a Wink toogle (switch) device. """
|
||||||
|
|
||||||
def __init__(self, wink):
|
def __init__(self, wink):
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
|
@ -1,25 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.zone
|
homeassistant.components.zone
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Allows defintion of zones in Home Assistant.
|
Allows defintion of zones in Home Assistant.
|
||||||
|
|
||||||
zone:
|
For configuration details please visit the documentation for this component at
|
||||||
name: School
|
https://home-assistant.io/components/zone.html
|
||||||
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
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
homeassistant.components.zwave
|
homeassistant.components.zwave
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Connects Home Assistant to a Z-Wave network.
|
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
|
from pprint import pprint
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import homeassistant.util.temperature as temp_util
|
|||||||
|
|
||||||
def convert(temperature, unit, to_unit):
|
def convert(temperature, unit, to_unit):
|
||||||
""" Converts temperature to correct 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
|
return temperature
|
||||||
elif unit == TEMP_CELCIUS:
|
elif unit == TEMP_CELCIUS:
|
||||||
return temp_util.celcius_to_fahrenheit(temperature)
|
return temp_util.celcius_to_fahrenheit(temperature)
|
||||||
|
@ -87,7 +87,7 @@ https://github.com/theolind/pymysensors/archive/d4b809c2167650691058d1e29bfd2c4b
|
|||||||
pynetgear==0.3
|
pynetgear==0.3
|
||||||
|
|
||||||
# Netdisco (discovery)
|
# Netdisco (discovery)
|
||||||
netdisco==0.4.2
|
netdisco==0.5
|
||||||
|
|
||||||
# Wemo (switch.wemo)
|
# Wemo (switch.wemo)
|
||||||
pywemo==0.3.1
|
pywemo==0.3.1
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Sets up and builds python open zwave to be used with Home Assistant
|
# 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
|
# apt-get install cython3 libudev-dev python-sphinx python3-setuptools
|
||||||
# pip3 install cython
|
# pip3 install "cython<0.23"
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class TestShellCommand(unittest.TestCase):
|
|||||||
path = os.path.join(tempdirname, 'called.txt')
|
path = os.path.join(tempdirname, 'called.txt')
|
||||||
self.assertTrue(shell_command.setup(self.hass, {
|
self.assertTrue(shell_command.setup(self.hass, {
|
||||||
'shell_command': {
|
'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…
x
Reference in New Issue
Block a user