Compare commits

..

754 Commits
0.37.1 ... 0.41

Author SHA1 Message Date
Fabian Affolter
1f046972d9 Merge pull request #6756 from home-assistant/release-0-41
0.41
2017-03-26 00:01:49 +01:00
Paulus Schoutsen
53f8828181 Merge branch 'master' into release-0-41 2017-03-23 23:32:50 -07:00
Paulus Schoutsen
b6b40286ef Version bump to 0.41 2017-03-23 08:42:01 -07:00
Andrey
8a86ec5b74 Add zwave per-node entity. (#6690)
* Add zwave per-node entity.

* Disable lint import error

* Add tests for base class

* More tests

* More tests

* Sort .coveragerc

* more tests

* Move location, battery and wakeup to node entity

* More tests

* Cleanup

* Make zwave node entity visible by default

* Remove battery sensor

* Fix tests
2017-03-23 08:37:20 -07:00
Dan Ports
20c5f9de4b Add sensor for Lyft time and price (based on Uber sensor) (#6711)
* Add sensor for Lyft time and price (based on Uber sensor)

* Minor fixes to lyft sensor
 - use add_devices(...,True) instead of explicitly calling update
 - move sensor name check into constructor

* lyft sensor: disable sandbox mode
2017-03-23 08:15:52 -07:00
Mitesh Patel
61730012d8 Adds Support for Lutron Caseta devices. (#6631)
* Adds support for the Lutron Caseta family of devices

* Added external requirement

* Removes unuse import

* Adds requirement to requirements_all.txt

* Removes unuse import

* fixes requirement_all.txt. by regenerating

* Cleans up syantax

* Cleans up syantax

* Cleans up syantax

* Cleans up syantax

* Shortens long line

* adds lutron_caseta component to .coveragerc

* Merges into light, removes component

* Fixes long lines

* Fixes requirement.txt

* Removes 'ERROR' log statements. Adds missing dependency

* savig work to pick up on other machine

* Enables Lutron Caseta component with Light and Switch platforms

* Add missing file to .coveragerc

* Changes based on PR review

* fixes requirements file

* Fixes install of paramiko dependency.

* Moves callback registration to

* comment changes

* Platform have no return value

* Change style for guard

* fix logic

* fix lint
2017-03-23 01:18:14 +01:00
Paulus Schoutsen
25d2df5689 Merge pull request #6740 from home-assistant/release-0-40-2
0.40.2
2017-03-22 09:31:21 -07:00
Paulus Schoutsen
672b83db8a Update constraints 2017-03-22 09:30:36 -07:00
Paulus Schoutsen
b37438ebb7 Constrain core dependencies to core versions (#6738)
* Require at least pip 7.1

* Write and use constraint files for packages

* Update gen_requirements_all.py
2017-03-22 08:51:18 -07:00
Paulus Schoutsen
902b72ba1a Constrain core dependencies to core versions (#6738)
* Require at least pip 7.1

* Write and use constraint files for packages

* Update gen_requirements_all.py
2017-03-22 08:50:54 -07:00
Paulus Schoutsen
f10fede17f Bump PyChromecast to 0.8.1 (#6702) 2017-03-22 08:50:42 -07:00
Paulus Schoutsen
c9548b11b1 Version bump to 0.40.2 2017-03-22 08:50:15 -07:00
Wolfgang Malgadey
f4aec3ac88 Tado climate device (#6572)
* Added tado climate component

named the component v1 because of the unsupported state of the api I
used (mytado.com)

* sensor component
* climate component which uses sensors
* main component initiating sensor and climate devices
* order of imports
* consts for username and password
* removed redundant code
* changed wrong calls and properties

* remove pylint overrides

* merged update() and push_update()

* changed wrong calls
* removed pylint overrides
* moved try..except

* renamed MyTado hass-data object

* added TadoDataStore

* moved update methods from sensor to TadoDataStore

* reorganised climate component

* use new TadoDataStore

* small change to overlay handling

* code refactoring

* removed unnessesary comments
* changed throttle to attribute
* changed suggestions from PR

* Added constant variable for string literal

* remove wrong fget() call

* changed dependencies

* Changed operation mode list

* added human readable list of operations
* removed unnecessary const
* activated update on add_devices

* droped unit

* removed unnused property

* changed temperature conversion

* removed defaults from config
changed naming of tado data const

* switched operation_list key/values

* changed the value returned as state

* added one extra line

* dropped state to use base impl.

* renamed component

* had to inplement temperature_unit

* because it is not implemented in base class

* create a copy of the sensors list

* because it can be changed by other components

* had to check for empty data object

* hass is too fast now
2017-03-22 08:18:13 -04:00
Adam Mills
e7425e9808 ZWave Lock Tests (#6730)
* ZWave Lock Tests

* Linting fixes

* Missed coveragerc
2017-03-21 08:55:21 -07:00
Matt N
978b539111 camera.zoneminder: Show recording state (#6686) 2017-03-21 07:25:10 +01:00
Paulus Schoutsen
9f4cd5fafe Do not log warning on rest_command if no error (#6713) 2017-03-21 07:18:33 +01:00
Anders Melchiorsen
ba3c9f9765 Fix LIFX unregister races (#6723)
* Fix LIFX unregister races

If the initial state request never got a response, we tried to unregister
a device that was not yet registered.

Also, aiolifx 0.4.2 has an "unregister" race fix.

* Update requirements
2017-03-21 07:17:58 +01:00
Paulus Schoutsen
4ee8be52fe Update frontend 2017-03-20 21:31:58 -07:00
Adam Mills
866bf887d3 ZWave switch tests (#6722) 2017-03-20 13:17:42 -04:00
Adam Mills
dddbce82f5 ZWave Sensor tests (#6721)
* ZWave Sensor tests

* Add missed coverage
2017-03-20 13:17:17 -04:00
Jeff Wilson
be15ca3f23 Don't warn if octoprint completion is null (#6719) 2017-03-20 09:00:45 -07:00
Finbarr Brady
9a305c9742 Fix for issue: luci returns 403 invalid token when rebooted #6715 (#6717) 2017-03-20 08:55:59 -07:00
Paulus Schoutsen
de231cf9ab restore_state: do not crash if domain not defined (#6714) 2017-03-20 08:54:51 -07:00
Adam Mills
8325f9db8a Add zwave light tests (#6710)
* Add zwave light tests

* Test turn_off
2017-03-19 22:22:13 -07:00
Paulus Schoutsen
3f38b9e52f Update frontend 2017-03-19 21:59:13 -07:00
printzlau
1cb2a6add0 automatically use bundled certificate it set to auto (#6707)
* automatically use bundled certificate if certificate-parameter is set to 'auto' and seperate this from which port is specified

* Fix travis error and long lines

* Update __init__.py
2017-03-19 14:51:53 -07:00
Greg Dowling
acf75b5253 Revise power and energy units and property names. (#6212)
* Revise power and energy units and property names.

* Add change for new wemo parameter.
2017-03-19 22:02:11 +01:00
Adam Mills
970bde9e99 Fix Kodi when websocket is disabled (#6706) 2017-03-19 21:38:12 +01:00
Adam Mills
796143a6c6 Kodi use websocket loop task created by library (#6703) 2017-03-19 12:46:14 -07:00
Paulus Schoutsen
5569ae38f1 Bump PyChromecast to 0.8.1 (#6702) 2017-03-19 11:53:58 -07:00
John Mihalic
7eaad4fb3a Fix longitude (#6697) 2017-03-19 11:00:13 -07:00
Fabian Affolter
35c679a956 Upgrade distro to 1.0.3 (#6693) 2017-03-19 15:59:07 +01:00
martinfrancois
678f273002 Rflink: added support for lights with toggle type (#6521)
* added support for lights with toggle type

* fixed style errors

* introduced tests for the toggle type

it's not passing yet because of an assertionerror at line 407

* updated to reflect tristate of "state"

* Format code according to pep8

Added line break for import that was too long.

* fixed lint, replaced if statement with 'var = bool(test)'

* changed implementation of state check according to bug on 6bceb04ca1 (r106758784)
2017-03-18 21:34:17 +01:00
Tyler Crumpton
4e91c65d6e Update Torque component to match recent API. (#6671) 2017-03-18 11:25:38 +01:00
Robbie Trencheny
f6106706e5 Merge pull request #6672 from robbiet480/new-plex-fix
Fixed Show All Controls feature
2017-03-17 17:34:26 -07:00
JesseWebDotCom
ecf337b123 Fixed Show All Controls feature 2017-03-17 17:22:38 -07:00
Martin Nöhrer
f5d8327d9a Fix hass script execution on Windows (#4977). (#6601)
* Fix hass script execution on Windows (#4977).

hass.exe returned ERRNO2 on a windows machine and must be started using
package loading. This fix adapts the command line options for
`setup_and_run_hass()` to start
either a script with `python homeassistant/__main__.py` or with
`Scripts/hass.exe`

* Fix code style
2017-03-17 17:07:36 -07:00
John Mihalic
30d4c54187 Update Emby component to async (#6664)
* Update Emby component to async

* Address comments

* Make SSL default

* Bump library

* Port based on SSL, use available property
2017-03-17 15:55:07 +01:00
David Straub
edf20f542a Phone book lookup support for Fritz!Box call monitor (#6474)
* Update fritzconnection dependency in fritz and fritzbox_netmonitor components

* Add phone book name lookup support to FritzBox call monitor

* Updated requirements_all.txt

* Requested changes to FritzBox call monitor

* Listen to HOME_ASSISTANT_STOP and close thread

* Safe CPU time
2017-03-17 14:40:12 +01:00
Jay Love
9778000e9a Add new media_player platform: Volumio Media Player (#6556)
* Add new media_player platform: Volumio Media Player

Volumio media player is a rpi music player, this platfor adds http based control of the player.

* Modify mute command to accept boolean

* Adjust mute call to reset volume after unmute
Remove references to volimi"a"

* Use yield from calls in mute and volume calls

Trying to speed up the indication of mute and volume level changes in UI, but doesn't seem to do much.

* Adjust async_add_devices call
2017-03-16 23:32:52 -07:00
miniconfig
b5149dfba6 Added support for multiple efergy sensors in the same household. (#6630)
* Added support for multiple efergy sensors in the same household.
Also added inital tests for the efergy platform.

* Fixed current_values units.
Changed name to include efergy_ prefix.
2017-03-16 23:22:10 -07:00
John Mihalic
ced3cd2616 Refactor Neurio to add Daily Power Sensor (#6662)
* Refactor Neurio to add Daily Power Sensor
2017-03-16 23:20:14 -07:00
RickyTaterSalad
7050236a61 add latitude and longitude configuration to darksky sensor (#6191)
* Optional latitude and longitude to darksky sensor

allow configuration of latitude and longitude in the darksky sensor.
falls back to home assistant coordinates if latitude/longitude not
specified.

* lat/long as inclusive on schema. removed None check for lat/long in setup_platorm

altered schema to require latitude and longitude configured as a pair.
removed None check on latitude and longitude since values will fall back
to hass config if not present

* adhere to line limit of 79 characters

adhere to line limit of 79 characters
2017-03-16 23:04:01 -07:00
Pascal Vizeli
c8e1ffad89 Pump Android ip webcam to 0.6 (#6665)
* Pump Android ip webcam to 0.5

* update to 0.6
2017-03-16 22:19:48 +01:00
hawk259
e3edff8a72 Add configurable timeout option to camera.synology (#6655) 2017-03-16 21:26:35 +01:00
Sebastian
d6fd0f405e Corrected help text for refresh_node (#6659)
Changed entity_id to node_id.
2017-03-16 21:50:01 +02:00
Fabian Affolter
1ab47b5d2b Check if droplet exists (#6663)
* Check if droplet exists

* Add droplet to message and remove else
2017-03-16 19:59:34 +01:00
Fabian Affolter
a2365eccf6 Upgrade aiohttp to 1.3.5 (#6660) 2017-03-16 18:04:00 +01:00
Fabian Affolter
c46ba3446d Upgrade astral to 1.4 (#6332)
* Upgrade astral to 1.4

* Update test for norway
2017-03-16 17:38:46 +01:00
JesseWebDotCom
5714f156c3 Support for non-clients, NVidia shield, dynamic grouping, extra metad… (#6054)
* Support for non-clients, NVidia shield, dynamic grouping, extra metadata, and more

* Fixed import orderdering, line lengths, and comment violations

* Local player check and season fixes

* Honor entity_namespace when using custom entity ids

* Semi compatibility with channels, force controls option added

* media_position_updated_at fix - only update when media is playing

* Fix: controls now work as expected on 1) casted sessions and 2) client sessions when client and PMS reside on the same sever

* Made PEP8 compliant

* Made PEP8 compliant

* Made PEP8 compliant, hopefully

* Better Tivo compatibility

* Added frozen detection and remediation

* PlayMedia EPISODE now supports season number and episode number (instead of episode index)

* Fix: Dynamic groups now exclude hidden devices

* Fix: Dynamic groups now exclude hidden devices

* Implemented arsaboo suggested formatting

* Implemented pylint command line suggested fixes

* Implemented Travis CI build suggested fixes

* Sorted Imports using Importanize

* Grouped request imports

* Removed dynamic groups, network calls from properties, and other cleanup

* Balloob recommendations and Plex Protocol Capabilities checks

* Remove deprecated disable-msg in favor of disable

* Removed position related items (seek, frozen detection, etc)

* Removed unused datetime
2017-03-16 09:09:46 -07:00
joe248
959dd29c90 round output values (#6657) 2017-03-16 15:36:44 +01:00
John Arild Berentsen
e75a66ed20 Add Zwave sensors test (#6640)
* Test for zwave sensor

* Add test for ZWave sensors

* Hound...

* Hound...

* Review changes
2017-03-16 08:25:37 -04:00
Fabian Affolter
3e72aa8643 Upgrade python-digitalocean to 1.11 (#6653) 2017-03-16 11:14:36 +01:00
John Arild Berentsen
5aaa1f8404 Add test for Z-wave switch (#6619)
* Add test for Z-wave switch

* Changes for new tests
2017-03-16 11:05:51 +01:00
Paulus Schoutsen
7292e564f8 Merge pull request #6652 from home-assistant/release-0-40-1
0.40.1
2017-03-15 23:47:10 -07:00
Wolf-Bastian Pöttner
509cfb6433 Added workday sensor (#6599)
* Added workday sensor

* Added unit tests
2017-03-15 23:46:13 -07:00
Pascal Vizeli
acdab67c1b Bugfix RFLINK remove group (#6580)
* Bugfix RFLINK remove group

* Remove group hack from lutron too

* fix tests

* fix lint

* fix lint
2017-03-15 23:19:33 -07:00
deisi
d7addf59cd Fix #6534 (#6598)
* Fix #6534

Makes sure 0 is not passes to `color_temperature_kelvin_to_mired`.

* Update osramlightify.py

* Update osramlightify.py
2017-03-15 23:19:24 -07:00
Yum
ccf9edf815 since knx_2_float can't handle 0, bypass converting 0 value from knx to float (#6626) 2017-03-15 23:18:55 -07:00
Johann Kellerman
2fd3c186e2 Update SMA solar sensor to work with the new add_devices callback (#6602) 2017-03-15 23:18:11 -07:00
Dale Higgs
719199da45 Update pyecobee version to 0.0.7 (#6593) 2017-03-15 23:17:44 -07:00
Thibault Cohen
a3cd7d653d Fix hydroquebec (#6574) 2017-03-15 23:17:17 -07:00
Andrey
aeeb927e19 Fix for the case of zwave value used in several devices. (#6577) 2017-03-15 23:16:50 -07:00
Jesse Newland
a3a14f9ea4 Don't start the push updater if the Apple TV is 'off' (#6552)
Add an optional extended description…
2017-03-15 23:16:32 -07:00
Tyler Page
f4e7b231bc Fix wake_on_lan ping with None as host (#6532)
* Update configuration validation

With the new update, wake_on_lan requires a host key in the configuration

* cast self._host to str as requested

* Changed host key back to optional
2017-03-15 23:15:56 -07:00
Paulus Schoutsen
5f68735375 Version bump to 0.40.1 2017-03-15 23:10:50 -07:00
Pascal Vizeli
774fd19638 Bugfix RFLINK remove group (#6580)
* Bugfix RFLINK remove group

* Remove group hack from lutron too

* fix tests

* fix lint

* fix lint
2017-03-15 23:08:47 -07:00
Paulus Schoutsen
e265401cd0 self.loop.create_task -> self.add_job (#6632)
* self.loop.create_task -> self.add_job

* Core to use create task
2017-03-16 06:58:54 +01:00
deisi
5b3dc7f2a5 Fix #6534 (#6598)
* Fix #6534

Makes sure 0 is not passes to `color_temperature_kelvin_to_mired`.

* Update osramlightify.py

* Update osramlightify.py
2017-03-15 22:58:06 -07:00
Anders Melchiorsen
9ef084d903 Move LIFX to aiolifx for driving the bulbs (#6584)
* Move LIFX to aiolifx for driving the bulbs

* Fix whitespace

* Fix more whitespace

* Fix lint

* Define _available in init

* Add @callback decorators

* Use hass.async_add_job

* Rename class
2017-03-15 22:50:33 -07:00
Robbie Trencheny
95b1e257bb Merge pull request #6633 from home-assistant/deprecate-event-forwarding
Deprecate event forwarding
2017-03-15 22:27:49 -07:00
Adam Mills
b06cf87c74 Kodi: Fix episode media type classification (#6645) 2017-03-15 22:07:30 -07:00
Adam Mills
326337777a Add ZWave cover tests (#6648) 2017-03-15 22:06:37 -07:00
mvillarejo
2c8a06bfbe media_player.kodi extra attributes for tvshow and music media (#6622)
* media_player.kodi extra attributes for tvshow and music media

* removed extra whitespaces/CR

* Kodi - add extra attributes #6250 (removed music attributes)

* Restored music attributes, this is ready for merge

* linting amended

* Fix Kodi artist support

* Copy-paste error

* Fix for non-music artist lookup

Kodi returns an emtpy list on videos, so we need to be able to
handle that as well.
2017-03-15 19:51:31 -04:00
Pascal Vizeli
198a234468 aioHttp 1.3.4 (#6643) 2017-03-15 22:30:46 +01:00
Paulus Schoutsen
e94aa3afe9 Deprecate event forwarding 2017-03-15 08:38:26 -07:00
Paulus Schoutsen
96e22c7b41 Remove event decorators (#6634) 2017-03-15 14:46:57 +01:00
Nathan Henrie
33450c726d Use sqlite's WAL mode to avoid database is locked errors (#6519)
* Use sqlite's WAL mode to avoid `database is locked` errors

- Relevant issue: https://github.com/home-assistant/home-assistant/issues/4780

Code:

- http://stackoverflow.com/a/23661501/1588795
- http://docs.sqlalchemy.org/en/rel_0_9/dialects/sqlite.html#foreign-key-support
- https://github.com/g2p/bedup/pull/86/files

* Only set WAL if using sqlite

* Reorder imports

* Fix pylint warnings
2017-03-15 00:14:12 -07:00
Yum
97b9d3bd21 since knx_2_float can't handle 0, bypass converting 0 value from knx to float (#6626) 2017-03-14 20:25:52 -07:00
Adam Mills
fff589eeab Correctly flag Kodi media types (#6628) 2017-03-14 20:25:15 -07:00
Adam Mills
5e5d2e8ab8 Tests for ZWave climate (#6629)
But wait, there's more! Also a few fixes discovered writing the tests.
2017-03-14 20:24:35 -07:00
Paulus Schoutsen
1a7ffdca52 Add "Refactor zwave discovery to entity schema" (#6565)
* Revert "Revert "Refactor zwave discovery to entity schema (#6445)" (#6564)"

This reverts commit 58826b264a.

* Update zwave tests for enitity schema

* Fix merge error

* Switch dict_id to id(self)
2017-03-14 19:55:33 -04:00
Erik Eriksson
cada74df22 Merge pull request #6583 from molobrakos/voc-fix
Bump VOC version (fixes heater bug)
2017-03-14 23:37:32 +01:00
Johan Bloemberg
bd3fbe8363 Upgrade to dsmr_parser 0.8, supporting protocol 3 and 5. (#6600)
* Upgrade to dsmr_parser 0.8, supporting protocol 3 and 5.

* Update tests for new import.
2017-03-14 20:16:43 +01:00
Daniyar Yeralin
4d9c7d9684 Update mpd.py (#6553)
* Update mpd.py

Introducing new parameter "Name"

* Update mpd.py

Change `CONF_LOCATION` to `CONF_NAME`
2017-03-14 20:10:35 +01:00
ArrayLabs
0bf66384ed Cover myq fix update pymyq (#6595)
* update pymyq to 0.0.8

update to correct wrong version in setup.py

* update pymyq to 0.0.8

update to correct wrong version in setup.py
2017-03-14 20:06:30 +01:00
tflack
c7798ef43c Define db for SHOW DIAGNOSTICS query since some users will not have a… (#6566)
* Define db for SHOW DIAGNOSTICS query since some users will not have admin perms

* fix white space error from CI
2017-03-14 11:46:46 -07:00
hawk259
f4d8095e54 Add configurable timeout option to notify/smtp (#6609)
* Add configurable timeout option to notify/smtp

* Updated smtp test to include timeout param

* fixed 80 column style issue
2017-03-14 19:00:16 +01:00
Pascal Vizeli
5529d77c62 Prevent entities running multiple updates simultaneously (#6511)
* Protect entity for multible updates on same time.

* Address all comments / make update more robust

* fix unittest

* fix lint

* address comments
2017-03-14 09:26:55 -07:00
Erik Eriksson
c4e151f621 Error handling when connection refused (#6614)
Add an optional extended description…
2017-03-14 10:08:40 +01:00
Fabian Affolter
f58941a0d4 Upgrade googlemaps to 2.4.6 (#6611) 2017-03-14 07:54:19 +01:00
Fabian Affolter
bca673f039 Upgrade py-cpuinfo to 0.2.7 (#6610) 2017-03-14 07:54:10 +01:00
Fabian Affolter
2687f2f623 Fix link (#6612) 2017-03-14 07:53:48 +01:00
Johann Kellerman
134b3d2f3b Update SMA solar sensor to work with the new add_devices callback (#6602) 2017-03-14 06:39:30 +02:00
Dale Higgs
f450c1351c Update pyecobee version to 0.0.7 (#6593) 2017-03-13 21:19:51 +01:00
Fabian Affolter
c6b10f3703 Upgrade Sphinx to 1.5.3 (#6587) 2017-03-13 21:05:27 +01:00
Fabian Affolter
4a08067b9c Upgrade psutil to 5.2.0 (#6585) 2017-03-13 21:05:07 +01:00
Fabian Affolter
9c37437a59 Upgrade sqlalchemy to 1.1.6 (#6591) 2017-03-13 21:02:28 +01:00
Fabian Affolter
9330142987 Upgrade pyasn1 to 0.2.3 (#6588) 2017-03-13 21:01:45 +01:00
Fabian Affolter
2bbaac44d4 Upgrade async_timeout to 1.2.0 (#6590) 2017-03-13 21:01:25 +01:00
Thibault Cohen
253dee8e4d Fix hydroquebec (#6574) 2017-03-13 18:54:23 +01:00
Andrey
5722cf53bf Fix for the case of zwave value used in several devices. (#6577) 2017-03-13 12:19:45 -05:00
Pascal Vizeli
5d301590c3 Remove dispatcher camera (#6579) 2017-03-13 17:54:28 +01:00
Erik
353f5d6b49 bump voc version (fixes heater bug) 2017-03-13 17:28:27 +01:00
Jesse Newland
11da7bed12 Don't start the push updater if the Apple TV is 'off' (#6552)
Add an optional extended description…
2017-03-13 14:23:15 +01:00
Kevin Fronczak
a358c8e10d Upgraded blinkpy version, increased Throttle time for camera (#6561) 2017-03-13 00:12:48 -07:00
Paulus Schoutsen
58826b264a Revert "Refactor zwave discovery to entity schema (#6445)" (#6564)
This reverts commit 56abc7f9b4.
2017-03-12 23:35:10 -07:00
Adam Mills
56abc7f9b4 Refactor zwave discovery to entity schema (#6445)
* Refactor zwave discovery to entity schema

* Address PR concerns

* Split DISCOVERY_SCHEMAS into separate file

* Only check cover reverse workaround once
2017-03-12 23:13:34 -07:00
Adam Mills
55d60a6a13 ZWave binary sensor tests (#6555)
* ZWave binary sensor tests

* Test fixes

* Improve coverage of features
2017-03-12 22:08:53 -07:00
Dennis de Greef
5183cb5903 Be able to select mqtt:tls_version for Python < 3.6 (#6442)
* Be able to select tls_version

* This test should always assert this value, not only in 3.6

* Disable linting on future property (py36)

* Only allow TLS 1.0, 1.1 and 1.2

* Fix line length issue

* Fix check config tests

* Allow auto as a TLS version
2017-03-12 22:02:59 -07:00
Tyler Page
0aa8933df6 Fix wake_on_lan ping with None as host (#6532)
* Update configuration validation

With the new update, wake_on_lan requires a host key in the configuration

* cast self._host to str as requested

* Changed host key back to optional
2017-03-12 20:46:58 +01:00
siebert
fc46a24996 Fix gen_requirements_all.py script for Windows. (#6547) 2017-03-12 21:08:49 +02:00
Paulus Schoutsen
5be58bd056 Simplify Android IP webcam discovery (#6528) 2017-03-12 18:56:48 +01:00
Lewis Juggins
4a423e63f3 Version bump to 0.41.0.dev0 2017-03-12 08:34:35 +00:00
Paulus Schoutsen
a8b32edc8e Merge pull request #6509 from home-assistant/release-0-40
0.40
2017-03-11 11:08:40 -08:00
Greg Dowling
4a5b9db394 Discovery is a dict rather than an array. (#6525) 2017-03-11 11:06:05 -08:00
Greg Dowling
9c23178457 Append vera device id to entity id - but not name. (#6523)
* Append vera device id to entity id - but not name.

* Tidy.

* Tidy.

* Tidy after review.

* Re-order.
2017-03-11 11:06:05 -08:00
Paulus Schoutsen
764d31efcb Remove mint finance sensor (#6522) 2017-03-11 11:06:05 -08:00
Anders Melchiorsen
fc90ccea36 Fix colortemp conversion for osramlightify (#6516)
* Fix colortemp conversion for osramlightify

Copied from the LIFX fix in 75df4be733.

* Fix style

* Updates from review

@armills:

While we're doing cleanup here, can you just change self._brightness,
self._rgb, self._name, self._temperature, and self._state assignments in
__init__ to None? These will get overwritten when self.update() is called, so
it's safer/cleaner to initialize them to None since it shouldn't matter if
everything is working.
2017-03-11 11:06:05 -08:00
Martin Hjelmare
aab63ea22a Fix mysensors gateway windows setup (#6500) 2017-03-11 11:06:05 -08:00
Adam Mills
157ab77232 Update Kodi notifier to async (#6497)
* Update Kodi notifier to async

* Change Kodi CONF_SSL to CONF_PROXY_SSL
2017-03-11 10:41:05 -08:00
Anders Melchiorsen
9a86ccaaea Fix colortemp conversion for osramlightify (#6516)
* Fix colortemp conversion for osramlightify

Copied from the LIFX fix in 75df4be733.

* Fix style

* Updates from review

@armills:

While we're doing cleanup here, can you just change self._brightness,
self._rgb, self._name, self._temperature, and self._state assignments in
__init__ to None? These will get overwritten when self.update() is called, so
it's safer/cleaner to initialize them to None since it shouldn't matter if
everything is working.
2017-03-11 10:40:16 -08:00
Greg Dowling
32dd815852 Discovery is a dict rather than an array. (#6525) 2017-03-11 10:39:26 -08:00
Boris K
9ac3928600 Add type configuration in history_stats (#6430) 2017-03-11 10:38:18 -08:00
William Scanlon
62e57456e1 Wink scene(shortcut) support (#6147)
* Wink scene(shortcut) support

* Scenes to Scene

* Moved wink scenes from switches to scenes

* Updated python-wink version
2017-03-11 10:18:29 -08:00
Róbert Nagy
11f11481b2 Force update support for MQTT sensor (#6492) 2017-03-11 10:07:52 -08:00
Greg Dowling
10f5e9744b Append vera device id to entity id - but not name. (#6523)
* Append vera device id to entity id - but not name.

* Tidy.

* Tidy.

* Tidy after review.

* Re-order.
2017-03-11 10:06:46 -08:00
Paulus Schoutsen
b2a2193ba3 Remove mint finance sensor (#6522) 2017-03-11 01:02:32 -08:00
Paulus Schoutsen
c8b2ba6559 Version bump to 0.40 2017-03-10 23:09:44 -08:00
Paulus Schoutsen
1496f1a570 Update frontend 2017-03-10 22:52:16 -08:00
Paulus Schoutsen
493c0bbb4c Update frontend 2017-03-10 22:51:44 -08:00
Martin Hjelmare
13dd17b2ab Fix mysensors gateway windows setup (#6500) 2017-03-11 03:30:23 +01:00
Pascal Vizeli
0ef1c3af34 Android webcam better error handling / pump library 0.4 (#6518) 2017-03-10 23:11:16 +01:00
Pascal Vizeli
44da43065f Android webcam better error handling / pump library 0.4 (#6518) 2017-03-10 23:10:35 +01:00
Pascal Bach
ffb1613d55 [packaging] Include LICENSE.md in tarball (#6514) 2017-03-10 19:59:38 +00:00
Pascal Vizeli
b0a2909835 Bugfix rpi_rf cleanup (#6513)
Add an optional extended description…
2017-03-10 14:57:03 +01:00
Pascal Vizeli
b5fb558c62 Bugfix rpi_rf cleanup (#6513)
Add an optional extended description…
2017-03-10 14:56:13 +01:00
Robbie Trencheny
846a0513c7 Don't allow sending to invalid iOS targets (#6115)
* Don't allow sending to invalid targets

* Fix valid target check
2017-03-10 12:32:43 +01:00
Craig J. Ward
0f1cad24ce Insteon lib (#6505)
* use lib with caching to reduce collisions

* use 0.43

* change requirements

* update the  lib to 0.44

* update req

* fix typo

* just keep checking

* just keep checking - switch

* use 0.45 with file cache

* requirements

* Update requirements_all.txt

* Update insteon_local.py

* Update requirements_all.txt

* Update insteon_local.py

* update library

* fix lint
2017-03-10 11:17:09 +01:00
Caleb
24630b1ebe Update to Pyunifi2.0 (#6490)
* Updated pyUnifi

* Missing comma

* Security opt-out, not opt-in

* Adjust minimal values

* Update to pyUnifi 2.0
2017-03-10 11:16:51 +01:00
Caleb
b705b3ddb9 Update to Pyunifi2.0 (#6490)
* Updated pyUnifi

* Missing comma

* Security opt-out, not opt-in

* Adjust minimal values

* Update to pyUnifi 2.0
2017-03-10 11:15:21 +01:00
Craig J. Ward
330d352d3a Insteon lib (#6505)
* use lib with caching to reduce collisions

* use 0.43

* change requirements

* update the  lib to 0.44

* update req

* fix typo

* just keep checking

* just keep checking - switch

* use 0.45 with file cache

* requirements

* Update requirements_all.txt

* Update insteon_local.py

* Update requirements_all.txt

* Update insteon_local.py

* update library

* fix lint
2017-03-10 11:14:31 +01:00
Pascal Vizeli
bdaae6f844 Bugfix android camera autodiscovery settings (#6510)
Add an optional extended description…
2017-03-10 10:14:05 +01:00
Pascal Vizeli
49308bec13 Bugfix android camera autodiscovery settings (#6510)
Add an optional extended description…
2017-03-10 10:10:35 +01:00
Paulus Schoutsen
edd96c2b04 Merge remote-tracking branch 'origin/master' into dev 2017-03-09 21:32:04 -08:00
Robbie Trencheny
11c4d3892f Merge pull request #6001 from jumpkick/patch-2
Improvements for WeMo Insight switches
2017-03-09 21:14:33 -08:00
Robbie Trencheny
75817ad46d Merge pull request #6361 from GreenTurtwig/dev
Updated to catch timeout error
2017-03-09 20:39:20 -08:00
Robbie Trencheny
780cdd5f90 Merge pull request #6389 from Deinara/discord_connect_fix
Discord connect fix
2017-03-09 19:57:29 -08:00
Robbie Trencheny
d70eaeb118 Merge pull request #6407 from jvolkman/patch-1
Small typo fix in setup_docker_prereqs
2017-03-09 19:55:57 -08:00
Robbie Trencheny
9e9c6d0184 Make states constants 2017-03-09 19:55:18 -08:00
Robbie Trencheny
2cdc0febf5 Merge pull request #6494 from armills/kodi-command-exceptions
Catch exceptions on kodi commands
2017-03-09 19:50:53 -08:00
Robbie Trencheny
c721ec7ab0 Merge pull request #6507 from amelchio/longer-light-transitions
Increase upper limit on light transitions (#2843)
2017-03-09 19:50:22 -08:00
Robbie Trencheny
4e63e8328e Merge pull request #6506 from happyleavesaoc/enhance-moon
more moon states
2017-03-09 19:45:40 -08:00
Robbie Trencheny
8f2009a187 Merge pull request #6488 from pvizeli/pydroid-ipcam
Android IP Cam support
2017-03-09 19:41:23 -08:00
Adam Mills
529eee994b Include functools.wraps 2017-03-09 19:52:45 -05:00
Christiaan Blom
3f7dd7ed9a Added an extra space 2017-03-10 00:33:29 +01:00
Christiaan Blom
b952cfe705 Added pylint ignore message and re-added .close() 2017-03-10 00:21:26 +01:00
Anders Melchiorsen
b9cf4df557 Increase upper limit on light transitions (#2843)
This increases the global limit to 6535 seconds (1h48m55s) because that is
supported by all light platforms.

Some platforms support even longer transition times so the limit should
actually be platform specific.
2017-03-09 23:59:35 +01:00
happyleaves
7892297240 more moon states 2017-03-09 16:54:04 -05:00
Pascal Vizeli
20fcd1f0e2 Bugfix mqtt socket memory error (#6501)
* Bugfix mqtt socket memory error

* Fix tests

* Fix lint
2017-03-09 06:31:43 -08:00
pvizeli
8bbf13ef9f Fix lint 2017-03-09 15:10:39 +01:00
Paulus Schoutsen
855756cb2a Add first pass at Z-Wave light tests (#6483)
* Add first pass at Z-Wave light tests

* Remove unused SIGNAL_VALUE

* Lint

* Update test_init.py
2017-03-09 14:35:04 +01:00
pvizeli
bbcfb9158a fix lint 2017-03-09 12:03:08 +01:00
pvizeli
bcd4def0ae pump version 0.3 / make a lot of improvments 2017-03-09 12:00:50 +01:00
Robbie Trencheny
ddc260b628 Add required changes to support MQTT discovery that I previously missed. See #6481. 2017-03-08 23:57:54 -08:00
Robbie Trencheny
06bc062221 MQTT should load the provided platform not DOMAIN
See #6481
2017-03-08 23:53:17 -08:00
Pascal Vizeli
21f3b62d09 fix coverage 2017-03-09 01:03:15 +01:00
Pascal Vizeli
185ccc4fc4 Fix some things 2017-03-09 01:00:57 +01:00
Adam Mills
2d337fd29a Catch exceptions on kodi commands 2017-03-08 15:54:51 -05:00
Paulus Schoutsen
c625e219c7 Not always asume manufacturername is present (#6484) 2017-03-08 08:57:38 -08:00
pvizeli
b1736994b7 fix lint 2017-03-08 17:57:22 +01:00
pvizeli
21feff5fd8 add available 2017-03-08 17:52:49 +01:00
pvizeli
93118fcade Android IP Cam support 2017-03-08 17:48:55 +01:00
ArrayLabs
5e1c74b430 Update pymyq requirement (#6486)
* update pymyq to 0.0.7

* update pymyq requirement

Adds additional state for stopped door.
2017-03-08 16:47:43 +01:00
Reed Riley
3d3a0a7a4f Improved iCloud 2FA support. (#5984) 2017-03-08 12:07:34 +01:00
Colin O'Dell
fdd1957750 Allow configurable conditions for Pi-Hole sensor (#6465)
* Allow configurable conditions for Pi-Hole sensor

* Include all three conditions by default

* Share Pi-Hole API data across all sensors; eliminate redundant API calls
2017-03-07 23:20:30 -08:00
Robbie Trencheny
2b97449d98 Expand MQTT lights (#6481)
* Add effect support to MQTT Light

* Use effect state topic for supported_features

* Dont use rainbow as default color

* Add color_temp support to MQTT JSON Light

* Add effect to MQTT JSON light

* Support lights in MQTT discovery

* Allow discovered devices to set their platform

* Add white value support to MQTT Light

* Add white value support to MQTT JSON Light

* Remove blank line

* Add color_temp support to MQTT Template light

* Add white value support to MQTT Template Light

* Remove unused SUPPORT_MQTT_TEMPLATE and stale unused flash and transition code from MQTT Template

* Add XY Color to MQTT Light Platform

* Fix syntax

* Fix more syntax errors

* Revert "Remove unused SUPPORT_MQTT_TEMPLATE and stale unused flash and transition code from MQTT Template"

This reverts commit c03798cb63.

* MQTT Template supports flash and transition but doesnt allow templating of the values

* Add XY color support to MQTT JSON

* Proper variable names

* Only allow whitelisted MQTT platforms to be loaded via MQTT Discovery

* Minor tweaks.
2017-03-07 23:01:36 -08:00
Pascal Vizeli
c937a7bcb0 Add support for remove services / Reload script support (#6441)
* Add support for remove services / Reload script support

* Reload support for scripts

* Add more unittest for services

* Add unittest for script reload

* Address paulus comments
2017-03-07 22:51:34 -08:00
Pascal Vizeli
e7f442d66b Add dispatcher camera for internal image. (#6471)
* Add dispatcher camera for internal image.

* fix lint

* Add unittest

* Update dispatcher.py
2017-03-07 22:37:23 -08:00
siebert
2c5d3387f2 Fix wake_on_lan ping for Linux. (#6480) 2017-03-07 20:57:35 -08:00
Paulus Schoutsen
bb4f23f8e7 Add warning for slow platforms/components (#6467)
* Add warning for slow platforms/components

* Add test for slow component setup.

* Add test for slow platform setup

* Fix tests on Py34
2017-03-07 20:31:57 -08:00
Kevin Fronczak
629b2e81ba Support for Blink Camera System (#6444)
* Passing pep8, no tests yet

* Fixed some issues with the request throttling

* Removed ability to set throttle time because it was causing more issues than it was worth

* Added blink to .coveragerc

* Changed blinkpy version

* Removed global var, fixed per PR requests

* Added services for camera, migrated switch to binary_sensor

* Added schema for service, fixed naming, removed unused function
2017-03-07 23:26:53 +01:00
Johan Bloemberg
3508f74fb2 Remove connection status state. (#6475)
Current implementation of connection status doesn't follow convention and is not properly configurable. Might be added again in the future as a full fledged entity or some other way.

For now users can rely on error logging to determine connection status.
2017-03-07 23:20:27 +01:00
Kevin Siml
d16bc632da fix issue (#6470)
* fix issue

fix issue: https://community.home-assistant.io/t/error-in-new-notification-pushsafer/13308

* Update pushsafer.py

* Update requirements_all.txt

* Update pushsafer.py

* Update pushsafer.py

* Update pushsafer.py
2017-03-07 21:18:28 +01:00
Paulus Schoutsen
44d4987536 Allow testing against uvloop (#6468) 2017-03-07 10:11:41 +01:00
Paulus Schoutsen
470702261a Upgrade netdisco to 0.9.2 (#6466) 2017-03-06 22:35:49 -08:00
Josh Anderson
5fb7aa212b Send a logo with webostv notifications (#6380)
* Update to pylgtv 0.1.4

* Send icon with webostv notifications

Default to the homeassistant logo, but allow customizing it on the
component and for individual notifications
2017-03-06 20:56:31 -08:00
Barry Williams
9522fe3a92 Bumped version number for supporting lib (#6462) 2017-03-06 20:38:33 -08:00
Markus Peter
ff3c90fb80 KWB Easyfire support (#6018)
* KWB Easyfire Support

* requirements, coverage

* Initialization fun

* lint

* requirements bump

* lint

* Second best validation ...

* changes

* reworked validation
2017-03-06 17:37:29 +01:00
Paulus Schoutsen
90ad54da7d Shorten recorder connection init (#6432)
* Wait up to 9 seconds

* Set number of recorder retries to 8

* Do not sleep when reporting last connection error if no retries left

* Make sure we clean up old engine if connection is retrying

* Update __init__.py
2017-03-06 12:20:12 +01:00
Marcelo Moreira de Mello
2baa838ba7 Added unittest for Ring sensor (#6447)
Add an optional extended description…
2017-03-06 12:15:08 +01:00
Pascal Vizeli
a8add06a40 Bugfix samsungtv discovery (#6438) 2017-03-05 23:52:15 +01:00
Dennis de Greef
1b23b32817 Use bundled certificates if port matches mqtts (#6429)
* Use bundled certificates if port matches mqtts

* Move import requests.certs to top, since it's used in more places

* Add happy and non-happy path tests for default certificate bundle on mqtts port
2017-03-05 14:08:29 -08:00
Andrey
eaaa0442e2 Add a Z-wave workaround to do full refresh on update (#6403)
* Add Zwave refresh services

* services file

* Use dispatcher

* Add zwave prefix to signal

* Add a Z-wave workaround to do full refresh on update
2017-03-05 12:55:52 -08:00
Job Vermeulen
bc9f2d21c4 Tado device_tracker exception when mobile device has geofencing enabled but location is currently unknown. (#6401) 2017-03-05 21:38:14 +01:00
Adam Mills
1a139234af Revert "Use dynamic port allocation for tests" (#6436) 2017-03-05 21:14:21 +01:00
Andrey
d5435cf066 Rename _scheduled_update to _update_scheduled (#6434) 2017-03-05 10:53:47 -08:00
Andrey
46ec6d6dce Delay zwave updates for 100ms to group them. (#6420)
* Add Zwave refresh services

* services file

* Use dispatcher

* Add zwave prefix to signal

* Delay zwave updates for 100ms to group them.

* Fixes

* lint

* Access _scheduled_update from loop thread only.

* More async

* Some optimizations

* Fix
2017-03-05 09:29:59 -08:00
Anders Melchiorsen
660e777f01 Ignore deleted mails in IMAP unread count (#6394) (#6395)
Message deletion in IMAP is a two step process: first delete, then expunge.
Deleting a message just sets a flag that usually makes the mail client hide
the message. It is the expunge that actually removes the message.

Thus, exclude the deleted messages so that the unread count matches up with
that of most mail clients.
2017-03-05 08:15:25 -08:00
Igor Shults
de038bae65 Don't log username and password in camera url (#6390)
* Don't log username and password in camera url

* Attempt fix of tox issues

* Attempt to fix indentation issue
2017-03-05 08:07:09 -08:00
Anders Melchiorsen
7774f0ae53 Set new color before turning LIFX bulbs on (#6402)
A LIFX bulb maintains its previous color even when the light is off.
For example, if the previous color is blue and the bulb is turned on
and then set to a red color, it will transition through purple colors.

After this commit, the target color is set while the bulb is still
turned off. This overrides the previous color and brightness that the
bulb remembered. The light is then turned on with the requested
transition duration.

For the example, this gives the expected result of only going through
red colors.
2017-03-05 11:11:33 +01:00
Paulus Schoutsen
7655b6271d Better restore_state warnings (#6418) 2017-03-05 10:54:49 +01:00
Paulus Schoutsen
10bf659773 Fix unnecessary warning for ip bans.yaml (#6417) 2017-03-05 10:53:21 +01:00
Paulus Schoutsen
e8a22cb4a8 Tweak recorder/restore_state (#6412)
* Tweak recorder/restore_state

* Lint
2017-03-05 10:52:08 +01:00
Paulus Schoutsen
2650c73a89 Split bootstrap into bs + setup (#6416)
* Split bootstrap into bs + setup

* Lint
2017-03-05 10:41:54 +01:00
Thibault Cohen
bdf948d866 Add Mint finance sensor (#6132)
* Add Mint finance sensor

* Add retry

* Fix PR comments

* Upgrade mintapi version

* Update mint_finance.py

* Doc tweak

* Update mint_finance.py
2017-03-05 00:08:58 -08:00
Marcelo Moreira de Mello
928e025910 Added sensors to support Ring.com devices (#6419) 2017-03-05 00:03:00 -08:00
Teemu R
96aae1292b switch.tplink: catch exceptions coming from pyHS100 to avoid flooding the logs when the plug is not available (#6400) 2017-03-05 08:44:34 +01:00
Pascal Vizeli
c0bf3d7f32 Restore flow on device_tracker platform (#6374)
* Restore flow on device_tracker platform

* fix flow

* fix lint
2017-03-05 08:06:53 +01:00
Paulus Schoutsen
307514e3a7 Prevent more I/O in apns (#6413) 2017-03-04 19:57:04 -08:00
Paulus Schoutsen
b939626497 Fix tests no internet (#6411)
* Fix honeywell tests without internet

* Fix device tracker without internet

* Fix MFI using internet during tests

* Remove I/O from apns tests
2017-03-04 17:15:20 -08:00
Johann Kellerman
1522e67351 Restore for automation entities (#6254)
* Restore for automation entities

* coroutine

* no clue what i'm doing now

* Still passes nicely in py 3.4
2017-03-04 15:19:01 -08:00
Pascal Vizeli
8232f1ef65 Cleanup async handling (#6388)
* Cleanups unneeded blocks

* Cleanup bootstrap

* dedicated update_ha_state

* Fix imap_email_content

* fx tests

* Fix lint & spell
2017-03-04 15:10:36 -08:00
Jeremy Volkman
78f5a8a6f8 Small typo fix in setup_docker_prereqs 2017-03-04 12:39:25 -08:00
Daniel Høyer Iversen
3044aecbe9 flux led lib (#6404) 2017-03-04 21:33:24 +01:00
siebert
a5081ac307 Fix wake_on_lan for german version of Windows 10 (#6397) (#6398) 2017-03-04 09:58:01 -08:00
Lev Aronsky
f396a4593e Add keep-alive feature to the generic thermostat (#6040)
* Add keep-alive feature to the generic thermostat

* Comply with maximum line lengths

* Added tests for the keep-alive functionality
2017-03-04 09:42:43 -08:00
Andrey
aac9f972cf Add Zwave refresh services (#6377)
* Add Zwave refresh services

* services file

* Use dispatcher

* Add zwave prefix to signal
2017-03-04 09:13:24 -08:00
Thibault Cohen
aaa0944595 Add multi contracts support for Hydroquebec (#6392) 2017-03-04 09:11:58 +01:00
Paulus Schoutsen
6cca127bbf Merge pull request #6384 from home-assistant/release-0-39-3
0.39.3
2017-03-03 19:24:29 -08:00
Christiaan Blom
c1f3ce78e1 Edit docstring 2017-03-04 01:48:47 +01:00
Christiaan Blom
887b53b794 Changes for Travis bot. Unused variable 'on_ready' will likely remain reported 2017-03-04 01:31:19 +01:00
Christiaan Blom
a444df3fde tweaks 2017-03-04 01:03:10 +01:00
Christiaan Blom
b038a1650e Resolved issue #5688 2017-03-03 23:15:03 +01:00
joe248
483556ac5b Comed Hourly Pricing sensor (#6378)
* Add ComEd RRTP price sensor

* Update wording to reflect ComEd's naming change from 'RRTP' to 'Hourly Pricing'

* Changed name of sensor source file

* Cleanup based on requested changes

* More cleanup

* small cleanups
2017-03-03 23:14:22 +01:00
Paulus Schoutsen
3e9e388745 Version bump to 0.39.3 2017-03-03 13:15:07 -08:00
Colin O'Dell
ab42acf4d7 Don't initialize components which have already been discovered (#6381)
* Don't initialize components which have already been discovered (fixes #5588)

* Don't log that we've found a service unless we know it's not a duplicate

* Encode discovery data hash with JSON

This also solves the issue of trying to hash non-hashable objects like dicts

* Add test for duplicate device discovery
2017-03-03 13:13:04 -08:00
Colin O'Dell
0489ae53c4 Don't initialize components which have already been discovered (#6381)
* Don't initialize components which have already been discovered (fixes #5588)

* Don't log that we've found a service unless we know it's not a duplicate

* Encode discovery data hash with JSON

This also solves the issue of trying to hash non-hashable objects like dicts

* Add test for duplicate device discovery
2017-03-03 13:11:40 -08:00
John Mihalic
35fcc299c0 Update Hikvision Binary Sensors to latest library, remove pyDispatcher (#6231)
* Update pyHik version, remove pyDispatcher in favor of callbacks

* Fix naming

* Fix lint blank line

* Move stream thread start to HOMEASSISTANT_START event

* Bump library version to cleanup shutdown

* Fix requirements
2017-03-03 15:11:30 +01:00
Valentin Alexeev
568c549353 Update pwaqi to 3.0 to use public API (#6376)
The underlying PWAQI library version 3.0 is now using public API to
access AQICN data.
2017-03-03 14:50:54 +01:00
Paulus Schoutsen
edf130b341 Z-Wave prevent I/O event loop (#6369)
* Prevent Z-Wave I/O in event loop

* Move value_handler to util class.

* Add docstring
2017-03-03 14:47:59 +02:00
Pascal Vizeli
ed9e93c29f Migrate mqtt tracker and arwn sensor to async / cleanup owntrack (#6373)
* Migrate mqtt tracker and arwn sensor to async / cleanup owntrack

* Fix tests / lint
2017-03-03 12:09:10 +01:00
Pascal Vizeli
55f8ec8866 Fix possibility that have multible topic subscribe mqtt (#6372) 2017-03-03 10:05:52 +01:00
Pascal Vizeli
3e70154695 OwnTrack Async (#6363)
* Migrate owntrack to async

* fix tests
2017-03-03 09:23:58 +01:00
Andrey
aa17481c94 Add Z-Wave battery level as a sensor. (#6341) 2017-03-03 09:19:06 +02:00
happyleavesaoc
b53bc24a63 twilio component (#6348)
* twilio component

* add http dependency to twilio

* fire->async_fire
2017-03-03 08:14:51 +01:00
Johann Kellerman
fbd0bf77c7 [recorder] Catch more startup errors #6179 (#6192)
* [recorder] Catch more startup errors #6179

* Rebase on new recorder
2017-03-02 22:44:52 -08:00
Jose Juan Montes
4da2156ebf Return None instead of raising ValueException from as_timestamp template function. (#6155) 2017-03-02 22:18:01 -08:00
Open Home Automation
8a67fcfee3 Added IPv4 data collector (#6304)
* Added IPv4 data collector

* Formatting

* Bugfix: data is in kBit/s not kByte/s
2017-03-02 22:16:50 -08:00
Pascal Vizeli
08f9793175 Restore for input_slider (#6360) 2017-03-02 08:36:26 -08:00
Pascal Vizeli
a5b2fc9759 Bugfix new async_add_devices function (#6362) 2017-03-02 17:27:45 +01:00
Micha LaQua
3fa8aff78e snmp: upgrade pysnmp to 4.3.4 (#6359)
* snmp: upgrade pysnmp to 4.3.4

fixes https://github.com/home-assistant/home-assistant/issues/6238

* snmp: v4.3.4: add missing definition changes
2017-03-02 16:12:44 +01:00
Rowan
09ff9cb08e Updated to catch timeout error 2017-03-02 14:58:35 +00:00
Jan Losinski
c32300a386 Bump limitlessled dependency to 1.0.5. (#6334)
This fixes issue #6295.
2017-03-02 14:18:44 +01:00
Pascal Vizeli
55dc483c91 Template switch change flow / add restore (#6356)
* Template switch change flow / add restore

* fix tests

* fix binary_sensor template
2017-03-02 14:09:53 +01:00
Andrey
597ae2e716 Zwave: Add remove/replace failed node services. (#6248)
* Zwave: Add remove/replace failed node services.

* Fix text
2017-03-02 12:36:40 +01:00
Pascal Vizeli
50887e7e2c Move dispatcher out of init. (#6355) 2017-03-02 10:20:57 +01:00
Alan Fischer
8743f23f13 Fix calendar authentication text, and handle calendar events without summaries. (#6337)
* Fixed google authorization text

* Let calendar handle events without a summary
2017-03-02 00:22:38 -08:00
Jeff Wilson
72fe50bef6 Fix command sudo not found error in dev Dockerfile (#6346) 2017-03-02 00:14:20 -08:00
Pierre Ståhl
bae6333c26 Use push updates in Apple TV (#6323)
* Use push updates in Apple TV

* Fix review comments
2017-03-02 00:12:55 -08:00
martinfrancois
a08539d88d Added support for multiple codes executed in a row (#5908)
* Added support for multiple codes executed in a row

now codes can be specified either by simply providing a single code, which will then be sent like usual, or multiple codes can be executed in a row, specified in a comma delimited format in the configuration.yaml. For example: 111111,222222,333333,444444 would mean 111111 would be sent first, followed by 222222 and 333333 and 444444.

* rpi_rf: added line breaks to not exceed 79 characters per line

* include validation for correct formatting of codes

added regex which only allows either a single number (like 1252456245) or a sequence of commas followed by another number.

* added line breaks to not exceed 79 characters per line

* fix for 'continuation line under-indented for visual indent'

* another try at 'continuation line under-indented for visual indent'

* changed from regex to list for easier maintainability

* removed unnecessary splitting of strings
2017-03-02 00:10:49 -08:00
Adam Mills
bf7aecce90 Use dynamic ports for test instances (#6232) 2017-03-02 00:07:50 -08:00
Paulus Schoutsen
e2aa024a05 Update coveragerc 2017-03-02 00:06:26 -08:00
dramamoose
edd5db296d Update Formulas in Convert XY to RGB (#6322)
* Update to Current RGB D65 Conversion

As per Philips Hue https://developers.meethue.com/documentation/color-conversions-rgb-xy

* Update the source of the XYZ to RGB formulas

* Fix Whitespace

* Update Whitespace

* Update Tests for new Formulas

* Update Tests

* Update XY_Brightness_to_hsv tests

* Update test_color.py
2017-03-02 08:54:45 +01:00
Duoxilian
e14d6f11c6 Additional support for ecobee hold mode (#6258)
* Integrate suggestion in #5590 by nordlead2005. This change has been
sitting in limbo for over a month, but it is a good idea. I don't
mean to step on nordlead2005's toes, but we need to make progress.

* Use defined constant for TEMPERATURE_HOLD

* Integrate handling of vacation into hold mode. Canceling vacation
hold requires an update to the external pyecobee library. Creation
of vacation is not supported (it would be straightforward in the code,
but a complex user interface would be required, similar to what is
now done in the ecobee thermostat).

* Add capability to retrieve list of defined climates from ecobee.

* The mode() method used to return the system mode in internal
representation. However, the user sees a different notation in
the ecobee thermostat. Seeing some internal name is particularly
weired with user-defined climates, where these are named "smart1",
"smart2", etc., instead of the name the user has defined. Return
the user-defined name instead. This change might break some user
interfaces but is easily remedied (e.g., use "Away" instead of
"away").

* Simplify is_away_mode_on().

* Correction of erroneously indented else statement.

* Change comment as flake8 gets confused.
2017-03-01 23:52:31 -08:00
Pascal Vizeli
f3870a8a48 Template binary_sensor change flow / add restore (#6343)
* Template binary_sensor change flow / add restore

* fix lint
2017-03-02 08:50:41 +01:00
Thibault Cohen
31bf5b8ff0 Improve Honeywell US climate component (#5313)
* Improve Honeywell US climate component

* Fix tests

* Fix tests

* Add cool_away_temp and heat_away_temp for honeywell US

* Fix honeywell tests

* Fix PR comments
2017-03-01 23:49:49 -08:00
Paulus Schoutsen
a7ae456a06 Merge remote-tracking branch 'origin/master' into dev 2017-03-01 23:44:11 -08:00
Reed Riley
c03022efa3 Add fallback for name if userdevicename isn't set using old serialnumber logic (#6265)
Add an optional extended description…
2017-03-02 08:41:31 +01:00
Mitko Masarliev
46f5a65e68 Update Adafruit_Python_DHT to support new raspberry kernel (#6325)
* Update Adafruit_Python_DHT to support new raspberry kernel

* update Adafruit Python DHT
2017-03-02 08:39:33 +01:00
Alexander Fortin
44ec6b056e Update Vagrant provision.sh (#6236)
- Bugfix: with f63a79ee we removed `script/home-assistant@.service`
  systemd unit file, which is used by Vagrant box to start/stop hass
- simplify interaction with Vagrant, provision.sh now is the only
  entry point and doesn't need the user to touch/remove files in
  order to change provisioner behavior
2017-03-01 23:15:30 -08:00
Andrey
354007f265 Zwave optimize value_added (#6210)
* Make zwave devices listen on less network changes.

* Convert more platforms

* Remove printouts.

* Fix copy-paste

* Change default dependent list to empty list
2017-03-01 22:41:19 -08:00
Pascal Vizeli
6cb8a36cf1 Template sensor change flow / add restore (#6336) 2017-03-02 07:38:19 +02:00
Fabian Affolter
435f253be8 Upgrade py-cpuinfo to 0.2.6 (#6335) 2017-03-02 05:58:03 +01:00
Fabian Affolter
0fe41ffb00 Upgrade TwitterAPI to 2.4.5 (#6351) 2017-03-02 05:57:51 +01:00
Martin Hjelmare
bafa0cc3b8 Fix mysensors callback race (#6311)
* Fix possible race at startup in mysensors callback

* Update devices via persistence before starting gateway to avoid
  two threads calling the same callback at the same time.

* Call add_devices max once per callback
2017-03-01 23:09:27 +01:00
Erik Eriksson
e23aa1ccf8 sensor.dovado: compute state in update (#6340) 2017-03-01 22:57:37 +01:00
Paulus Schoutsen
a9db6b16eb Merge pull request #6339 from home-assistant/release-0-39-2
0.39.2
2017-03-01 12:43:00 -08:00
Paulus Schoutsen
bf30f2e9e8 Version bump to 0.39.2 2017-03-01 09:29:34 -08:00
Paulus Schoutsen
ee9d50c0a5 Bump netdisco to 0.9.1 (#6338) 2017-03-01 09:29:14 -08:00
Paulus Schoutsen
6736534a52 Discovery fix (#6321)
* Fix incorrect import

* Create own discovery service

* Fix tests

* Fix hdmi_cec bad import
2017-03-01 09:28:49 -08:00
Paulus Schoutsen
4ccd819ec5 Bump netdisco to 0.9.1 (#6338) 2017-03-01 09:05:05 -08:00
Pascal Vizeli
52b1e13aca Bugfix ZigBee / Move from eventbus to dispatcher (#6333)
* Bugfix ZigBee / Move from eventbus to dispatcher

* fix lint
2017-03-01 08:57:53 -08:00
Pascal Vizeli
67f3910f03 Bugfix ZigBee / Move from eventbus to dispatcher (#6333)
* Bugfix ZigBee / Move from eventbus to dispatcher

* fix lint
2017-03-01 08:57:23 -08:00
Paulus Schoutsen
64cb3390ea Test against 3.6-dev (#6324) 2017-03-01 08:53:40 -08:00
Paulus Schoutsen
0ac4a152be Discovery fix (#6321)
* Fix incorrect import

* Create own discovery service

* Fix tests

* Fix hdmi_cec bad import
2017-03-01 07:38:49 -08:00
Pascal Vizeli
4e96e461f7 Cleanup component track_point_in_utc_time usage (#6330) 2017-03-01 07:37:48 -08:00
Stefano Scipioni
30bed8341a Telegram webhooks new text event (#6301)
* new TELEGRAM_TEXT

* telegram command event renamed in 'telegram_command'

* fire telegram_text event anyway
2017-03-01 12:15:16 +01:00
Erik Eriksson
d17733427b Merge pull request #6329 from molobrakos/dovado
sensor.dovado: Upgraded library version
2017-03-01 12:02:58 +01:00
Erik Eriksson
782d2a30cd Merge pull request #6328 from molobrakos/eliqonline
sensor.eliqonline: Change to more appropriate icon
2017-03-01 11:52:44 +01:00
Paulus Schoutsen
84f30d9ef8 Bootstrap tweaks tests (#6326)
* Update strings/fix component not found message.

* Fix tests

* More tweak text
2017-02-28 23:42:31 -08:00
Johann Kellerman
ac49298c8d Log errors when loading yaml (#6257) 2017-03-01 06:56:23 +02:00
jumpkick
a0256e1947 Rollback netdisco to 0.8.2 to resolve #6165 (#6314)
* Rollback netdisco to 0.8.2 to resolve #6165

* Rollback netdisco to 0.8.2 to resolve #6165
2017-02-28 20:37:56 -08:00
ericgingras
7bc2e1238d Convert kpH and mpH to kph and mph (#6316)
There is no reason for the H to be capitalized. Changing it to lowercase increases consistency with other components and allows for use of the min/max sensor, which throws an error if the units of measurement are not the same.
2017-03-01 05:34:40 +01:00
Pascal Vizeli
41f558b181 Bootstrap / Component setup async (#6264)
* Bootstrap / Entiy setup async

* Cleanup add_job stuff / return task/future object

* Address paulus comments / part 1

* fix install pip

* Cleanup bootstrap / move config stuff to config.py

* Make demo async

* Further bootstrap improvement

* Address Martin's comments

* Fix initial tests

* Fix final tests

* Fix bug with prepare loader

* Remove no longer needed things

* Log error when invalid config

* More cleanup

* Cleanups platform events & fix lint

* Use a non blocking add_entities callback for platform

* Fix Autoamtion is setup befor entity is ready

* Better automation fix

* Address paulus comments

* Typo

* fix lint

* rename functions

* fix tests

* fix test

* change exceptions

* fix spell
2017-02-28 20:33:19 -08:00
Adam Mills
383b0914b3 Version bump to 0.40.0.dev0 2017-02-28 11:01:19 -05:00
Krasimir Zhelev
be297c4c7e Frontier silicon (#6131)
* added frontier_silicon constant

* added the frontier_silicon component

* cleaning up according to travis

* trying to satisfy pylint

* trying to satisfy pylint

* fsapi version 0.0.6

* with fsapi version 0.0.7

* added fsapi dependency

* yielding the FSAPI

* Removing white space from docstring

* Removing white space from an empty line

* Switching to sync

* clean up white spaces and rename device to FSAPIDevice

* added frontier_silicon constant

* added the frontier_silicon component

* cleaning up according to travis

* trying to satisfy pylint

* trying to satisfy pylint

* fsapi version 0.0.6

* with fsapi version 0.0.7

* added fsapi dependency

* yielding the FSAPI

* Removing white space from docstring

* Removing white space from an empty line

* Switching to sync

* clean up white spaces and rename device to FSAPIDevice

* changed info to debug

* added frontier_silicon constant

* added the frontier_silicon component

* cleaning up according to travis

* trying to satisfy pylint

* trying to satisfy pylint

* fsapi version 0.0.6

* with fsapi version 0.0.7

* added fsapi dependency

* yielding the FSAPI

* Removing white space from docstring

* Removing white space from an empty line

* Switching to sync

* clean up white spaces and rename device to FSAPIDevice

* added the frontier_silicon component

* trying to satisfy pylint

* fsapi version 0.0.6

* remove white space

* generated requirements

* added the frontier_silicon component

* cleaning up according to travis

* trying to satisfy pylint

* trying to satisfy pylint

* fsapi version 0.0.6

* with fsapi version 0.0.7

* added fsapi dependency

* yielding the FSAPI

* Removing white space from docstring

* Removing white space from an empty line

* Switching to sync

* clean up white spaces and rename device to FSAPIDevice

* trying to satisfy pylint

* changed info to debug

* added the frontier_silicon component

* fsapi version 0.0.6

* generated requirements

* pylint

* moved import requests to the method where it is being used

* add a basic unit test

* cleaned up source code

* added frontier_silicon constant

* added the frontier_silicon component

* added basic test

* added fsapi to requirements_all.txt

* added coverage omit, though a basic test was included

* added MEDIA_TYPE_MUSIC for artist and album

* removed duplicate cons

* switched fsapi call to a property, removed unecessary comment

* detailed docstring for fs_device

* added a space for the info_name - info_text separator

* reduced proeprty (fsapi) access for volume down/up
2017-02-28 09:23:07 -05:00
Pascal Vizeli
aa1f64bed6 Migrate calendar setup to async. (#6305) 2017-02-28 10:49:06 +01:00
Adam Mills
faf8bbcf13 Fix toggle and media_play_pause post async (#6291) 2017-02-27 19:55:34 -08:00
Open Home Automation
0fa259089d Influx fix (#6289)
* Fix: replace influxdb query by another query that is more lightweight and won't timeout

* Fix: replace influxdb query by another query that is more lightweight and won't timeout
2017-02-27 19:54:43 -08:00
Alan Fischer
f7c7073cd7 Updated pyitachip2ir (#6296)
* Updated pyitachip2ir

* Updated requirements_all.txt
2017-02-27 19:52:32 -08:00
Boris K
d7bf3920a5 improve history_stats accuracy (#6294) 2017-02-27 19:52:10 -08:00
Andrey
7ee75d67c5 Add temperature support for MH-Z19 CO2 sensor. (#6169)
* Add temperature support for MH-Z19 CO2 sensor.

* Remove debug printout

* More tests

* Minor fixes
2017-02-27 21:19:11 +02:00
arjenfvellinga
d7db3aba36 Prevent duplicate names on Vera devices by appending the device id (#6100)
* Prevent duplicate names by prepending device id to it.

* Always append device id, not conditionally.

* Moved naming of devices

* flake8
2017-02-27 18:57:39 +00:00
Lindsay Ward
7f99e99dad Update library version for Yeelight Sunflower lights platform (fix for packaging problem with 0.0.7) (#6233) 2017-02-27 13:47:51 -05:00
Greg Dowling
fbea5b4cac Merge pull request #6278 from home-assistant/fix_vera_thormostat_bug
Fix vera thermostat bug
2017-02-27 10:55:33 +00:00
Daniel Perna
e6c88c05ad [sensor.dnsip] New Sensor: DNS IP (#6214)
* Added DNS IP sensor

* Removed unused import

* Added coverage

* fixed flake

* Applied suggested changes

* Removed debug code

* Switched to aiodns

* Raised scan interval

* Updating state with entity creation

* Lint

* Updated requirements_all
2017-02-27 10:45:32 +00:00
pavoni
757813411d Fix vera thermostat mode set bug 2017-02-27 10:18:22 +00:00
TimV
7dc05785cc Analog modem callerid support (#5840)
* analog-modem-callerid

* analog-modem-callerid

* analog-mod

* Updates from latest review

* Updates from latest review
2017-02-26 21:38:47 -08:00
Wolf-Bastian Pöttner
d7af43b87d Add support for MAX!Cube thermostats and window shutter sensors (#6105) 2017-02-26 21:35:33 -08:00
groth-its
6ea74ce740 Fix for OSRAM lights connected to hue bridge (#6122)
* Fix for OSRAM lights connected to hue bridge

Do not send command "effect = none" to OSRAM lights
Osram lights connected to a hue bridge do not seem to handle "effect =
none" very well. Most of the times they jump to the selected color and
then change to red within a second.

Osram lights connected to a hue bridge do not handle xy values outside
of their gamut. Since they just stay at their old color value, handling
the UI is very unpredictable. Sending HSV values to the lights fixes this.

* Add tests for new util methods
2017-02-26 21:28:31 -08:00
Nate
d5bdf7783e light.transition now supports float instead of int in order to be able to perform faster transitions (#6163) 2017-02-26 21:21:12 -08:00
Jose Juan Montes
65d255a626 Local file camera now supports yet inexisting files. (#6157) 2017-02-26 21:16:11 -08:00
Jeff Wilson
53a735a329 Properly report features for each hue bulb type (#6271) 2017-02-26 20:59:23 -08:00
Paulus Schoutsen
68713822fd Merge pull request #6272 from home-assistant/release-0-39-1
0.39.1
2017-02-26 20:48:57 -08:00
Pascal Vizeli
3d26ac3323 Bugfix mqtt paho client to speend time (#6266) 2017-02-26 20:31:11 -08:00
Paulus Schoutsen
d487960ad8 Config fix (#6261) 2017-02-26 20:31:11 -08:00
Pascal Vizeli
9403cdd2a5 Bugfix mqtt socket error (#6256) 2017-02-26 20:31:11 -08:00
Paulus Schoutsen
1fb1a32c9a Version bump to 0.39.1 2017-02-26 20:30:21 -08:00
Pascal Vizeli
31ddcc6278 Bugfix mqtt paho client to speend time (#6266) 2017-02-26 15:28:54 -08:00
Paulus Schoutsen
d789de9ea2 Config fix (#6261) 2017-02-26 15:28:12 -08:00
Scott Henning
e2014eb153 Notify ciscospark (#6130)
* Adding ciscospark notifier

* Adding ciscospark notifier

* CI cleanup.

* houndci-bot changes

* ok --- a bunch of code verify changes
2017-02-26 15:04:30 -08:00
Pascal Vizeli
5932446508 Bugfix mqtt socket error (#6256) 2017-02-26 14:43:02 -08:00
Paulus Schoutsen
61909e873f Feature/reorg recorder (#6237)
* Re-organize recorder

* Fix history

* Fix history stats

* Fix restore state

* Lint

* Fix session reconfigure

* Move imports around

* Do not start recording till HASS started

* Lint

* Fix logbook

* Fix race condition recorder init

* Better reporting on errors
2017-02-26 14:38:06 -08:00
Pascal Vizeli
48cf7a4af9 Move ffmpeg to dispatcher from hass.data entity store. (#6211)
* Move ffmpeg to dispatcher from hass.data entity store.

* fix lint

* address paulus comments

* add more unittest for better coverage
2017-02-26 14:31:46 -08:00
Pierre Ståhl
9490cb4c8f Add service to change log levels (#6221)
* Add service to change log levels

* Fix review comments
2017-02-26 14:15:44 -08:00
Paulus Schoutsen
86d4d10176 Ensure we properly close HASS instances. (#6234) 2017-02-26 14:05:18 -08:00
Philipp Schmitt
7b3b755aaf Fix livebox-play interactions for Python < 3.6 (#6243) 2017-02-26 14:04:22 -08:00
Paulus Schoutsen
f5a1cd5b3c Merge pull request #6229 from home-assistant/release-0-39
Fix recorder async (#6228)
2017-02-25 15:23:55 -08:00
Paulus Schoutsen
7b9f7889d2 Fix recorder async (#6228) 2017-02-25 15:22:23 -08:00
Paulus Schoutsen
9afcbaed1d Fix recorder async (#6228) 2017-02-25 15:21:40 -08:00
Paulus Schoutsen
58f9455604 Merge pull request #6227 from home-assistant/release-0-39
Release 0 39
2017-02-25 15:04:54 -08:00
Paulus Schoutsen
596f7b99f6 Update frontend 2017-02-25 15:03:54 -08:00
Johann Kellerman
94183e1992 No wait for start and more async 2017-02-25 15:03:54 -08:00
Johann Kellerman
0e5df9b641 Allow 4.5min startup time for recorder 2017-02-25 15:03:54 -08:00
Paulus Schoutsen
3a7cc9bb45 Update frontend 2017-02-25 15:03:24 -08:00
Paulus Schoutsen
ecd1da6525 Merge pull request #6167 from kellerza/recorder_timer
Recorder async & remove start_recording event
2017-02-25 15:01:29 -08:00
Paulus Schoutsen
a19a285bb0 Merge pull request #6199 from home-assistant/release-0-39
0.39
2017-02-25 14:36:17 -08:00
Andrey
eb36174b51 Make glob preserve order (#6224) 2017-02-25 14:35:27 -08:00
Fabian Affolter
6e51f7d987 Update regex (#6216) 2017-02-25 14:35:27 -08:00
Lindsay Ward
4ba9020859 Update Yeelight Sunflower light platform to 0.0.6 (#6208)
Add an optional extended description…
2017-02-25 14:35:27 -08:00
Paulus Schoutsen
505725f9d3 Fix reporting on bad login (#6201) 2017-02-25 14:35:27 -08:00
Paulus Schoutsen
2566d01aaa Remove automatically reloading group config (#6197) 2017-02-25 14:35:27 -08:00
Johann Kellerman
477f621705 Bugfix restore startup state (#6189) 2017-02-25 14:35:27 -08:00
Pascal Vizeli
7fcc3ae00a Refactory of envisalink (#6160)
* Refactory of envisalink

* remove event buss

* init dispatcher from hass.

* Move platform to new dispatcher

* fix lint

* add unittest & threadded functions

* fix copy & past error
2017-02-25 14:35:27 -08:00
Fabian Affolter
9f2719bb1f Update regex (#6216) 2017-02-25 12:55:01 -08:00
Andrey
85d0f2e861 Make glob preserve order (#6224) 2017-02-25 12:54:04 -08:00
Paulus Schoutsen
a44d849405 Version bump to 0.39 2017-02-25 12:53:23 -08:00
Johann Kellerman
5d007e636b No wait for start and more async 2017-02-25 17:51:37 +02:00
Johann Kellerman
7cd6f9038c Allow 4.5min startup time for recorder 2017-02-25 17:28:53 +02:00
Fabian Affolter
a80fd2f243 Fix link (#6219) 2017-02-25 13:24:43 +01:00
Erik
2487d27c45 sensor.eliqonline: Change icon 2017-02-25 12:51:48 +01:00
Erik
be7162a0df sensor.dovado: Upgraded library version 2017-02-25 12:50:10 +01:00
Andrey
c5a8372f13 Update flake8 and pylint to latest (#6217) 2017-02-25 09:44:22 +01:00
Pascal Vizeli
81ca978413 Move mqtt from eventbus to dispatcher / add unsub for dispatcher (#6206)
* Move mqtt from eventbus to dispatcher / add unsub for dispatcher

* Fix lint

* Fix test

* Fix lint v2

* fix dispatcher_send
2017-02-24 17:11:50 -08:00
Paulus Schoutsen
d6818c7015 Fix reporting on bad login (#6201) 2017-02-24 16:33:58 -08:00
Greg Dowling
df5866dd95 Merge pull request #6213 from home-assistant/bump_pyloopenergy
Bump pyloopenergy - catch socketIO exceptions.
2017-02-24 22:16:03 +00:00
pavoni
34ee2b1ae9 Bump pyloopenergy - catch socketIO exceptions. 2017-02-24 22:04:41 +00:00
Zac Hatfield Dodds
8ca897da57 Zamg weather (#5894)
* Fast & efficient updates for ZAMG weather data

ZAMG updates on the hour, so instead of checking every half-hour we can
check each minute - only after the observations are taken until
receiving them.

* sensor.zamg: test instead of whitelist for station_id

* Autodetect closest ZAMG station if not given

* ZAMG weather component, based on the sensor

* Review improvements

* Update to new ZAMG schema, add logging

Turns out it wasn't a typo, but rather an upstream schema change.  Added
better error handling to ease diagnosis in case it happens again.

* No hardcoded name
2017-02-24 22:45:46 +01:00
Lev Aronsky
c7fcd98cad Test the temperature returned by RM2 (#6205)
* Test the temperature returned by RM2
* Validate fields via voluptuous
* Fixed range for humidity
2017-02-24 20:54:31 +01:00
Erik Eriksson
8aa3124aa6 sensor.speedtest: provide a default icon (#6207) 2017-02-24 18:40:52 +01:00
Andrey
b27ba9660b Some zwave cleanup (#6203) 2017-02-24 16:17:27 +02:00
Lindsay Ward
9f04b55572 Update Yeelight Sunflower light platform to 0.0.6 (#6208)
Add an optional extended description…
2017-02-24 14:13:55 +01:00
Daniel Høyer Iversen
c4f4a9a158 minor broadlink fix (#6202) 2017-02-24 09:49:42 +01:00
Paulus Schoutsen
e2e8b43902 Default config to setup group editor (#6198) 2017-02-23 22:53:16 -08:00
Paulus Schoutsen
3a35642dc1 Remove automatically reloading group config (#6197) 2017-02-23 22:40:21 -08:00
Paulus Schoutsen
34a7aa2376 Extend test for group config 2017-02-23 21:57:48 -08:00
Paulus Schoutsen
58eb32bce4 Random test fixes (#6195)
* Store persistent errors in hass (speeds up tests)

* Fix sleepiq test dependency on test order

* Fix sleepiq validation
2017-02-23 21:44:47 -08:00
Johann Kellerman
c940d26f07 Bugfix restore startup state (#6189) 2017-02-23 20:06:21 -08:00
jumpkick
fc5e25a07b Incorporate comment suggestions
- Separate attribs from coffeemaker condition
- Set power units for threshold to mW to be consistent with others
- Adjust on-time labels to be more clear
2017-02-23 18:03:49 -05:00
Andrey
1d32bced1c Create zwave devices on OZW thread and only add them during discovery (#6096)
* Create zwave devices on OZW thread and only add them during discovery.

* Read and write devices dict from loop thread.

* More async

* replace callback with coroutine

* import common function instead of callin git
2017-02-23 13:06:28 -08:00
Pascal Vizeli
f2a2d6bfa1 Refactory of envisalink (#6160)
* Refactory of envisalink

* remove event buss

* init dispatcher from hass.

* Move platform to new dispatcher

* fix lint

* add unittest & threadded functions

* fix copy & past error
2017-02-23 13:02:56 -08:00
Colin O'Dell
4f990ce488 Use H2 headers to split up the different sections (#6183)
Using headers makes it easier to visually differentiate between the different sections
2017-02-23 12:58:18 -08:00
Pascal Vizeli
106b7a9d8f Cleanup run_callback_threadsafe (#6187)
* Cleanup run_callback_threadsafe

* fix spell

* Revert image_processing, they need to wait for update
2017-02-23 12:57:25 -08:00
Pascal Vizeli
1cd1facbd0 Add device_class to image_processing (#6186)
* Add image_processing device_class

* Fix comments

* address comments
2017-02-23 17:33:54 +01:00
Pascal Vizeli
b725eaf67f Homematic icon map / upper case on services (#6178)
* Set upper on service / add sensor icon mapper

* Add more icons

* fix id
2017-02-23 15:31:32 +01:00
Colin O'Dell
89807f24ad QNAP update (#6182)
* Bump qnapstats library to 0.2.3

* Expose the new timeout setting

* Show persistent notification if QNAP fails to set up

This sitaution will usually occur if the server configuration is wrong or the
timeout is set too low.  In both cases `api.update()` will fail, which is a
problem because we cannot initialize many of the sensors without having this
data.

* Add new system_temp condition to QNAP sensor
2017-02-23 15:01:25 +01:00
Erik Eriksson
7935c54420 's' is SI symbol for seconds (#6181) 2017-02-23 14:57:51 +01:00
Erik Eriksson
46d0d38444 Merge pull request #6180 from home-assistant/molobrakos-patch-1
volvooncall: icon and unit were mixed
2017-02-23 13:28:03 +01:00
Erik Eriksson
5da110d764 volvooncall: icon and unit were mixed 2017-02-23 13:27:17 +01:00
Erik Eriksson
c88527ce79 Merge pull request #6177 from molobrakos/volvooncall
volvooncall: support for naming vehicle and selecting what attributes to display
2017-02-23 13:00:11 +01:00
Erik Eriksson
6127173d2a cache name in entity so we can display it even if the connection is lost (#6176)
update tellduslive dependency
check return value from update
2017-02-23 12:37:25 +01:00
Erik
1c6ba989a9 Support for naming vehicle. Support for selecting what resources to display 2017-02-23 12:00:51 +01:00
Erik Eriksson
827e3c4395 Merge pull request #6162 from molobrakos/nut
sensor.nut: Handle multiple statuses returned
2017-02-23 11:56:25 +01:00
Pierre Ståhl
eefedaf332 Make it possible to ignore platforms in discovery (#6048)
* Make it possible to ignore platforms in discovery

* Add tests for discovery component

* small cleanups
2017-02-23 11:54:35 +01:00
Fabian Affolter
ac1e811dcd Upgrade slacker to 0.9.42 (#6173) 2017-02-23 10:56:35 +01:00
Fabian Affolter
49b4cd3c41 Upgrade fuzzywuzzy to 0.15.0 (#6175)
Add an optional extended description…
2017-02-23 10:56:00 +01:00
jumpkick
ef87d4dad4 Update device_state_attributes only
This gets rid of the other stuff and just updates device_state_attributes, leaving the default properties alone.
2017-02-23 04:54:09 -05:00
Barry Williams
960af20cc9 Added Openhome Support (#6153)
* Added Openhome Support

* added to coveragerc

* PR suggestions

* revert accidental deletion

* More PR suggestions and a lint fix

* Removed semicolons
2017-02-22 17:01:06 -05:00
Daniel Høyer Iversen
6c91e04852 Refactor broadlink (#6168)
* refactor broadlink

* typo
2017-02-22 22:11:49 +01:00
Johann Kellerman
74837dbf45 Restore for device_tracker (#6150) 2017-02-22 22:55:11 +02:00
Erik Eriksson
3b693d5e70 generic camera: improved exception handling (#6158)
Avoid unhandled exception and stack trace when server closes connection by changing from handle ClientDisconnectedError to DisconnectedError. Also added HttpProcessingError, which was missing.
2017-02-22 07:43:52 -08:00
Erik
23dd76cdc5 Handle UPS:es that returns more than one status (e.g. 'OL CHRG'). 2017-02-22 14:38:00 +01:00
Greg Dowling
896e0476ff Bump pywemo version. Improves notifications for insight devices. (#6159)
Add an optional extended description…
2017-02-22 12:23:25 +01:00
Pascal Vizeli
b0d3bbed79 Convert mqtt platforms to async (#6145)
* Convert mqtt platforms to async

* fix lint

* add more platforms

* convert mqtt_eventstream

* fix lint / add mqtt_room

* fix lint

* fix test part 1

* fix test part 2

* fix out of memory bug

* address comments
2017-02-22 09:43:22 +01:00
Erik Eriksson
65ed85c6eb volvooncall: fix missing property. see vehicle when discovered. (#6144) 2017-02-22 00:24:42 -08:00
Johann Kellerman
aee8758fc1 Restore input_select and test helper proposal (#6148)
* Restore input_select and test helper proposal

* DB still active
2017-02-22 00:15:48 -08:00
Pascal Vizeli
8983b826c4 Bugfix automation state linsteners (#6120)
* Bugfix automation state linsteners

* address paulus comments.

* fix lint

* fix lint v2
2017-02-22 00:02:37 -08:00
Johann Kellerman
11d3093a30 Restore: migrate fastdotcom and speedtest to restore (#6149) 2017-02-21 18:10:09 -08:00
Erik Eriksson
15e8a22100 dovado: GiB -> GB (#6143) 2017-02-21 18:54:20 -05:00
Pascal Vizeli
10fb30e924 Update jinja to 2.9.5 (#6146) 2017-02-21 09:05:44 -08:00
Justin Dray
b7b1429ac7 Add support for waking up Samsung TVs over the network (#6114)
* Add support for waking up Samsung TVs over the network

* Return the correct supported features for samsungtv

* Update requirements_all
2017-02-21 16:57:29 +01:00
Daniel Høyer Iversen
9f4a9585d2 miflora lib version (#6142) 2017-02-21 14:43:17 +01:00
Lev Aronsky
c1be5ede1c Add 'entity_picture' to Darksky component (#6141) 2017-02-21 00:01:44 -08:00
David McNett
3beb87c54d New component 'insteon_plm' and related platforms (#6104)
* Connect to PLM and process simple protocol callbacks

* Baseline commit

* Connect to PLM and process simple protocol callbacks

* Baseline commit

* Connection working again

* Async add devices is working via callback now

* Beginning to interface with PLM library for control and state

* Deal with brightness in 255 levels with library

* Change sub names to match API changes

* Remove PLM-level update callback

* Support dimmable based on underlying PLM device attributes

* Expand to non-light platforms

* Stubs for turn on and off

* Current version of Python library

* Amend to use switch device attributes

* Use asyncio endpoints for control

* Add logging line

* Bump module version to 0.7.1

* Auto-load platforms, display device info/attributes

* Unify method name for getting a device attribute

* Require Current version of insteonplm module

* Import the component function in each platform in the balloob-recommend manner

* For consistency, handle switch state as onlevel just like lights

* Use level 0xff for on state, even with binary switches

Observing the behavior of a 2477S switch, it looks like even the non-dimmable
devices use 0x00 and 0xff for off/on respectively.  I was using 0x01 for on
previously, but that yields unnecessary state change callbacks when message
traffic ends up flipping the onlevel from 0xff to 0x01 or 0x01 to 0xff.

* Use sensorstate attribute for sensor onoff

* Move new device callback to devices attribute

* Add support for platform override on a device

* Bump version of insteonplm module

* Default overrides is an empty list

* Avoid calling private methods when doing common attributes

* Remove unused CONF_DEBUG for now

* flake8 and pylint code cleanup

* Move get_component to local function where it is needed

* Update to include insteonplm module.

* New files for insteon_plm component

* Legitimate class doctring instead of stub

* Docstring changes.

* Style changes as requested by @SEJeff

* Changes requested by @pvizeli

* Add @callback decorator to callback functions

* Opportunistic platform loading triggered by qualifying device detection

Instead of loading all the constituent platforms that comprise the insteon_plm
component, instead we defer and wait until we receive a callback for a device
that requires the platform.
2017-02-21 08:53:39 +01:00
Johann Kellerman
fdc373f27e Restore_state helper to restore entity states from the DB on startup (#4614)
* Restore states

* feedback

* Remove component move into recorder

* space

* helper

* Address my own comments

* Improve test coverage

* Add test for light restore state
2017-02-20 23:40:27 -08:00
Matt N
2b9fb73032 zoneminder: Add camera mjpeg stream support (#6098) 2017-02-20 22:17:11 -08:00
Paulus Schoutsen
36cda8c6b2 Merge remote-tracking branch 'origin/master' into dev 2017-02-20 21:57:37 -08:00
Paulus Schoutsen
041f1edd35 Update frontend 2017-02-20 21:56:38 -08:00
Paulus Schoutsen
32873508b7 Add initial group config (#6135) 2017-02-20 21:53:55 -08:00
Paulus Schoutsen
addd955a6b Version bump to 0.38.4 (#6137) 2017-02-20 21:52:36 -08:00
Paulus Schoutsen
022afcf050 Merge pull request #6136 from home-assistant/release-0-38-4
0.38.4
2017-02-20 21:50:00 -08:00
Paulus Schoutsen
7ce2b9e018 Update frontend 2017-02-20 21:35:10 -08:00
Paulus Schoutsen
f256d1fe2f Bump netdisco to 0.8.3 2017-02-20 21:30:38 -08:00
Pascal Vizeli
1910440a3c Update aiohttp to 1.3.3 (#6129) 2017-02-20 21:29:38 -08:00
Lewis Juggins
1d4c3febee [google] suppress file_cache warning (#6128) 2017-02-20 14:14:45 -08:00
Pascal Vizeli
1d7ab0fa95 Cleanup some async stuff (#6127)
* Cleanup some async stuff

* change to schedule_update_ha_state()

* fix media player

* fix zigbee
2017-02-20 13:24:03 -08:00
Stefano Scipioni
14cf5b884b fixed error caused by POST call with no 'message' inside (for example… (#6038)
* fixed error caused by POST call with no 'message' inside (for example in edited messages)

* avoid assert
2017-02-20 21:15:45 +01:00
arraylabs
3d34368e6e myq cover support gates (#6123)
* update myq to 0.0.6

* update req to 0.0.6

Adds support for gates
2017-02-20 18:25:29 +01:00
Pascal Vizeli
e425801fe0 Homematic cleanup & hass best praxis (#6121) 2017-02-20 17:07:33 +01:00
John Arild Berentsen
73a4c09597 Set configurable refresh for zwave light to 5 seconds default. (#5957)
* Set configurable refresh value delay to 5 seconds

* Revert "Remove configurable refresh value delay, and fix it to 5 seconds"

This reverts commit edc2dc35d165e5e13b0f3cf4df40493a7ce764f1.

* Use default value of 5 sec for refresh, and still configurable

* Make default delay 5secs, but needs to be activated
2017-02-20 15:49:34 +01:00
Pascal Vizeli
1a4b62909b Pump ffmpeg to 1.5 (#6119) 2017-02-20 15:12:09 +01:00
Scott Bradshaw
37a8035c54 Added support for alternate SSH ports in AsusWRT (#4832) (#6109)
* Added support for alternate SSH ports in AsusWRT (#4832)

* Always set the SSH port in SSH arguments

* Removed whitespace

* Adding port=22 to the mock calls

* Changed config.get(CONF_PORT)  to config[CONF_PORT] per feedback from @pvizeli
2017-02-20 09:06:50 +01:00
Paulus Schoutsen
25408941de Mqtt fixes (#6116)
* Fix MQTT stop

* MQTT: Make sure to have connection setup at end of MQTT setup.

* Fix MQTT connect
2017-02-19 22:43:10 -08:00
Paulus Schoutsen
b969fea900 Z-Wave config panel fix (#6113) 2017-02-19 22:25:03 -08:00
Robbie Trencheny
2cc6fe6609 Fix links in template
Closes #6112
2017-02-19 21:00:54 -08:00
Tom Matheussen
66d8787d47 Weather platform Forecast (#4721)
* Added forecast functionality to the weather platform, updated OWM to get forecast data

* style fixes

* Changed returned forecast data to a more managable dict

* Fixed line length

* forecast will always be collected, data returned from owm is based on metric setting

* use list comprehension to create the forecast data

* Added forecast data to the weather demo

* Create dict directly in list comprehension

* Minor variable change in weather demo platform

* Convert forecast temperatures in weather component

* set forecast attributes as constants

* Style fixes and tests

* Copied forecast_entry instead of mutating data
2017-02-19 16:42:12 -08:00
Pascal Vizeli
5d8e219448 Update aiohttp handling with upc connect (#6108)
* Refactor upc connect

* fix aiohttp cleanup

* fix test

* fix tests

* allow status code for login
2017-02-19 23:25:45 +01:00
Daniel Høyer Iversen
58f813b518 broadlink (#6101) 2017-02-19 17:45:57 +01:00
normakm
dee4c85c32 Add support for aliased owfs sensors (#6043)
* Support aliased owfs sensors

Current implementation does not support OneWire OWFS sensors that are aliased by OWFS alias.txt file:
http://owfs.org/index.php?page=aliases
Assumption is that folder name == sensor address

This change reads the supported families from owfs "family" file and adds both aliased and unaliased sensors.
(this approach also skips the "management" folders.. eg simultaenous, bus, alarm, statistics etc. For example when adding "simultaneous" as sensor (it also has "temperature" file) then owfs crashes)

* Update onewire.py

lint suggested style fixes

* Update onewire.py

Empty line removed

* Update onewire.py

comments removed
2017-02-19 01:59:44 -08:00
William Scanlon
a4318c3125 Added tamper detection to Wink devices. (#6072)
* Added tamper detection to wink devices.
2017-02-18 23:00:27 -05:00
Adam Mills
5f095b5126 Add supported_features to cover component (#6082) 2017-02-18 18:11:03 -08:00
William Scanlon
3cb1a5dd89 SimpliSafe updates (#6034)
* SimpliSafe updates

* Check login status

* Fixed requirements_all.txt
2017-02-18 17:47:52 -08:00
Kevin Siml
dfbef45e49 Add pushsafer.com notification service (#6050)
* Add pushsafer.com notification service

* Add pushsafer.com notification service

* Add pushsafer.com notification service

* Add pushsafer.com notification service

* Update pushsafer.py

* Update pushsafer.py

* Update pushsafer.py

* Update README.rst
2017-02-18 17:36:28 -08:00
Erik Eriksson
9e73115337 Updated volvooncall library + support sensors, heater and lock (#6052) 2017-02-18 17:09:25 -08:00
Andrey
beb8b4b11f Zwave: add power_consumption attribute (#6067)
* Zwave: Pull power consumption value into attribute.

* Zwave: Add power_consumption attribute.

* fix condition

* Update __init__.py

* Update

* Simplify class condition

* Handle empty class_id
2017-02-18 16:51:13 -08:00
dramamoose
003815c91a Update FLUX_LED by adding Effects (#6083)
* Add FLUX_LED Effects

Add add the various supported FLUX_LED effects

* Correct Flux_LED Issues

* Whitespace Changes

* Feed the Hound

* Feed the hound better food
2017-02-18 18:45:21 -05:00
Pascal Vizeli
e1cbd6b4c0 MQTT convert to async (#6064)
* Migrate mqtt to async

* address paulus comment / convert it complet async

* adress paulus comment / remove future

* Automation triggers should be async

* Fix MQTT async calls

* Show that event helpers are callbacks

* Fix tests

* Lint
2017-02-18 14:17:18 -08:00
Lindsay Ward
fa2c1dafdf Add platform for Yeelight Sunflower lights (#6060) 2017-02-18 14:05:55 -08:00
Erik Eriksson
76d1ee9fc2 Support for Pocket Casts (#6084) 2017-02-18 13:52:37 -08:00
Paulus Schoutsen
f29ee24b72 Do not allow config dependency (#6036)
* Do not allow config dependency

* Prevent config in discovery

* Migrate to blacklist
2017-02-18 11:31:37 -08:00
Adam Mills
b277fd55f9 [media_player.kodi] Fix for when no item id is provided (#6088) 2017-02-18 19:09:17 +00:00
kitcorey
75df4be733 Fix colortemp conversion for lifx lights (#6087) 2017-02-18 20:42:57 +02:00
Adam Mills
86a1b0a6c6 Websocket push notifications for Kodi (#6063)
* Websocket push notifications for Kodi

* Only create ws server if ws enabled

* Fix conditional websocket server creation
2017-02-18 00:26:07 -08:00
John Arild Berentsen
799fbe42f8 zwave refactor, don't use ozw values directly in properties. (#5961)
* First round of not using values directly

* Round two

* lint

* Round four

* Conflict

* Round five

* Update zwave.py

* round six

* Docstring

* flakywakie

* Fetch values in constructor

* Blank line removal

* Set attributes in callback

* Docstring

* Round seven

* Ughgit add homeassistant/components/lock/zwave.py!

* Sloppy code
2017-02-17 23:56:05 -08:00
Andrey
c1eed148cc Clean up value_added in zwave light. (#6074) 2017-02-17 23:54:45 -08:00
Erik Eriksson
62fe9f955e update dovado version (#6081) 2017-02-18 08:15:32 +01:00
Daniel Høyer Iversen
b857f838df Broadlink (#6051)
* Add fail checking of broadlink data
2017-02-18 07:38:50 +01:00
Philipp Schmitt
c2dc940819 Update liveboxplaytv and catch connection errors (#6056)
* Update liveboxplaytv and catch connection errors

* Implement @pvizeli's suggestion

* lint
2017-02-17 21:40:19 +01:00
Fabian Affolter
ca9eb31d1d Upgrade aiohttp to 1.3.2 (#6059) 2017-02-17 21:39:29 +01:00
William Scanlon
8a5fe38d69 Slugify trackr device_id (#6062)
* Slugify trackr device_id

* Removed replace
2017-02-17 21:39:05 +01:00
Andrey
91c3a49a5b Zwave: Add forgotten service file (#6073)
* add print

* Add 'print_node' service to zwave.

* Add forgotten service file
2017-02-17 22:09:38 +02:00
Andrey
1f72506f9b Add 'print_node' service to zwave (#6069)
* add print

* Add 'print_node' service to zwave.
2017-02-17 22:03:55 +02:00
Adam Mills
843840b963 Add effect_list to hue light (#6065) 2017-02-17 20:37:45 +02:00
Andrey
bb64560089 Zwave: Make different messages for ignores by woraround and device config. (#6061) 2017-02-17 16:19:21 +01:00
Walker Boyle
ba305ee71c Add aurora sensor (#6003)
* Add aurora sensor

* allow custom forecast threshold for aurora binary sensor

* move AuroraGateway functionality to Aurora data object to conform with HA standards
2017-02-17 09:13:52 +01:00
Andrey
905f4bf994 Support zwave glob & domain device settings. (#6046)
* Support zwave glob & domain device settings.

* data[DATA_DEVICE_CONFIG].get() now always return non-None

* Update test

* Update tests2

* Lint fix
2017-02-16 15:19:22 -08:00
Pascal Vizeli
a496a7c792 Protect device_tracker scan interval / TTS logging (#6041)
* Protect device_tracker scan interval / TTS logging

* clear pass
2017-02-16 07:13:33 -08:00
Jose Juan Montes
714ba31b75 Mediaplayer clementine remote (#5877)
* Added Clementine Music Player Remote component.

* Remove stale stuff
2017-02-16 15:34:34 +01:00
Pascal Vizeli
2574b915dd Fix name in logging message (#6039)
Add an optional extended description…
2017-02-16 10:30:12 +01:00
Thibault Cohen
1eceb405ce [WIP] Hydroquebec plugin now use pyhydroquebec lib (#6000)
* Hydroquebec plugin now use pyhydroquebec lib

* Fix logger message

* Fix platform name
2017-02-16 10:22:21 +01:00
Thibault Cohen
8bef7d84bb Add Ebox sensor component (#5998)
* Add Ebox sensor component

* Fix PR #5998 comments

* Fix logger message
2017-02-16 09:29:43 +01:00
Paulus Schoutsen
75e41a21c9 Clean up mock_coro (#6037) 2017-02-15 23:19:34 -08:00
Jon Caruana
9c176ad85a LiteJet: Lights should have the option to dim in the UI. (#6031)
* LiteJet: Lights should have the option to dim in the UI.

* Fix lint error.
2017-02-15 22:41:03 -08:00
Paulus Schoutsen
0f1a254f3b Update frontend 2017-02-15 22:33:52 -08:00
Pascal Vizeli
6674a8ad57 [Device Tracker] Remove coro (#6014)
* Remove coro and make flow faster.

* fix lint

* address comments
2017-02-15 19:52:06 -08:00
Paulus Schoutsen
235d0057b1 Simplify customize (#6007)
* Simplify customize

* Maintain glob order

* Have glob overrule domain
2017-02-15 19:47:30 -08:00
Adam Mills
eb9400de4c cmus remove IO from properties (#6030) 2017-02-15 19:13:25 -08:00
Thibault Cohen
4addcccfac Update to pyfido 0.1.4 (#6033) 2017-02-15 19:12:29 -08:00
jumpkick
f6e46aecf5 Update wemo.py 2017-02-15 17:32:45 -05:00
jumpkick
e9cf5f6f42 Update wemo.py 2017-02-15 16:58:11 -05:00
jumpkick
e221c8a37d Update wemo.py 2017-02-15 16:57:16 -05:00
jumpkick
b163544e3c Back to you travis.... 2017-02-15 16:47:02 -05:00
jumpkick
a718e92708 Update wemo.py
trailing whitespace... (argh... the bot should just trim it)
2017-02-15 15:40:02 -05:00
jumpkick
44d274e428 Update wemo.py
* continuation line under-indented for visual indent
2017-02-15 15:38:41 -05:00
jumpkick
c404fb7142 Update wemo.py
* Reordered datetime import
* Spaces by 4
2017-02-15 15:34:42 -05:00
Thibault Cohen
5895f431b4 [WIP] Add Fido sensor (#5997)
* Add Fido sensor

* Fix PR #5997 comments

* Make error message usable
2017-02-15 21:21:38 +01:00
Erik Eriksson
0d06454a94 eliqonline lib upgrade (#6021) 2017-02-15 19:02:58 +01:00
Pierre Ståhl
fdb6dd81ce Add fake support for turn on/off for Apple TV (#5962)
* Add fake support for turn on/off for Apple TV

When the device is "turned off", no requests are sent to the device.
When the setting "start_off" is set to true, the device starts in off
state.

* Fix async comments

* Clean up supported features
2017-02-15 09:10:48 -08:00
Johan Bloemberg
2d33ee6258 Reconnect robustness, expose connection state. (#5869)
* Reconnect robustness, expose connection state.

- Expose connection status as rflink.connection_status state.
- Handle alternative timeout scenario.
- Explicitly set a timeout for connections.
- Error when trying to send commands if disconnected.
- Do not block component setup on gateway connection.

* Don't use coroutine where none is needed.

* Test disconnected behaviour.

* Use proper conventions for task creation.

* Possibly fix test race condition?

* Update hass import style
2017-02-15 16:10:19 +01:00
George.M
b1fa178df4 Added a config flag[Boolean] to declare if SenseHAT is attached (#5883)
* Added a config flag[Boolean] to declare if SenseHAT is attached to RaspberryPi

* Hound found a line too long violation - fix
2017-02-15 11:11:55 +01:00
Robbie Trencheny
cf99551110 Merge pull request #6008 from tdickman/dev
Fix abreviation for miles in darksky sensor
2017-02-14 23:57:33 -08:00
happyleavesaoc
58e707a264 Limitless light: bump version; fix conf (#6006) 2017-02-15 08:45:04 +02:00
Paulus Schoutsen
c1988acb36 Merge pull request #6010 from home-assistant/merge-master
Merge master
2017-02-14 21:55:30 -08:00
Paulus Schoutsen
7776bfefc2 Merge branch 'master' into merge-master 2017-02-14 21:53:07 -08:00
Paulus Schoutsen
ad95b2715e Merge pull request #6009 from home-assistant/release-0-38-3
0.38.3
2017-02-14 21:48:49 -08:00
Pascal Vizeli
d6f525a23f Bugfix sonos favorite_source after lost connection (#5996) 2017-02-14 21:38:56 -08:00
happyleavesaoc
b1eb3243bd timeMin fix (#5983)
Add an optional extended description…
2017-02-14 21:38:56 -08:00
William Scanlon
9bcc692ff2 Fix #5979 (#5980) 2017-02-14 21:38:56 -08:00
Fabian Affolter
91d2ba609e Remove unit of measurement 2017-02-14 21:38:43 -08:00
Martin Hjelmare
bbc5c3a300 Fix mysensors platforms version requirement (#5942)
* Notify and device tracker platforms require mysensors version 2.0 or
  greater.
2017-02-14 21:37:54 -08:00
Andrey
04f3fe0ba3 Point-fix zwave getter not to ignore label (#5938) 2017-02-14 21:37:32 -08:00
William Scanlon
ea26aa2c81 Fixed typos in wink climate (#5936) 2017-02-14 21:37:17 -08:00
Tom Dickman
71dc41655c Fix abreviation for miles in darksky sensor 2017-02-14 23:06:06 -06:00
jumpkick
29c7987453 Improvements for WeMo Insight switches
* Changes current power units to watts
* Adds power on times and additional totals
2017-02-14 18:29:23 -05:00
Pascal Vizeli
80bc2666ac Make homematic climate dynamic for datapoints. (#5993)
* Make homematic climate dynamic for datapoints.

* Code cleanup

* Add more option

* add options

* Pump version 0.1.22

* optimaze
2017-02-14 23:19:57 +01:00
arraylabs
039559882b myq-cover updated to new requirement file, changed error message to be more informative (#5995) 2017-02-14 12:03:50 -08:00
Adam Mills
2993a4a7a5 Add object-assign polyfill support to polymer (#5994)
* Add object-assign polyfill support to polymer

* Conditionally load compatibility.js

* Remove compatibility preload

* Include newly compiled files

* Update compiled frontend with latest polymer
2017-02-14 12:00:45 -08:00
Pascal Vizeli
30ad8bcc80 Bugfix sonos favorite_source after lost connection (#5996) 2017-02-14 11:59:54 -08:00
Andrey
67d35e6454 Point-fix zwave getter not to ignore label (#5938) 2017-02-14 11:59:34 -08:00
Paulus Schoutsen
409b74b780 Update hassbian component with real output (#5989) 2017-02-14 09:34:17 -08:00
Pascal Vizeli
4b8e6e36b6 Make EntityComponent update process more robust. (#5943)
* Make EntityComponent update process more robust.

* address paulus comments

* Add platform to log message.
2017-02-14 09:32:40 -08:00
Fabian Affolter
cd9f3fa215 Upgrade pylast to 1.8.0 (#5991) 2017-02-14 13:10:38 +01:00
Sören Oldag
a06f89085d Added limitlessled support for bridge v6 and RGBWW bulbs. (#5958)
* Added limitlessled support for bridge v6 and RGBWW bulbs.

* Fix minor code style issue.

* Updated requirements_all.txt
2017-02-14 11:12:32 +01:00
happyleavesaoc
1bdd8e235a timeMin fix (#5983)
Add an optional extended description…
2017-02-14 10:30:16 +01:00
Erik Eriksson
39ca1a5a0d install libsodium to enable decryption of encrypted owntracks payload (#5976) 2017-02-13 23:59:09 -08:00
PetePriority
e17410c9a1 Added fritzbox_netmonitor.py (#5469)
* Added fritzbox_netmonitor.py

* Implemented changes
2017-02-13 23:58:23 -08:00
Fabian Affolter
f82ac0af60 Enable sensor for discovery (#5974)
* Enable sensor for discovery

* Remove blank line
2017-02-13 23:54:13 -08:00
Paulus Schoutsen
462b47c725 Update frontend (#5987) 2017-02-13 22:25:26 -08:00
Paulus Schoutsen
52567b1a48 Fix Z-Wave node config (#5986) 2017-02-13 22:16:39 -08:00
Andrey
ffb46ab541 Add 'days' flag to history fetch urls. (#5895)
* Add 'days' flag to history fetch urls.

* Fix unrenamed variable

* Switch to end_time param instead of days

* Checkthat end_time is parsed
2017-02-13 22:10:39 -08:00
Paulus Schoutsen
0effe14619 Z-Wave file name fix (#5985) 2017-02-13 21:58:16 -08:00
Andrey
e70b7ab509 Allow printing the number of states returned by history and time it took to extract. (#5973) 2017-02-13 21:48:53 -08:00
Paulus Schoutsen
36c196f9e8 Add initial Z-Wave config panel (#5937)
* Add Z-Wave config panel

* Add config to Z-Wave dependencies

* Lint

* lint

* Add tests

* Remove temp workaround

* Lint

* Fix tests

* Address comments

* Fix tests under Py34
2017-02-13 21:34:36 -08:00
Robbie Trencheny
6005933451 Merge pull request #5975 from fabaff/unit-moon
Remove unit of measurement
2017-02-13 18:08:49 -08:00
William Scanlon
41c2392f8b Fix #5979 (#5980) 2017-02-13 21:08:37 -05:00
Fabian Affolter
e866eeb518 Remove unit of measurement 2017-02-13 23:04:25 +01:00
Paulus Schoutsen
32fc164df3 Clean up HDMI_CEC [Breaking change] (#5932) 2017-02-13 13:52:11 -08:00
Gert-Jan van de Streek
5cad539859 Fix slow status updates from the knx bus (#5963)
* Fix slow status updates from the knx bus

The data set in the entity was an array, not the value.

@fixes https://github.com/home-assistant/home-assistant/issues/4407

* speed up status update
2017-02-13 22:48:48 +01:00
Josh Anderson
401263519d Only try to pair notify.webostv when not paired (#5967)
This allows the notify.webostv component to successfully register when
the TV is not currently powered on as long as a pairing record exists.
2017-02-13 22:29:18 +01:00
Andrey
0feb1c3e28 Add workaround for ignoring zwave devices and reversing cover open/close (#5922) 2017-02-13 20:59:42 +02:00
Paulus Schoutsen
b2d1774293 Fix Z-Wave (#5955) 2017-02-13 08:54:11 -08:00
Stuart Mumford
a8dc559519 Add support for the Open Energy Monitor Thermostat (#5583)
* Add support for the Open Energy Monitor Thermostat

* Fix linting errors

* Define an update method and local state

* fix linter

* Small tweaks.

Update oemthermostat version, default name and docstrings

* Fail to setup oem platform if connection fails.

* update requirements

* More tweaks to auth and exceptions

* Remove target temp
2017-02-13 16:45:04 +01:00
Philipp Schmitt
6d7041cd42 Reduce battery drain on Nuki Lock (#5945) 2017-02-13 14:43:12 +01:00
Valentin Alexeev
2ffdf1fdcd Bugfix/waqi sensor pwaqi version bump (#5944)
* Bump pwaqi to 1.4 to fix a typo in the underlying library.

* Update WAQI sensor to use pwaqi 2.0 which relies on AQICN public API.
This is a breaking change as the component now requires 'token' parameter.

* Fix lint
2017-02-13 14:28:40 +01:00
Fabian Affolter
f77eda2981 Upgrade thingspeak to 0.4.1 and use the correct API key (#5906) 2017-02-13 11:25:28 +01:00
Martin Hjelmare
b6404d70ec Fix mysensors platforms version requirement (#5942)
* Notify and device tracker platforms require mysensors version 2.0 or
  greater.
2017-02-13 11:23:28 +01:00
Fabian Affolter
9a5618fe96 Upgrade TwitterAPI to 2.4.4 (#5940) 2017-02-13 11:20:37 +01:00
arraylabs
bc1d14f9c3 Added myq cover component (#5886)
Add an optional extended description…
2017-02-13 11:20:07 +01:00
Alan Fischer
18f38229b2 iTach Remote Platform (#5660)
* Added itach remote device

* Added coverage & requirements

* Updated requirements

* Added schema, inline commands, and platform_setup failure if itach not found

* Removed unnecessary optional parameter

* Removed filename option for itach remote
2017-02-13 11:10:34 +01:00
Robbie Trencheny
feb2ebbc03 Fix AWS Lambda breakage after #5824 (#5935)
Add an optional extended description…
2017-02-13 09:27:50 +01:00
Paulus Schoutsen
7b56fe2af6 Update frontend (#5939) 2017-02-13 00:00:41 -08:00
Paulus Schoutsen
8ca3ca8564 Z-Wave: Rename customize to device_config [Breaking change] (#5933)
* Z-Wave: Rename customize to device_config

* Fix light

* Make entity id not required
2017-02-12 23:55:27 -08:00
Paulus Schoutsen
7401ec96b5 Version bump to 0.38.3 2017-02-12 23:31:04 -08:00
Pascal Vizeli
41849eab06 Core cleanup: two stage shutdown (#5876)
* Core cleanup: two stage shutdown

* fix spell

* fix

* add async logger to close

* change aiohttp to use CLOSE

* address paulus comments

* Fix tests

* Add unittest
2017-02-13 06:24:07 +01:00
William Scanlon
4623d1071e Fixed typos in wink climate (#5936) 2017-02-12 19:34:13 -08:00
Paulus Schoutsen
a37a3af126 Merge pull request #5928 from home-assistant/release-0-38-2
0.38.2
2017-02-12 15:49:58 -08:00
John Arild Berentsen
1a0a8f106e Bugfix for #5900 (#5901) 2017-02-12 15:47:20 -08:00
John Arild Berentsen
6311f21d31 Bugfix for #5900 (#5901) 2017-02-12 15:47:04 -08:00
Andrey
f4372a7df5 Fix getters that ignored labels. (#5903)
* Fix getters that ignored labels.

* Try 5 times for changed dict

* fix lint

* Add decorator with retrying functions.

* Fix lint

* use retries instead of decorator
2017-02-12 15:42:09 -08:00
Andrey
9b0a3e4c5a force_update zwave sensors. (#5844)
* force_update zwave sensors with polling_intensity.

* use bool to cast

* Make all zwave sensors force_update=True
2017-02-12 14:10:56 -08:00
Andrey
35118b6d9c Make hdmi_cec work with the new customize (#5916) 2017-02-12 14:02:45 -08:00
Fabian Affolter
8991fcf835 Fix name (#5912) 2017-02-12 14:02:45 -08:00
happyleavesaoc
15ef55a4c8 bump myusps version (#5911) 2017-02-12 14:02:45 -08:00
Philipp Schmitt
d3c444ff10 [lock.nuki] Fix Nuki lock for Python 3.4 and 3.5 (#5899) 2017-02-12 14:02:45 -08:00
Paulus Schoutsen
153e354002 Version bump to 0.38.2 2017-02-12 14:01:26 -08:00
Paulus Schoutsen
da5823becb Make check ha config file work with custom config dir 2017-02-12 14:00:06 -08:00
Paulus Schoutsen
8d0731e9fc Merge branch 'master' into dev 2017-02-12 13:58:09 -08:00
Pierre Ståhl
3a262cd7e0 Fix artwork in Apple TV platform (#5874) 2017-02-12 22:34:02 +01:00
Pascal Vizeli
9aac2113b6 Add 'wait_template' to script commands / Refactory track_template (#5827)
* Add 'wait' to script commands.

* Add track_template + unittest / rename wait_template

* fix lint & test

* Fix handling / change automation-template / add tests

* address paulus comments
2017-02-12 13:27:53 -08:00
happyleavesaoc
5f0b2a7d15 [WIP] gstreamer media player (#5839)
* gstreamer media player

* gstreamer meta
2017-02-12 13:00:27 -08:00
happyleavesaoc
64cb65a04e fedex sensor (#5891)
* fedex sensor

* fix fedex requirement
2017-02-12 12:47:27 -08:00
happyleavesaoc
3f675afd5b ups sensor (#5890) 2017-02-12 12:47:12 -08:00
Colin O'Dell
289767522b Update qnapstats library; add support for new verify_ssl config (#5919) 2017-02-12 12:38:29 -08:00
Per Sandström
675dd04e97 vasttrafik: update token on read error (#5875) 2017-02-12 11:57:29 -08:00
Pierre Ståhl
e5085bf620 Add media_image to media_player component (#5754) 2017-02-12 11:42:56 -08:00
Paulus Schoutsen
780173befb Update frontend (#5923) 2017-02-12 11:35:36 -08:00
Paulus Schoutsen
dab6d011ca Add check_config API (#5898)
* Add check_config API

* Add config panel to default config

* Add tests

* Lint

* lint
2017-02-12 11:31:46 -08:00
Andrey
dc6a28a8b2 Make hdmi_cec work with the new customize (#5916) 2017-02-12 11:19:15 -08:00
Fabian Affolter
b2fae212cb Fix name (#5912) 2017-02-12 11:16:06 -08:00
Greg Dowling
9c400de64b Bump pywemo - fix for latest bridge firmware. (#5921) 2017-02-12 11:14:23 -08:00
Adam Mills
e4bbe37112 Add device_class support to cover component (#5881) 2017-02-12 11:08:06 -08:00
Jose Juan Montes
2103bfc824 Fixed proximity zone incorrectly using name instead of zone setting. (#5862)
* Fixed proximity zone incorrectly using name instead of zone setting.

* Fixed proximity tests to suit change.
2017-02-12 11:03:53 -08:00
Pascal Bach
f8be731891 [google] Update google component dependencies (#5904) 2017-02-12 17:55:17 +00:00
happyleavesaoc
4af9d0f9ea bump myusps version (#5911) 2017-02-12 18:49:02 +01:00
Philipp Schmitt
533d28ce40 [lock.nuki] Fix Nuki lock for Python 3.4 and 3.5 (#5899) 2017-02-12 10:22:55 +00:00
Paulus Schoutsen
b59b42db2c 0.38.1 (#5889)
* Upgrade AppleTV dep to 0.1.4

* Version bump to 0.38.1

* Update logbook in frontend
2017-02-11 19:58:20 -08:00
Paulus Schoutsen
a25e394a11 Upgrade AppleTV dep to 0.1.4 2017-02-11 19:25:20 -08:00
Paulus Schoutsen
44311193ef Add config component and hassbian example panel (#5868)
* Add hassbian panel

* Rename to generic config panel

* Allow loading hassbian as test

* Add tests

* Update frontend

* Lint

* Lint
2017-02-11 17:29:05 -08:00
Robbie Trencheny
2b2c1562a5 Version bump to 0.39.0.dev0 2017-02-11 14:39:35 -08:00
Robbie Trencheny
e0f1c8ac67 Merge pull request #5833 from home-assistant/release-038
Release 0.38
2017-02-11 14:38:12 -08:00
Johann Kellerman
abaf9e53c2 Component set add unsing OR (#5880) 2017-02-11 23:27:06 +02:00
Paulus Schoutsen
5ad934907a Revert "Stop using entity_picture that is known to be bad." (#5882) 2017-02-11 13:10:28 -08:00
Fabian Affolter
88653e66c8 Style updates (#5878)
* Use consts, update quoting, and update comments

* Update log message

* Update docstrings

* Update log messages

* Update log messages

* Update style

* Fix typo

* Add newline

* Fix indent

* Fix line too long
2017-02-11 11:29:37 -08:00
Andrey
b981bfba7e Stop using entity_picture that is known to be bad. (#5856)
* Stop using entity_picture that is known to be bad.

* Only abandon image on 400 or 404 response

* Return is_permanent_failure as a third part of response

* Add debug printout

* Fix lint

* Fix lint
2017-02-11 20:33:41 +02:00
Fabian Affolter
2711c12928 Upgrade psutil to 5.1.3 (#5873) 2017-02-11 14:48:54 +01:00
Petr Vraník
0aad6c72d2 version bump (#5871) 2017-02-11 13:53:45 +01:00
Daniel Høyer Iversen
d32949b099 rfxtrx 0.17 (#5870) 2017-02-11 10:55:38 +01:00
Jose Juan Montes
f5c58748b7 Adds play URL support to mpd (makes it work with tts). (#5863)
* Adds play URL support to mpd (makes it work with tts).

* Removed extra line at the end of the file.
2017-02-11 10:07:31 +01:00
Paulus Schoutsen
3a7309ab62 Update frontend (#5866) 2017-02-10 21:06:42 -08:00
Paulus Schoutsen
d8a34877d4 Version bump to 0.38 2017-02-10 20:55:52 -08:00
Marcelo Moreira de Mello
3fb70afb14 Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call (#5865)
* Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call

* Make lint happy
2017-02-10 20:55:34 -08:00
Johan Bloemberg
bb043c47f8 Rflink update and small refactor. (#5789)
* Use same pattern for device defaults in both platforms.

* Update Rflink that passes loop downstream.

* Update requirements.
2017-02-10 20:55:34 -08:00
Paulus Schoutsen
849ae9903c Recorder run can be None (#5854) 2017-02-10 20:55:34 -08:00
Johann Kellerman
66088377e1 [recorder] Run end model changed in session scope (#5858) 2017-02-10 20:55:34 -08:00
Paulus Schoutsen
0e6ab3ace6 Update frontend (#5855) 2017-02-10 20:55:34 -08:00
Pascal Vizeli
eaa6392535 Fix check_config script. (#5853) 2017-02-10 20:55:34 -08:00
Petr Vraník
a071cd21f2 version bump (#5846)
Add an optional extended description…
2017-02-10 20:55:33 -08:00
Teemu R
0f6aed16a2 bump python-yeelight version (#5850)
Add an optional extended description…
2017-02-10 20:55:33 -08:00
Christian Brædstrup
cee389f621 D-Link switch version bump of external library (#5843) 2017-02-10 20:55:33 -08:00
Andrey
2b62e9f008 Fix zwave helper getter not to fail on some None results. (#5845) 2017-02-10 20:55:33 -08:00
Adam Mills
3d7b79f523 [recorder] Add tests for full schema migration (#5831)
* [recorder] Add tests for full schema migration

* Remove leftover code

* Fix duplicate creation of sqlalchemy Index object

* It's that kind of day...

* Improve models_original docstring
2017-02-10 20:55:33 -08:00
Philipp Schmitt
7bf7c727d1 Refactoring and JSON decode error handling (#5826)
* Refactoring and JSON decode error handling

* Catch ValueError instead of simplejson.scanner.JSONDecodeError
2017-02-10 20:55:33 -08:00
Pascal Vizeli
3f87d28616 Update aiohttp 1.3.1 (#5838) 2017-02-10 20:55:33 -08:00
Pierre Ståhl
7259082de5 Reuse default aiohttp session (#5836) 2017-02-10 20:55:33 -08:00
Pierre Ståhl
60f85b1e09 Handle connection errors when connecting to Apple TVs (#5829)
* Handle connection errors when connecting to Apple TVs

Also bump pyatv to 0.1.2 which fixes a request leak.

* Fix pylint error

* Fix import order
2017-02-10 20:55:33 -08:00
Erik Eriksson
0fdf1391e2 Don't thow exception if connection to server is lost (#5775) 2017-02-10 20:55:33 -08:00
Marcelo Moreira de Mello
75887e6069 Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call (#5865)
* Avoid traceback for Amcrest cameras/firmware that does not have the software_information API call

* Make lint happy
2017-02-10 20:51:19 -08:00
Adam Mills
e877d572f5 binary_sensor sensor_class to entity device_class (#5860)
* binary_sensor sensor_class to entity device_class

* Linter fixes

* Should be it
2017-02-10 20:46:15 -08:00
Johan Bloemberg
67957cbfa8 Rflink update and small refactor. (#5789)
* Use same pattern for device defaults in both platforms.

* Update Rflink that passes loop downstream.

* Update requirements.
2017-02-11 00:24:07 +01:00
Paulus Schoutsen
b10d20bcab Recorder run can be None (#5854) 2017-02-10 12:55:59 -08:00
Johann Kellerman
cbf3a2ecae [recorder] Run end model changed in session scope (#5858) 2017-02-10 22:22:15 +02:00
Paulus Schoutsen
23ff2eb79c Update frontend (#5855) 2017-02-10 09:30:13 -08:00
Paulus Schoutsen
6ffab53377 Core: cleanup timer (#5825)
* Minor core cleanup

* Cleanup timer

* Lint

* timeout with correct loop

* Improve timer thanks to pvizeli

* Update core.py

* More tests
2017-02-10 09:00:17 -08:00
Erik Eriksson
c7c3b30e0a Do not call state if device isn't available (#5835) 2017-02-10 08:59:58 -08:00
Andrey
0b5191a247 Add support for zwave wakeup setting. (#5849)
* Add support for zwave wakeup setting.

* rename wakeup
2017-02-10 08:54:48 -08:00
Pascal Vizeli
4e8d20328a Fix check_config script. (#5853) 2017-02-10 08:51:08 -08:00
Pascal Vizeli
8785e5826e telegram small cleanup/style (#5852) 2017-02-10 16:39:02 +01:00
Teemu R
1da6181491 bump python-yeelight version (#5850)
Add an optional extended description…
2017-02-10 14:45:31 +01:00
Christian Brædstrup
a150a69cca D-Link switch version bump of external library (#5843) 2017-02-10 12:00:28 +01:00
Andrey
5bd54f69cc Fix zwave helper getter not to fail on some None results. (#5845) 2017-02-10 12:30:44 +02:00
Mark Oude Veldhuis
0d76d72b9f Add support for multiple devices to Tado device tracker (#5810)
* Add support for multiple devices to Tado device tracker

* Hound did not agree with my usage of spaces

* Two blank lines were expected

* Keep CONF_HOME_ID in the Tado file

* Make home_id optional

* Work with different API URLs depending on home_id being present

* Remove CONF_HOME_ID from HA's const.py file

* Missed removing CONF_HOME_ID from the import
2017-02-09 18:50:14 -08:00
Boris K
5ecef6aaac Add history_stats sensor (#5610)
* Add new sensor/history_stats component

* Add real unit tests

* Code style changes requested for pull request

* Remove time aliases & allow datetime values

* Reformat unit tests

* Remove all async behavior in history_stats

* Change duration format
2017-02-09 18:47:12 -08:00
Adam Mills
be08bf0ef7 [recorder] Add tests for full schema migration (#5831)
* [recorder] Add tests for full schema migration

* Remove leftover code

* Fix duplicate creation of sqlalchemy Index object

* It's that kind of day...

* Improve models_original docstring
2017-02-09 18:17:17 -08:00
Philipp Schmitt
4c5e6399e9 Refactoring and JSON decode error handling (#5826)
* Refactoring and JSON decode error handling

* Catch ValueError instead of simplejson.scanner.JSONDecodeError
2017-02-09 17:57:19 -08:00
Pascal Vizeli
2e8e5a35b5 Update aiohttp 1.3.1 (#5838) 2017-02-09 17:31:20 -08:00
Pierre Ståhl
841321f154 Reuse default aiohttp session (#5836) 2017-02-09 23:07:46 +01:00
Stefano Scipioni
ebfff6a907 Telegram webhooks (#5793)
* new component telegram_webhooks

* keyboard support in telegram notify

* telegram_webhooks has no tests

* requirement like notify/telegram

* ops, requirements_all.txt needed for travis

* ops, requirements_all.txt is generated by script/gen_requirements_all.py

* check telegram trusted networks in web handler

* raise an event now

* use of hass.config.api.base_url

* more readable

* small cleanups

* Small style change for HA guideline

* fix lint

* revert return to origin
2017-02-09 23:05:28 +01:00
Pierre Ståhl
ecbbb06b2f Handle connection errors when connecting to Apple TVs (#5829)
* Handle connection errors when connecting to Apple TVs

Also bump pyatv to 0.1.2 which fixes a request leak.

* Fix pylint error

* Fix import order
2017-02-09 22:25:06 +01:00
Paulus Schoutsen
c54517de90 Convert config.components to a set (#5824) 2017-02-09 20:21:57 +02:00
Erik Eriksson
f3b9fa2f41 Don't thow exception if connection to server is lost (#5775) 2017-02-09 09:00:18 -08:00
Paulus Schoutsen
e5256ccf1f Merge remote-tracking branch 'origin/master' into dev 2017-02-09 08:54:40 -08:00
John Arild Berentsen
298575f7cb Adding helper for get and set values (#5743)
* cleanup

* Update __init__.py

* Update __init__.py

* Update __init__.py
2017-02-09 13:40:35 +01:00
Paulus Schoutsen
c550a316a4 Make device sun light trigger async (#5823) 2017-02-09 00:10:53 -08:00
Paulus Schoutsen
4398b8b5c6 Deprecate event decorators (#5822) 2017-02-09 00:10:38 -08:00
Pascal Vizeli
2cbed9cd96 Move signal handling out of core to bootstrap (#5815)
* Move signal handling out of core to bootstrap

* Fix tests
2017-02-08 21:58:45 -08:00
Paulus Schoutsen
7eb4bdc37b Upgrade aiohttp to 1.3 (#5821) 2017-02-08 21:27:36 -08:00
Paulus Schoutsen
ebceca36ec Update frontend (#5820) 2017-02-08 20:55:15 -08:00
Paulus Schoutsen
03fe5b04b5 Remove non-working webfont preload (#5819) 2017-02-08 20:31:36 -08:00
Duoxilian
7fa08059dc Support away_mode as permanent hold and hold_mode as temporary hold. (#5725)
* Support away_mode as permanent hold and hold_mode as temporary hold.

* Add comments to explain code better. Remove indefinite hold preference
to be consistent with 'away_mode'.
2017-02-08 20:04:09 -08:00
John Arild Berentsen
fdcf5fe233 Bugfixes (#5740)
* wrong data for lock alarm_type

* missing whitespace

* Not possible to set codes starting with 0
2017-02-08 19:59:47 -08:00
Johann Kellerman
415500de23 [recorder] Protect against running in the event loop (#5812) 2017-02-08 19:58:43 -08:00
William Scanlon
628b169393 Fixed call to object_id() (#5814) 2017-02-08 19:57:58 -08:00
Sean Dague
49f2540730 Enhancements to ARWN platform (#5816)
* Fix arwn platform discover_sensors

The discover_sensors function can return either singletons or a list
of sensors. However the consumer was always expecting a list. This
fixes it to work in both cases.

* Add custom icons to arwn sensors.

This adds some custom icons for different kinds of weather sensors
that the arwn platform returns. Makes it a little easier to see what's
going on.
2017-02-08 19:56:44 -08:00
Teagan Glenn
76db4cc099 Change medium state for filtering (#5817) 2017-02-08 19:55:48 -08:00
Pascal Vizeli
d29b7f6910 Ffmpeg update 1.4 (#5813)
* Pump ffmpeg version

* update entity

* next 1.4
2017-02-08 23:18:23 +01:00
Johann Kellerman
612aa1cf21 Initial (#5811) 2017-02-08 13:16:39 -08:00
Andreas Cambitsis
4f20a2d3ea Upgrade Russound integration to v0.1.7 (#5756)
* Bumped up version to use 0.1.7 of Russound integration module.
Fixed bug arising from not supporting TURN_ON state (fixes issue https://github.com/home-assistant/home-assistant/issues/5012)
Implemented state support in 0.1.7 such that component state is returned from the actual AMP. (Still uses polling model though).
Tested it with home-assitant users @laf (original developer of the module) and @hofsta.  Works fine with their Russounds.

* Made styling / compliance changes and updated correct version of russound module on requirements_all.txt.

* Changed handling of properties to be compliant with https://github.com/home-assistant/home-assistant/issues/4210
(Specifcailly added member variables for state, volume and source to cache these values, and introduced Update() method to set their values).

Now returns None if the selected source index that is returned from russound is greater than the length of the specified source list in the yaml config.
Removed unnecesary comment.

* Removed blank line after docstring.

* Removed updated() in class init and added True paramter to add_devices in setup_platform.

* Dropped the no longer needed self.update()
2017-02-08 15:53:59 -05:00
Teemu R
061985bc65 Add available property and typing hints (#5593)
* light.demo: add available property, add typing hints

* light.demo: keep all lights available, fix init ordering

* Fix issues raised during review

* Update demo.py
2017-02-08 12:13:07 -08:00
Andrey
4b15946a9b Make sure workaround_component is not none (#5808) 2017-02-08 21:11:36 +02:00
Pascal Vizeli
881d53339b [Image_Processing][Breaking Change] Cleanup Base face class add support for microsoft face detect (#5802)
* [Image_Processing] Cleanup Base face class add support for microsoft face detect

* fix lint

* add unittest for micosoft detect

* fix test
2017-02-08 09:19:40 -08:00
Pascal Vizeli
3f82ef64a1 Move core service from core to components (#5787)
* Move core servcie from core to components

* add new handler for signals/exception

* Static persistent id

* Move unittest

* fix coro/callback

* Add more unittest for new services

* Address comments

* Update __init__.py
2017-02-08 09:17:52 -08:00
Daniel Høyer Iversen
08efe2bf6d Improve warning message in template rendering (#5806)
* improve warning message when template is none

* improve error message when template is none

* improve error message when template is none

* improve error message when template is none
2017-02-08 09:07:43 -08:00
Johann Kellerman
db6c166abe Update sma.py (#5807) 2017-02-08 09:07:03 -08:00
George.M
8951e1bdc0 The word router was misspelt (#5803)
fixed as this message is user facing
2017-02-08 12:28:45 +01:00
Pierre Ståhl
250523c1d8 Add discovery suppport to Apple TV (#5801)
Add an optional extended description…
2017-02-08 12:17:23 +01:00
Philipp Schmitt
2dab6cbb0e Mailgun notify service (#5782)
* Mailgun notify service

* Update dependency to version 1.3

- The provided credentials (including the domain) are now checked during
startup, as requested by @balloob
- The domain name is now optional
- There's a new config item "sandbox" which indicates whether to use the
sandboxed domain in case the domain is not set

* Fix a few lint issues

* Disable lint check no-value-for-parameter
2017-02-07 22:22:19 -08:00
Johan Bloemberg
0e6dd39c15 Add support for fluxled discovery. (#5784)
* Add support for fluxled discovery.

* Make use of device type/protocol auto detection.
2017-02-07 21:49:36 -08:00
Johann Kellerman
490ef6afad WIP: [component/recorder] Refactoring & better handling of SQLAlchemy Sessions (#5607)
* Refactor recorder and Sessions

* Cover #4352

* NO_reset_on_return

* contextmanager

* coverage
2017-02-07 21:47:41 -08:00
Paulus Schoutsen
bdebe5d53c Update frontend (#5800) 2017-02-07 21:30:24 -08:00
Adam Mills
ecfe8e0a9a Formalize supported_features as entity property (#5794)
* Formalize supported_features as entity property

* Remove extra emulated_hue conditions

* Generate log message in executor
2017-02-07 20:42:45 -08:00
Jeff Wilson
4fa4d7347f Fix climate.set_fan_mode yaml (#5799) 2017-02-07 20:38:16 -08:00
Andrey
1b54218d46 Create a file for zwave workarounds. (#5798)
* Create a file for zwave workarounds. Add sensor->binary_sensor for fgfs101 (#2)

* Don't use default None
2017-02-07 20:37:11 -08:00
Robbie Trencheny
b8a0792424 Bump netdisco to 0.8.2 2017-02-07 14:11:51 -08:00
Josh Wright
35f6dbc9dc Update python-nest dependency version (#5795)
The nest-cam changes have now been merged into the upstream library, so
there is no need to track a specific branch.

Updating to 3.1.0 also fixes a structure parsing bug I was experiencing.
2017-02-07 22:55:49 +01:00
Fabian Affolter
12bc7c7316 Upgrade pyasn1 to 0.2.2 (#5796) 2017-02-07 22:55:21 +01:00
Pascal Vizeli
acdda1f42b Revert last change on TTS cache load for more speed (#5797) 2017-02-07 22:54:52 +01:00
Martin Hjelmare
45a7c27280 Add mysensors device tracker and platform discovery (#5781)
* Add mysensors device_tracker platform

* Add discovery of device_tracker platforms

* Enable discovery of device_tracker platforms that are not
  DeviceScanner.
* Update signature of setup_scanner function in all affected platforms.
* Add test.
* Use discovery for mysensors device_tracker platform.

* Remove gps accuracy

* Small change to core like schema

* fix depency
2017-02-07 20:47:11 +01:00
Fabian Affolter
c7fd28c10f MQTT discovery (#5724)
* Change implementation

* Re-write

* Remove unused consts

* Update discovery.py

* Add tests

* fix other tests

* Fix check_config script test

* Lint

* Lint
2017-02-07 09:13:24 -08:00
Robbie Trencheny
45507cd9d1 TTS ID3 support (#5773)
* Add support for writing ID3 tags to the file for improved display in media players

* Lint and async fixes

* Use mutagen instead of taglib

* Fix tests

* Add fallback for album

* Requested changes

* move import

* Fix album name

* Change default options handling

* Move to member function / minor fix

* fix style

* fix lint

* change mutagen handling

* fix lint / add name to bytesio

* Update __init__.py

* Fix test, some cleanups

* Add mutagen exeption handling, fix tests

* fix mutagen taging
2017-02-07 12:07:11 +01:00
Trevor
063c0e8f44 Add icon_template to template sensor (#5766)
* Add icon_template to template sensor

* Update test_template.py

* Update test_template.py again

* Update template.py

* Update test_template.py

* Update test_template.py
2017-02-07 01:51:44 -08:00
Trevor
f0da576315 Fix Hue groups with same names (#5737)
* Revert "Fix hue lightgroups not syncing state (#5702)"

* Use light_id in unique_id for Hue groups

* Make sure HueLight unique_id is unique

* Update hue.py

* Update hue.py

* Update hue.py
2017-02-07 01:51:05 -08:00
andrey-git
f774538e66 Check config before restarting (#5609)
* Check config before restarting.

* Make check_config on restart async

* don't check if notification service exists

* Use .communicate()

* Reduce the number of notifications. Add tests.
2017-02-07 01:19:08 -08:00
Hermann Kraus
51810620fb Check for command topics when determinig the capabilities of an MQTT light. (#5770)
Previous code used the state topic which is obviously wrong:
- The state topic is already used to select optimistic mode.
- A light with only the state topic but no command topic would still announce the capability.
2017-02-07 01:13:00 -08:00
Pierre Ståhl
c7e282257a Initial support for Apple TV (#5698)
* Initial support for Apple TV

* hash_wip

* Add media_play support to Apple TV
2017-02-07 00:55:19 -08:00
Jesse Osiecki
9a2c84ee8a Added error checking to the MIMEImage encoding for smtp.py (#5753)
* Added error checking to the MIMEImage encoding for smtp.py

Added fallback to file attachment rather than inline image for images
without a known MIME

* PEP8 reqs to fix previous commit
2017-02-07 00:43:03 -08:00
Alessandro Mogavero
86da4f511d Improve Sky Hub error handling (#5762)
* Added error handling in function _get_skyhub_data

* Error line split for readability
2017-02-07 00:28:33 -08:00
Pascal Vizeli
48161697f8 Sonos fix favorite, coordinator, cleanup update (#5778)
* Sonos fix favorite, coordinator, cleanup update

* Bugfix snapshot restore
2017-02-07 00:27:55 -08:00
Stéphane Bidoul (ACSONE)
7927a6b588 add min and max jinja filters (#5765) 2017-02-07 00:25:47 -08:00
ray0711
1546ec7778 Fix brightness slider for mqtt template lights (#5780)
Add the missing supported_features declaration.
2017-02-07 09:52:07 +02:00
Marcelo Moreira de Mello
305d2612cf Fix attribute error for media_player/roku if roku device is unreachable and shows a persistent notification (#5785) (#5786) 2017-02-06 22:00:20 -08:00
Andrzej
34c7bac9b4 Update package.py (#5783) 2017-02-06 22:16:17 +01:00
Pascal Vizeli
2b124a008c Migrate lock component to async (#5748) 2017-02-06 21:25:34 +01:00
Alberto Arias Maestro
32dc276c53 Add support for position on wink cover (#5751)
Add support for position property for wink covers and fix state when stopped in the middle.
2017-02-06 15:43:36 +02:00
Adrián López
4cc711357a Allow to use data for enhanced messages (#5763)
Add notification data field to the message send to Facebook.
Allows to construct richer messages like cards, quick replies, attach
images, videos, etc
2017-02-06 14:01:41 +01:00
andrey-git
26a3ecc9d0 Merge pull request #5718 from benvm/modbus_write_register_array
Modbus write_register doesn't accept list
2017-02-06 13:55:48 +02:00
Johan Bloemberg
264bdc9d56 Make brightness display work for rgb devices. (#5675)
* Make brightness display work for rgb devices.

Non rgbw devices return 255 for getWarmWhite255. This is part 2 to make the brightness slider work for these devices.

https://github.com/Danielhiversen/flux_led/pull/25

* Query brightness property which return WW level or RGB brightness equivalent.

https://github.com/Danielhiversen/flux_led/pull/25
2017-02-06 11:32:51 +01:00
Daniel Høyer Iversen
150c8ac11c flux led o.13 (#5774) 2017-02-06 11:32:37 +01:00
Yannic-HAW
4a341ff55f - added send packet service to send ir packets directly from scripts (no need to define a switch for each command) (#5768)
- changed ip suffix of SERVICE_LEARN to use _ instead of . as ip seperator to avoid errors if used in yaml
2017-02-06 07:53:58 +01:00
Martin Hjelmare
0d89f2bc69 Update mysensors sensors (#5764)
* Add V_DIRECTION type for S_WIND.
* Add more predefined units of measurement.
2017-02-05 21:07:30 +01:00
Pascal Vizeli
2a139d6bc7 Add unittest for multible entities in one line (#5759) 2017-02-05 14:24:38 +01:00
Fabian Affolter
91bebca0b6 Upgrade pysnmp to 4.3.3 (#5757) 2017-02-05 11:22:32 +01:00
Philipp Schmitt
573fc651dc Store the key file in the config dir (#5732)
* webostv: Store the key file in the config dir

* Update the pylgtv source to use the repo by @TheRealLink

* Add missing config parameter
2017-02-05 10:39:04 +01:00
Fabian Affolter
d88c903537 Upgrade pyasn1 to 0.2.1 (#5755) 2017-02-05 10:16:57 +01:00
Martin Hjelmare
82c99f81fc Fix validation of serial port on windows (#5749)
* Fix validation of serial port on windows

* Use pyserial to check serial ports.
* Check that persistence file ends with either `.json` or `.pickle`.

* Change fix to not rely on pyserial

* Use generator expr instead of list comprehension
2017-02-04 21:54:20 -08:00
Fabian Affolter
02dfd9660e Upgrade zeroconf to 0.18.0 (#5746) 2017-02-04 20:52:11 +01:00
Fabian Affolter
6164b61e14 Upgrade psutil to 5.1.2 (#5745) 2017-02-04 20:51:49 +01:00
Fabian Affolter
4cb20ce6d9 Upgrade astral to 1.3.4 (#5744) 2017-02-04 20:51:22 +01:00
Joeboyc2
0ea81c1269 Change CONF_DEFAULT_COLOR CV type (#5700)
* Change CONF_DEFAULT_COLOR CV type

Changed  vol.Optional(CONF_DEFAULT_COLOR, default=DEFAULT_COLOR) from cv.string to cv.ensure_list

This allows the optional parameter default_color to be picked up correctly and to function

the option needs to be specifed as follows:

    default_color: [0,255,0]

Solution provided by @scossa2020 in issue #5338
https://github.com/home-assistant/home-assistant/issues/5338

* Update hyperion.py
2017-02-03 23:36:25 -08:00
Fabian Affolter
b29c167dde Upgrade psutil to 5.1.1 (#5736) 2017-02-03 09:09:14 -08:00
William Scanlon
25a68f3ce9 Update python-wink version (#5734) 2017-02-03 16:37:00 +01:00
Fabian Affolter
c0dcef6c3e Add wind bearing (#5730) 2017-02-03 09:44:07 +01:00
Fabian Affolter
6786f83c26 Upgrade pyowm to 2.6.1 (#5729) 2017-02-03 09:43:29 +01:00
Philipp Schmitt
7506569db9 Support for the Orange Livebox Play TV appliance (#5533)
* Support for the Orage Livebox Play TV appliance

* Add liveboxplaytv to coveragerc

* Minor refactoring

* Update requirements

* Adjust comments

* Fix alignment

* Fix some coding-style issues highlighted by Travis CI

* The livebox play TV does not support playing media

* Lint: shorten line

* Remove unused callback function

* Remove redundant backslash

* Implement changes requested by balloob

* Don't error out if channel name or media url could not be retrieved

* Support current program (media title property)

* Remove unnecessary check

* Clean up: Remove another unnecessary check, _CONFIGURING variable and _playing attribute

* Update liveboxplaytv dependency to version 1.4.4

* Fix liveboxplaytv requirement

* Improve media state (support for playing and pause state)

* Update liveboxplaytv.py
2017-02-02 23:52:52 -08:00
Fabian Affolter
f9ede73a55 Add moon sensor (#5726)
* Add moon sensor

* Update moon.py
2017-02-02 23:43:03 -08:00
Joseph Piron
4aa7f030e8 Adds average load to systemmonitor (#5686)
* Adds average load to systemmonitor

* split the values in 3 sensors

* hound ok
2017-02-02 23:33:15 -08:00
Wolf-Bastian Pöttner
e831a2705e Add support for FRITZ!DECT wireless switches based on fritzhome (#5541) 2017-02-02 23:29:18 -08:00
Ryan Kraus
537355924f Alert Component (#5201) 2017-02-03 07:20:51 +02:00
miniconfig
dbc2f6b9cd Merge pull request #5658 from miniconfig/openevse
Added new sensor component to monitor OpenEVSE chargers.
2017-02-02 23:52:11 -05:00
Adam Mills
6a64e79d7b [recorder] Index events time_fired to improve logbook performance (#5633)
* Index events time_fired to improve logbook perf.

* Updated implementation to track schema versions

* Added tests for schema migration support logic

* Rename check_schema to migrate_schema
2017-02-02 22:04:14 -05:00
miniconfig
4b62a0d924 Updated openvse sensor component to use new structure of openevsewifi library. 2017-02-02 21:46:35 -05:00
Valentin Alexeev
dfb991ce19 Bump pwaqi to 1.4 to fix a typo in the underlying library. (#5716) 2017-02-02 12:59:52 -08:00
Pascal Vizeli
f63874eb8c Migrate cover to async. (#5717) 2017-02-02 12:39:13 -08:00
Colin O'Dell
bc65452efb QNAP Sensor (#5666)
* Implement the QNAP sensor

* Add sensors immediately

* Remove unnecessary check

* Use CONF_SSL instead of CONF_PROTOCOL
2017-02-02 12:29:04 -08:00
Pascal Vizeli
2fc3dfff67 Migrate fan component to async. (#5723)
* Migrate fan component to async.

* Fix lint
2017-02-02 12:07:00 -08:00
Daniel Høyer Iversen
574384f446 update miflora lib and allow specification of bluetooth adapter (#5720) 2017-02-02 17:08:10 +01:00
Daniel Høyer Iversen
ee551e2a9c up rfxtrx lib (#5721) 2017-02-02 16:18:16 +01:00
Duoxilian
219337a574 Cleanup climate and ecobee (#5616)
* Remove redundant input validation which is already accomplished through
defined schemata.

* Rely on defined state attributes for hold mode.

* Remove misleading comment. This comment seems to assume that sleep
mode is a hold; it is a schedule instead. The code snippets in the
comment could never work.

* Remove use of constants for hold mode. Will be made irrelevant
by a planned change by nordlead2005.
2017-02-02 15:28:32 +01:00
Philipp Schmitt
ff65c2a114 Support for Nuki.io smart locks (#5715)
* Support for Nuki.io smart locks

* Update requirements and add lock.nuki to .coveragerc

* lint: Re-organize imports

* Schedule a state update instead of calling directly update_ha_state

* Remove update requests altogether

* Make sure there is no IO inside properties

* Fix: nuki lock are all initialized as "lock.unnamed_device"

* Update pynuki to 1.2 to avoid an extra REST API call for each lock init
2017-02-02 15:15:27 +01:00
Ben Van Mechelen
0ea9d935af Modbus write_register accept list 2017-02-02 10:23:13 +01:00
William Scanlon
80a794e587 Wink AC and addidtional sensor support (#5670)
* Added door bell sensors

* Initial support for AC units.

* Added new device service

* Quirky Aros AC unit support

* Use super() everywhere and error checking for token request.

* Ignore camera sensors during setup of alarms.

* Added manufacturer/device attributes to all wink devices.

* Fixed style errors

* Fixed remaining lint errors.
2017-02-01 22:43:12 -08:00
Trevor
b5f285a789 Fix OwnTracks state names (#5454)
* Fix OwnTracks state names (#5453)

* Update owntracks.py

* Update tests
2017-02-01 22:06:02 -08:00
Paulus Schoutsen
6e94f0d7cd Upgrade zeroconf dep" (#5706) 2017-02-01 21:48:30 -08:00
Pascal Vizeli
eefb603f17 Cleanup media_player universal platform / blocking platform. (#5671)
* Cleanup media_player universal platform / blocking platform.

* fix comments

* fix unittest

* fix lint

* fix unittest lint

* fix coro

* fix test

* fix tests part 2
2017-02-01 21:45:19 -08:00
Pascal Vizeli
10a104271e Cleanup climate platform for async update_ha_state / migrate generic thermostat (#5679)
* Cleanup climate from blocking stuff / migrate generic

* Migrate generic thermostat

* fix tests

* fix lint
2017-02-01 21:44:05 -08:00
Trevor
647a93801c Fix hue lightgroups not syncing state (#5702) 2017-02-01 21:06:11 -08:00
Johann Kellerman
2fcaf8bda6 [sensor/sma] handle units correctly (#5657) 2017-02-01 21:01:06 -08:00
Johan Bloemberg
ae1f59970d Prevent infinite loop in crossconfigured mqtt event streams (#5624)
* Prevent events about MQTT messages received to cause infinite loop when two HA instances are crossconfigured for mqtt_eventstream.

* Fix linting

* Publish all MQTT received events except incoming from eventstream. Also make it configurable.
2017-02-01 21:00:05 -08:00
John Arild Berentsen
68d6bcd3ed [lock.zwave] Bugfix Zwave lock (#5619)
* Bugfix state

* remove debug
2017-02-01 20:57:57 -08:00
Pascal Vizeli
b2180fba63 Bugfix sonso source input (#5699) 2017-02-02 00:02:24 +01:00
Pascal Vizeli
b5b1d72ab6 Fix bug for UNREACH devices / Variable handling and update. (#5689)
* Fix bug for UNREACH devices / Variable handling and update.

* fix track_time

* update after data after creation

* add message output

* change unreach

* change unreach code

* Revert "change unreach code"

This reverts commit f58430de3c.

* update pyhomematic
2017-02-01 23:55:16 +01:00
Daniel Høyer Iversen
2a5ccff82e up rfxtrx lib (#5687) 2017-02-01 19:47:18 +01:00
Paulus Schoutsen
bdc62730bd Update frontend (#5696) 2017-02-01 09:03:35 -08:00
Hugo Dupras
676519d0cb Hotfix for netatmo cameras (#5644)
* Fix for missing netatmo tags in 0.37

Also fix issue with SSL certificate for vpn_url

Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>

* Netatmo welcome: vpn_url can be empty

Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>

* add config floag to disable SSL verification for vpn_url

Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>

* Import CONF_VERIFY_SSL from const
2017-02-01 17:33:32 +01:00
Pascal Vizeli
a72d32b9af Bugfix async blocking loop with xml parser. (#5694) 2017-02-01 17:20:52 +01:00
Pascal Vizeli
32f8622bba Bugfix sonos group coordinator (#5691)
* Bugfix sonos group coordinator

* Fix tests
2017-02-01 16:53:02 +01:00
Johan Bloemberg
cabc4dff03 Use same pattern for device defaults in both platforms. (#5682) 2017-02-01 10:42:50 +01:00
Paulus Schoutsen
987f59e8d8 Update frontend (#5685) 2017-02-01 00:47:02 -08:00
Johan Bloemberg
7be3414785 Only set LANG=C.UTF8 during install. (#5648) 2017-01-31 19:30:53 -08:00
Paulus Schoutsen
8334bc908c Update frontend (#5683) 2017-01-31 19:29:07 -08:00
Michaël Arnauts
8247acb7b9 Move docker installation scripts to virtualization/Docker path. Splits out openalpr to seperate script. (#5676) 2017-01-31 19:02:06 -08:00
Erik Eriksson
89ec752064 Upgraded tellduslive (#5664) 2017-01-31 11:08:11 -08:00
Mathew Peterson
d65f07860c Refactors script/setup_docker_prereqs (#5506)
* Refactors script/setup_docker_prereqs

Refactors script/setup_docker_prereqs to allow toggling of packages
to being installed

* Adds support for openalpr to Docker

* Updates Dockerfile

Comments ENV directives in order to preserve cache.

* Fixes incorrect position of echo

* Fixes telldus installer by updating apt before pkg install
2017-01-31 18:11:51 +01:00
Johan Bloemberg
bbda2a72f4 Rflink 433Mhz gateway platform and components (#4547)
* Initial sketches of rflink component.

* Add requirement.

* Properly load configuration.

* Bump rflink for graceful parse errors and protocol callback.

* Cleanup, documentation and linting.

* More documentation, first sensor implementation (temp & hum).

* Add brightness/dim support for newkaku protocol.

* Use separate class for dimmables.

* Make sure non-dimmable newkaku devices are turned on.

* Move some code around, add switches. Support loading from config.

* Fix bug in ignoring devices.

* Fix initial state assumption.

* Improve reliability on invalid conditions.

* Allow configuration of group for new devices.

* Sensor icons.

* Fix parsing negative numbers.

* Correct icon.

* Allow sending commands serial.

* Pluralize.

* Allow adding sensors from config.

* Fix ignoring devices and bugs in previous commit.

* Share know devices so devices from configuration don't get added as lights.

* Lookup unit from value_key.

* Remove debug.

* Start implementing event protocol in place of packet protocol.

- Added first test suite for sensors.
- This currently breaks light and switch.

* Refactor switch component to fit new rflink changes. Add test suite.

* Fix style.

* Refactor and test lights. Bring coverage to 100%.

* Use non-broken and production tested rflink module.

* Update requirements.

* Bump for logging.

* Improve readability.

* Do not use global variable but keep known device state in intended place.

* Improve docs.

* Make icon support generic.

* Disable overriding icons in config, as it belongs in customization. Only keep custom icon for entities that are able to detect a icon based on the thing they represent (sensors in this case).

* Implement configuration schema, overall refactor of magic values.

* Fix bug in config/test wait_for_ack.

* Small refactors.

* Move command logic into separate class.

* Convert command sending logic to class based pattern instead of using the event bus.

* Start not using bus for rflink event propagation to platforms.

* Do not use event bus for all entity types.

* Fire an event on the bus for every switch incoming rflink command.

* Resolve lint errors, remove some old code.

* Known devices no longer need to be registered separately.

* Log bus events.

* Event callback is a..... callback.

* Use full entity id for events.

* Move event sending to entity.

* Log incoming events.

* Make firing events optional inline with rfxtrx.

* Add foundation for signal repetition.

* Add signal repetition config and tests.

* Make plain switchable type explicitly configurable.

* Enable default entity settings for automatically added entities as well.

* Prevent default configuration leaking accross entities.

* Make sure device defaults don't get overwritten by defaults further down.

* Don't let fast state switching and repetitions turn your house into a disco.

* Make repetitions more responsive.

* Disable on/off fallback on dimmables as it currently doesn't play nice with repetitions.

* Use rflink that allows send_command_ack to be safely cancelled.

* Reduce duplication and make repeat work for non-ack.

* Implement reconnection logic.

* Improve reconnection logic.

* Also cancel repetitions when entity state is changed due to external command.

* Update requirements.

* Fix linting.

* Fix spelling.

* Don't lie.

* Fix lint.

* Support for automatically creating protocol translation (fixes spaces in device names).

* Returned support for dimmable and on/off entity.

* Duplicate code to fix linting issues with inheritance.

* Allow overriding unit of measurement from config.
2017-01-31 08:11:52 -08:00
Johan Bloemberg
9925b2a8e0 Load mqtt_eventstream before any other component. (#5629)
This ensures that initial state changes for components are broadcasted on the MQTT bus.
2017-01-31 08:02:28 -08:00
Michaël Arnauts
b080ae154c Add devices detected by ping as SOURCE_TYPE_ROUTER instead of GPS (#5625) 2017-01-31 08:01:14 -08:00
Adrián López
14f8bc26d1 Voice command API.AI. First import (#5462)
* Voice command API.AI. First import

* Fixes suggested by hound

* Fixing comments

* Fix pylint and pydocstyle errors

* Change how speech is defined

Also clean some unused constants, remove card type (not used), define
a message when action is not defined and improve the message when
action is unknown.

* Change how speech is defined

Clean some constants.
Improve error messages.
Delete card type, not used.

* Tests for new Api.ai component

* Use async_add_job to python compatibility. New test to measure response time

* Add async_action option to choose between waiting or not for the action to execute

* Travis-ci needs more time

* Removed timeout tests

* Removed timeout tests

* Added apiai to .coveragerc as specified by PR doc
2017-01-31 07:54:54 -08:00
Pascal Vizeli
88d9d787a6 Add unittests for FFmpeg and spliting binary sensor (#5659)
* Spliting ffmpeg binary sensor and move service to component.

* unittests for component

* add unittest for binary_sensor

* exclude camera for tests
2017-01-31 07:48:03 -08:00
Paulus Schoutsen
9ae574c7d9 Update frontend (#5669) 2017-01-31 07:39:01 -08:00
Daniel Høyer Iversen
29816f3041 Vlc (#5665)
* vlc default name
2017-01-31 13:51:02 +01:00
Teemu R
5f0138f8e4 new yeelight backend lib, new features (#5296)
* initial yeelight based on python-yeelight

* adapt yeelight's discovery code & suppress exceptions on set_default

* Support flash & code cleanups

Adds simple pulse for flashing, needs to be refined.
This commit also includes changing transition from seconds to milliseconds,
and cleans up the code quite a bit.

* cleanup code, adjust default transition to 350

* bump required version to 0.0.13

* Cleaning up and marking todos, ready to be reviewed

* Renamed back to yeelight.
* Removed effect support for now until we have some sane effects available.
* Add "breath" notification for flash, currently hidden behind a False check due to unknown issue not accepting it.
* TODO/open points are marked as such.

* Fix a typo in rgb calculation

* yeelight_<bulbtype>_<mac> for autodetected bulbs

hostname from mdns seems to vary

* Lint fixes, add music mode, fix flash

* Flash transforms now to red and back
* Fix lint warnings
* Add initial music mode.

* remove unused mode logging, move set_mode to turn_on

* Add save_on_change configuration variable

* yeelight: check if music mode is on before enabling it.

* Fix linting, bump required python-yeelight version

* More linting fixes, use import when needed instead of saving the module handle

* Use OR instead of + for features assignment

* Fix color temperature support, convert non-rgb values to rgb values in rgb()

* Fix typo on duration, thanks @qzapwy for noticing

* yeelight: fix issues from review, behave when not available

* Implement available()
* Fix transition to take seconds instead of milliseconds
* Fix default configuration for detected bulbs
* Cache values fetched in update()
* Add return values for methods

* yeelight: kwarg-given transition overrides config, slight cleanups

* change settings back to optional, request update when calling add_devices

* As future version of python-yeelight will wrap exceptions, we can handle broken connections more nicely.

* bump yeelight library version

* Remove unused import

* set the default only when settings are changed and not, e.g., when turned on by automation

* update comment & fix linting
2017-01-31 10:01:11 +01:00
Teemu R
2c31e3ea8c Cleanup modes & available, bump version requirement (#5606)
* Cleanup modes & available, bump version requirement

* check for Noneness on available
2017-01-31 09:23:05 +01:00
Marcelo Moreira de Mello
976cd545fe Fixes issue #5627 by bumping external Amcrest module to version 1.1.4 (#5662)
Add an optional extended description…
2017-01-31 09:19:49 +01:00
Adam Mills
7f3ee8a83c [docker] cec install path fixed upstream (#5651) 2017-01-30 21:27:20 -05:00
miniconfig
495b0667e9 Added new sensor component to monitor OpenEVSE chargers equipped with the WiFi Kit. 2017-01-30 15:29:56 -05:00
Daniel Høyer Iversen
3b32afda01 bug fix in hue (#5623) 2017-01-30 09:20:35 -08:00
Daniel Høyer Iversen
3a1607500e Add set_options_service for input select (#5630) 2017-01-30 09:17:57 -08:00
Matt N
1bf3eba603 yarn setup_js_dev was deleted (#5639) 2017-01-30 09:15:26 -08:00
Fabian Affolter
ab019b9747 Upgrade slacker to 0.9.40 (#5650) 2017-01-30 09:14:00 -08:00
Paulus Schoutsen
55992468b0 Update frontend (#5652)
* Return empty result when history date is in future

* Update frontend
2017-01-30 09:12:07 -08:00
Fabian Affolter
87764a51ba Use device_state_attributes() for platforms (#5649)
* Use device_state_attributes() for platforms

* Update test

* Fix lint issue
2017-01-30 16:16:49 +01:00
Pascal Vizeli
ca558f6485 Add unittest for cleanup not validate ssl stuff. (#5643) 2017-01-30 13:09:36 +01:00
Paulus Schoutsen
f1d1f7d032 Update frontend (#5642) 2017-01-30 00:57:13 -08:00
Paulus Schoutsen
c8ff1094f8 Update frontend (#5640) 2017-01-30 00:20:51 -08:00
Paulus Schoutsen
318f3c9625 Update frontend (#5638)
* Ensure fonts get loaded quicker

* Update frontend
2017-01-29 23:26:35 -08:00
Paulus Schoutsen
da4f402ebe Update frontend (#5637) 2017-01-29 18:43:39 -08:00
Paulus Schoutsen
b5047bbaad Prioritize core.js (#5636)
* Prioritize loading app core script

* change app skeleton to be small
2017-01-29 18:36:48 -08:00
Pascal Vizeli
847a5a064d Aiohttp client unittest (#5635)
* add test for cleanup

* add test for mjpeg stream
2017-01-29 16:15:40 -08:00
Pascal Vizeli
261ffbbfea Move part of image_processing tests (#5634)
* Move part of image_processing tests

* fix lint
2017-01-29 14:40:37 -08:00
Martin Hjelmare
24f828d7eb Fix mysensors RGB and W light turn on (#5608)
* RGBW light needs a white value defined.
* Log error if V_RGB is not 6 characters and V_RGBW not 8 characters.
2017-01-29 12:59:13 +01:00
Kyle Hendricks
fddab7f2b4 Fixes the AsusWRT ip neigh regex to handle the possible IPv6 "router" flag (#5605)
See the last line here: http://linux-ip.net/gl/ip-cref/ip-cref-node62.html
2017-01-29 09:37:59 +01:00
David-Leon Pohl
a9325ea663 Fixes: Pilight Switch rejects alphanumeric IDs #5119 (#5601) 2017-01-28 17:49:16 -08:00
Fabian Affolter
5ae5d9b576 Upgrade rpi-rf to 0.9.6 (#5611) 2017-01-28 17:05:24 -08:00
Paulus Schoutsen
e32f933cb6 Version bump to 0.38.0.dev0 2017-01-28 15:13:59 -08:00
772 changed files with 35060 additions and 9655 deletions

View File

@@ -5,6 +5,7 @@ omit =
homeassistant/__main__.py
homeassistant/scripts/*.py
homeassistant/helpers/typing.py
homeassistant/helpers/signal.py
# omit pieces of code that rely on external devices being present
homeassistant/components/apcupsd.py
@@ -13,9 +14,15 @@ omit =
homeassistant/components/arduino.py
homeassistant/components/*/arduino.py
homeassistant/components/android_ip_webcam.py
homeassistant/components/*/android_ip_webcam.py
homeassistant/components/bbb_gpio.py
homeassistant/components/*/bbb_gpio.py
homeassistant/components/blink.py
homeassistant/components/*/blink.py
homeassistant/components/bloomsky.py
homeassistant/components/*/bloomsky.py
@@ -40,6 +47,9 @@ omit =
homeassistant/components/insteon_local.py
homeassistant/components/*/insteon_local.py
homeassistant/components/insteon_plm.py
homeassistant/components/*/insteon_plm.py
homeassistant/components/ios.py
homeassistant/components/*/ios.py
@@ -49,6 +59,9 @@ omit =
homeassistant/components/lutron.py
homeassistant/components/*/lutron.py
homeassistant/components/lutron_caseta.py
homeassistant/components/*/lutron_caseta.py
homeassistant/components/modbus.py
homeassistant/components/*/modbus.py
@@ -81,12 +94,19 @@ omit =
homeassistant/components/*/thinkingcleaner.py
homeassistant/components/twilio.py
homeassistant/components/notify/twilio_sms.py
homeassistant/components/notify/twilio_call.py
homeassistant/components/vera.py
homeassistant/components/*/vera.py
homeassistant/components/verisure.py
homeassistant/components/*/verisure.py
homeassistant/components/volvooncall.py
homeassistant/components/*/volvooncall.py
homeassistant/components/*/webostv.py
homeassistant/components/wemo.py
@@ -98,9 +118,6 @@ omit =
homeassistant/components/zigbee.py
homeassistant/components/*/zigbee.py
homeassistant/components/zwave/*
homeassistant/components/*/zwave.py
homeassistant/components/enocean.py
homeassistant/components/*/enocean.py
@@ -116,9 +133,6 @@ omit =
homeassistant/components/knx.py
homeassistant/components/*/knx.py
homeassistant/components/ffmpeg.py
homeassistant/components/*/ffmpeg.py
homeassistant/components/zoneminder.py
homeassistant/components/*/zoneminder.py
@@ -128,10 +142,17 @@ omit =
homeassistant/components/zabbix.py
homeassistant/components/*/zabbix.py
homeassistant/components/maxcube.py
homeassistant/components/*/maxcube.py
homeassistant/components/tado.py
homeassistant/components/*/tado.py
homeassistant/components/alarm_control_panel/alarmdotcom.py
homeassistant/components/alarm_control_panel/concord232.py
homeassistant/components/alarm_control_panel/nx584.py
homeassistant/components/alarm_control_panel/simplisafe.py
homeassistant/components/apiai.py
homeassistant/components/binary_sensor/arest.py
homeassistant/components/binary_sensor/concord232.py
homeassistant/components/binary_sensor/flic.py
@@ -141,6 +162,7 @@ omit =
homeassistant/components/browser.py
homeassistant/components/camera/amcrest.py
homeassistant/components/camera/bloomsky.py
homeassistant/components/camera/ffmpeg.py
homeassistant/components/camera/foscam.py
homeassistant/components/camera/mjpeg.py
homeassistant/components/camera/rpi_camera.py
@@ -149,10 +171,13 @@ omit =
homeassistant/components/climate/heatmiser.py
homeassistant/components/climate/homematic.py
homeassistant/components/climate/knx.py
homeassistant/components/climate/oem.py
homeassistant/components/climate/proliphix.py
homeassistant/components/climate/radiotherm.py
homeassistant/components/config/zwave.py
homeassistant/components/cover/garadget.py
homeassistant/components/cover/homematic.py
homeassistant/components/cover/myq.py
homeassistant/components/cover/rpi_gpio.py
homeassistant/components/cover/scsgate.py
homeassistant/components/cover/wink.py
@@ -181,9 +206,7 @@ omit =
homeassistant/components/device_tracker/tplink.py
homeassistant/components/device_tracker/trackr.py
homeassistant/components/device_tracker/ubus.py
homeassistant/components/device_tracker/volvooncall.py
homeassistant/components/device_tracker/xiaomi.py
homeassistant/components/discovery.py
homeassistant/components/downloader.py
homeassistant/components/emoncms_history.py
homeassistant/components/emulated_hue/upnp.py
@@ -207,13 +230,17 @@ omit =
homeassistant/components/light/tikteck.py
homeassistant/components/light/x10.py
homeassistant/components/light/yeelight.py
homeassistant/components/light/yeelightsunflower.py
homeassistant/components/light/piglow.py
homeassistant/components/light/zengge.py
homeassistant/components/lirc.py
homeassistant/components/lock/nuki.py
homeassistant/components/media_player/anthemav.py
homeassistant/components/media_player/apple_tv.py
homeassistant/components/media_player/aquostv.py
homeassistant/components/media_player/braviatv.py
homeassistant/components/media_player/cast.py
homeassistant/components/media_player/clementine.py
homeassistant/components/media_player/cmus.py
homeassistant/components/media_player/denon.py
homeassistant/components/media_player/denonavr.py
@@ -221,15 +248,19 @@ omit =
homeassistant/components/media_player/dunehd.py
homeassistant/components/media_player/emby.py
homeassistant/components/media_player/firetv.py
homeassistant/components/media_player/frontier_silicon.py
homeassistant/components/media_player/gpmdp.py
homeassistant/components/media_player/gstreamer.py
homeassistant/components/media_player/hdmi_cec.py
homeassistant/components/media_player/itunes.py
homeassistant/components/media_player/kodi.py
homeassistant/components/media_player/lg_netcast.py
homeassistant/components/media_player/liveboxplaytv.py
homeassistant/components/media_player/mpchc.py
homeassistant/components/media_player/mpd.py
homeassistant/components/media_player/nad.py
homeassistant/components/media_player/onkyo.py
homeassistant/components/media_player/openhome.py
homeassistant/components/media_player/panasonic_viera.py
homeassistant/components/media_player/pandora.py
homeassistant/components/media_player/philips_js.py
@@ -242,10 +273,12 @@ omit =
homeassistant/components/media_player/sonos.py
homeassistant/components/media_player/squeezebox.py
homeassistant/components/media_player/vlc.py
homeassistant/components/media_player/volumio.py
homeassistant/components/media_player/yamaha.py
homeassistant/components/notify/aws_lambda.py
homeassistant/components/notify/aws_sns.py
homeassistant/components/notify/aws_sqs.py
homeassistant/components/notify/ciscospark.py
homeassistant/components/notify/discord.py
homeassistant/components/notify/facebook.py
homeassistant/components/notify/free_mobile.py
@@ -256,6 +289,7 @@ omit =
homeassistant/components/notify/kodi.py
homeassistant/components/notify/lannouncer.py
homeassistant/components/notify/llamalab_automate.py
homeassistant/components/notify/mailgun.py
homeassistant/components/notify/matrix.py
homeassistant/components/notify/message_bird.py
homeassistant/components/notify/nfandroidtv.py
@@ -263,6 +297,7 @@ omit =
homeassistant/components/notify/pushbullet.py
homeassistant/components/notify/pushetta.py
homeassistant/components/notify/pushover.py
homeassistant/components/notify/pushsafer.py
homeassistant/components/notify/rest.py
homeassistant/components/notify/sendgrid.py
homeassistant/components/notify/simplepush.py
@@ -271,12 +306,11 @@ omit =
homeassistant/components/notify/syslog.py
homeassistant/components/notify/telegram.py
homeassistant/components/notify/telstra.py
homeassistant/components/notify/twilio_sms.py
homeassistant/components/notify/twilio_call.py
homeassistant/components/notify/twitter.py
homeassistant/components/notify/xmpp.py
homeassistant/components/nuimo_controller.py
homeassistant/components/remote/harmony.py
homeassistant/components/remote/itach.py
homeassistant/components/scene/hunterdouglas_powerview.py
homeassistant/components/sensor/amcrest.py
homeassistant/components/sensor/arest.py
@@ -287,21 +321,26 @@ omit =
homeassistant/components/sensor/broadlink.py
homeassistant/components/sensor/dublin_bus_transport.py
homeassistant/components/sensor/coinmarketcap.py
homeassistant/components/sensor/comed_hourly_pricing.py
homeassistant/components/sensor/cpuspeed.py
homeassistant/components/sensor/cups.py
homeassistant/components/sensor/currencylayer.py
homeassistant/components/sensor/darksky.py
homeassistant/components/sensor/deutsche_bahn.py
homeassistant/components/sensor/dht.py
homeassistant/components/sensor/dnsip.py
homeassistant/components/sensor/dovado.py
homeassistant/components/sensor/dte_energy_bridge.py
homeassistant/components/sensor/efergy.py
homeassistant/components/sensor/ebox.py
homeassistant/components/sensor/eliqonline.py
homeassistant/components/sensor/emoncms.py
homeassistant/components/sensor/fastdotcom.py
homeassistant/components/sensor/fedex.py
homeassistant/components/sensor/fido.py
homeassistant/components/sensor/fitbit.py
homeassistant/components/sensor/fixer.py
homeassistant/components/sensor/fritzbox_callmonitor.py
homeassistant/components/sensor/fritzbox_netmonitor.py
homeassistant/components/sensor/glances.py
homeassistant/components/sensor/google_travel_time.py
homeassistant/components/sensor/gpsd.py
@@ -313,11 +352,13 @@ omit =
homeassistant/components/sensor/imap.py
homeassistant/components/sensor/imap_email_content.py
homeassistant/components/sensor/influxdb.py
homeassistant/components/sensor/kwb.py
homeassistant/components/sensor/lastfm.py
homeassistant/components/sensor/linux_battery.py
homeassistant/components/sensor/loopenergy.py
homeassistant/components/sensor/mhz19.py
homeassistant/components/sensor/lyft.py
homeassistant/components/sensor/miflora.py
homeassistant/components/sensor/modem_callerid.py
homeassistant/components/sensor/mqtt_room.py
homeassistant/components/sensor/netdata.py
homeassistant/components/sensor/neurio_energy.py
@@ -325,11 +366,14 @@ omit =
homeassistant/components/sensor/nzbget.py
homeassistant/components/sensor/ohmconnect.py
homeassistant/components/sensor/onewire.py
homeassistant/components/sensor/openevse.py
homeassistant/components/sensor/openexchangerates.py
homeassistant/components/sensor/openweathermap.py
homeassistant/components/sensor/pi_hole.py
homeassistant/components/sensor/plex.py
homeassistant/components/sensor/pocketcasts.py
homeassistant/components/sensor/pvoutput.py
homeassistant/components/sensor/qnap.py
homeassistant/components/sensor/sabnzbd.py
homeassistant/components/sensor/scrape.py
homeassistant/components/sensor/sensehat.py
@@ -352,6 +396,7 @@ omit =
homeassistant/components/sensor/transmission.py
homeassistant/components/sensor/twitch.py
homeassistant/components/sensor/uber.py
homeassistant/components/sensor/ups.py
homeassistant/components/sensor/usps.py
homeassistant/components/sensor/vasttrafik.py
homeassistant/components/sensor/waqi.py
@@ -365,6 +410,7 @@ omit =
homeassistant/components/switch/digitalloggers.py
homeassistant/components/switch/dlink.py
homeassistant/components/switch/edimax.py
homeassistant/components/switch/fritzdect.py
homeassistant/components/switch/hdmi_cec.py
homeassistant/components/switch/hikvisioncam.py
homeassistant/components/switch/hook.py
@@ -379,13 +425,18 @@ omit =
homeassistant/components/switch/tplink.py
homeassistant/components/switch/transmission.py
homeassistant/components/switch/wake_on_lan.py
homeassistant/components/telegram_webhooks.py
homeassistant/components/thingspeak.py
homeassistant/components/tts/amazon_polly.py
homeassistant/components/tts/picotts.py
homeassistant/components/upnp.py
homeassistant/components/weather/bom.py
homeassistant/components/weather/openweathermap.py
homeassistant/components/weather/zamg.py
homeassistant/components/zeroconf.py
homeassistant/components/zwave/__init__.py
homeassistant/components/zwave/util.py
homeassistant/components/zwave/workaround.py
[report]

View File

@@ -1,16 +1,16 @@
**Description:**
## Description:
**Related issue (if applicable):** fixes #<home-assistant issue number goes here>
**Pull request in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io) with documentation (if applicable):** home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
**Example entry for `configuration.yaml` (if applicable):**
## Example entry for `configuration.yaml` (if applicable):
```yaml
```
**Checklist:**
## Checklist:
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io)
@@ -26,5 +26,5 @@ If the code does not interact with devices:
- [ ] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**
- [ ] Tests have been added to verify that the new code works.
[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L16
[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L51
[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L14
[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L54

View File

@@ -14,6 +14,8 @@ matrix:
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36
- python: "3.6-dev"
env: TOXENV=py36
# allow_failures:
# - python: "3.5"
# env: TOXENV=typing

View File

@@ -1,14 +1,22 @@
FROM python:3.5
MAINTAINER Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>
# Uncomment any of the following lines to disable the installation.
#ENV INSTALL_TELLSTICK no
#ENV INSTALL_OPENALPR no
#ENV INSTALL_FFMPEG no
#ENV INSTALL_OPENZWAVE no
#ENV INSTALL_LIBCEC no
#ENV INSTALL_PHANTOMJS no
VOLUME /config
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Copy build scripts
COPY script/setup_docker_prereqs script/build_python_openzwave script/build_libcec script/install_phantomjs script/
RUN script/setup_docker_prereqs
COPY virtualization/Docker/ virtualization/Docker/
RUN virtualization/Docker/setup_docker_prereqs
# Install hass component dependencies
COPY requirements_all.txt requirements_all.txt
@@ -18,4 +26,4 @@ RUN pip3 install --no-cache-dir -r requirements_all.txt && \
# Copy source
COPY . .
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]
CMD [ "python", "-m", "homeassistant", "--config", "/config" ]

View File

@@ -1,5 +1,5 @@
include README.rst
include LICENSE
include LICENSE.md
graft homeassistant
prune homeassistant/components/frontend/www_static/home-assistant-polymer
recursive-exclude * *.py[co]

View File

@@ -75,7 +75,8 @@ Build home automation on top of your devices:
`Instapush <https://instapush.im>`__, `Notify My Android
(NMA) <http://www.notifymyandroid.com/>`__,
`PushBullet <https://www.pushbullet.com/>`__,
`PushOver <https://pushover.net/>`__, `Slack <https://slack.com/>`__,
`PushOver <https://pushover.net/>`__,
`Slack <https://slack.com/>`__,
`Telegram <https://telegram.org/>`__, `Join <http://joaoapps.com/join/>`__, and `Jabber
(XMPP) <http://xmpp.org>`__

View File

@@ -255,10 +255,13 @@ def closefds_osx(min_fd: int, max_fd: int) -> None:
def cmdline() -> List[str]:
"""Collect path and arguments to re-execute the current hass instance."""
if sys.argv[0].endswith('/__main__.py'):
if sys.argv[0].endswith(os.path.sep + '__main__.py'):
modulepath = os.path.dirname(sys.argv[0])
os.environ['PYTHONPATH'] = os.path.dirname(modulepath)
return [sys.executable] + [arg for arg in sys.argv if arg != '--daemon']
return [sys.executable] + [arg for arg in sys.argv if
arg != '--daemon']
else:
return [arg for arg in sys.argv if arg != '--daemon']
def setup_and_run_hass(config_dir: str,

View File

@@ -4,314 +4,30 @@ import logging
import logging.handlers
import os
import sys
from time import time
from collections import OrderedDict
from types import ModuleType
from typing import Any, Optional, Dict
import voluptuous as vol
from voluptuous.humanize import humanize_error
import homeassistant.components as core_components
from homeassistant.components import persistent_notification
import homeassistant.config as conf_util
import homeassistant.core as core
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
from homeassistant.setup import async_setup_component
import homeassistant.loader as loader
import homeassistant.util.package as pkg_util
from homeassistant.util.async import (
run_coroutine_threadsafe, run_callback_threadsafe)
from homeassistant.util.logging import AsyncHandler
from homeassistant.util.yaml import clear_secret_cache
from homeassistant.const import EVENT_COMPONENT_LOADED, PLATFORM_FORMAT
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import (
event_decorators, service, config_per_platform, extract_domain_configs)
from homeassistant.helpers.signal import async_register_signal_handling
_LOGGER = logging.getLogger(__name__)
ATTR_COMPONENT = 'component'
ERROR_LOG_FILENAME = 'home-assistant.log'
_PERSISTENT_ERRORS = {}
HA_COMPONENT_URL = '[{}](https://home-assistant.io/components/{}/)'
def setup_component(hass: core.HomeAssistant, domain: str,
config: Optional[Dict]=None) -> bool:
"""Setup a component and all its dependencies."""
return run_coroutine_threadsafe(
async_setup_component(hass, domain, config), loop=hass.loop).result()
@asyncio.coroutine
def async_setup_component(hass: core.HomeAssistant, domain: str,
config: Optional[Dict]=None) -> bool:
"""Setup a component and all its dependencies.
This method is a coroutine.
"""
if domain in hass.config.components:
_LOGGER.debug('Component %s already set up.', domain)
return True
if not loader.PREPARED:
yield from hass.loop.run_in_executor(None, loader.prepare, hass)
if config is None:
config = {}
components = loader.load_order_component(domain)
# OrderedSet is empty if component or dependencies could not be resolved
if not components:
_async_persistent_notification(hass, domain, True)
return False
for component in components:
res = yield from _async_setup_component(hass, component, config)
if not res:
_LOGGER.error('Component %s failed to setup', component)
_async_persistent_notification(hass, component, True)
return False
return True
def _handle_requirements(hass: core.HomeAssistant, component,
name: str) -> bool:
"""Install the requirements for a component.
This method needs to run in an executor.
"""
if hass.config.skip_pip or not hasattr(component, 'REQUIREMENTS'):
return True
for req in component.REQUIREMENTS:
if not pkg_util.install_package(req, target=hass.config.path('deps')):
_LOGGER.error('Not initializing %s because could not install '
'dependency %s', name, req)
_async_persistent_notification(hass, name)
return False
return True
@asyncio.coroutine
def _async_setup_component(hass: core.HomeAssistant,
domain: str, config) -> bool:
"""Setup a component for Home Assistant.
This method is a coroutine.
"""
# pylint: disable=too-many-return-statements
if domain in hass.config.components:
return True
setup_lock = hass.data.get('setup_lock')
if setup_lock is None:
setup_lock = hass.data['setup_lock'] = asyncio.Lock(loop=hass.loop)
setup_progress = hass.data.get('setup_progress')
if setup_progress is None:
setup_progress = hass.data['setup_progress'] = []
if domain in setup_progress:
_LOGGER.error('Attempt made to setup %s during setup of %s',
domain, domain)
_async_persistent_notification(hass, domain, True)
return False
try:
# Used to indicate to discovery that a setup is ongoing and allow it
# to wait till it is done.
did_lock = False
if not setup_lock.locked():
yield from setup_lock.acquire()
did_lock = True
setup_progress.append(domain)
config = yield from async_prepare_setup_component(hass, config, domain)
if config is None:
return False
component = loader.get_component(domain)
if component is None:
_async_persistent_notification(hass, domain)
return False
async_comp = hasattr(component, 'async_setup')
try:
_LOGGER.info("Setting up %s", domain)
if async_comp:
result = yield from component.async_setup(hass, config)
else:
result = yield from hass.loop.run_in_executor(
None, component.setup, hass, config)
except Exception: # pylint: disable=broad-except
_LOGGER.exception('Error during setup of component %s', domain)
_async_persistent_notification(hass, domain, True)
return False
if result is False:
_LOGGER.error('component %s failed to initialize', domain)
_async_persistent_notification(hass, domain, True)
return False
elif result is not True:
_LOGGER.error('component %s did not return boolean if setup '
'was successful. Disabling component.', domain)
_async_persistent_notification(hass, domain, True)
loader.set_component(domain, None)
return False
hass.config.components.append(component.DOMAIN)
hass.bus.async_fire(
EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: component.DOMAIN}
)
return True
finally:
setup_progress.remove(domain)
if did_lock:
setup_lock.release()
def prepare_setup_component(hass: core.HomeAssistant, config: dict,
domain: str):
"""Prepare setup of a component and return processed config."""
return run_coroutine_threadsafe(
async_prepare_setup_component(hass, config, domain), loop=hass.loop
).result()
@asyncio.coroutine
def async_prepare_setup_component(hass: core.HomeAssistant, config: dict,
domain: str):
"""Prepare setup of a component and return processed config.
This method is a coroutine.
"""
# pylint: disable=too-many-return-statements
component = loader.get_component(domain)
missing_deps = [dep for dep in getattr(component, 'DEPENDENCIES', [])
if dep not in hass.config.components]
if missing_deps:
_LOGGER.error(
'Not initializing %s because not all dependencies loaded: %s',
domain, ", ".join(missing_deps))
return None
if hasattr(component, 'CONFIG_SCHEMA'):
try:
config = component.CONFIG_SCHEMA(config)
except vol.Invalid as ex:
async_log_exception(ex, domain, config, hass)
return None
elif hasattr(component, 'PLATFORM_SCHEMA'):
platforms = []
for p_name, p_config in config_per_platform(config, domain):
# Validate component specific platform schema
try:
p_validated = component.PLATFORM_SCHEMA(p_config)
except vol.Invalid as ex:
async_log_exception(ex, domain, config, hass)
continue
# Not all platform components follow same pattern for platforms
# So if p_name is None we are not going to validate platform
# (the automation component is one of them)
if p_name is None:
platforms.append(p_validated)
continue
platform = yield from async_prepare_setup_platform(
hass, config, domain, p_name)
if platform is None:
continue
# Validate platform specific schema
if hasattr(platform, 'PLATFORM_SCHEMA'):
try:
# pylint: disable=no-member
p_validated = platform.PLATFORM_SCHEMA(p_validated)
except vol.Invalid as ex:
async_log_exception(ex, '{}.{}'.format(domain, p_name),
p_validated, hass)
continue
platforms.append(p_validated)
# Create a copy of the configuration with all config for current
# component removed and add validated config back in.
filter_keys = extract_domain_configs(config, domain)
config = {key: value for key, value in config.items()
if key not in filter_keys}
config[domain] = platforms
res = yield from hass.loop.run_in_executor(
None, _handle_requirements, hass, component, domain)
if not res:
return None
return config
def prepare_setup_platform(hass: core.HomeAssistant, config, domain: str,
platform_name: str) -> Optional[ModuleType]:
"""Load a platform and makes sure dependencies are setup."""
return run_coroutine_threadsafe(
async_prepare_setup_platform(hass, config, domain, platform_name),
loop=hass.loop
).result()
@asyncio.coroutine
def async_prepare_setup_platform(hass: core.HomeAssistant, config, domain: str,
platform_name: str) \
-> Optional[ModuleType]:
"""Load a platform and makes sure dependencies are setup.
This method is a coroutine.
"""
if not loader.PREPARED:
yield from hass.loop.run_in_executor(None, loader.prepare, hass)
platform_path = PLATFORM_FORMAT.format(domain, platform_name)
platform = loader.get_platform(domain, platform_name)
# Not found
if platform is None:
_LOGGER.error('Unable to find platform %s', platform_path)
_async_persistent_notification(hass, platform_path)
return None
# Already loaded
elif platform_path in hass.config.components:
return platform
# Load dependencies
for component in getattr(platform, 'DEPENDENCIES', []):
res = yield from async_setup_component(hass, component, config)
if not res:
_LOGGER.error(
'Unable to prepare setup for platform %s because '
'dependency %s could not be initialized', platform_path,
component)
_async_persistent_notification(hass, platform_path, True)
return None
res = yield from hass.loop.run_in_executor(
None, _handle_requirements, hass, platform, platform_path)
if not res:
return None
return platform
FIRST_INIT_COMPONENT = set((
'recorder', 'mqtt', 'mqtt_eventstream', 'logger', 'introduction'))
def from_config_dict(config: Dict[str, Any],
@@ -333,23 +49,14 @@ def from_config_dict(config: Dict[str, Any],
hass.config.config_dir = config_dir
mount_local_lib_path(config_dir)
@asyncio.coroutine
def _async_init_from_config_dict(future):
try:
re_hass = yield from async_from_config_dict(
config, hass, config_dir, enable_log, verbose, skip_pip,
log_rotate_days)
future.set_result(re_hass)
# pylint: disable=broad-except
except Exception as exc:
future.set_exception(exc)
# run task
future = asyncio.Future(loop=hass.loop)
hass.async_add_job(_async_init_from_config_dict(future))
hass.loop.run_until_complete(future)
hass = hass.loop.run_until_complete(
async_from_config_dict(
config, hass, config_dir, enable_log, verbose, skip_pip,
log_rotate_days)
)
return future.result()
return hass
@asyncio.coroutine
@@ -366,26 +73,22 @@ def async_from_config_dict(config: Dict[str, Any],
Dynamically loads required components and its dependencies.
This method is a coroutine.
"""
start = time()
hass.async_track_tasks()
setup_lock = hass.data.get('setup_lock')
if setup_lock is None:
setup_lock = hass.data['setup_lock'] = asyncio.Lock(loop=hass.loop)
yield from setup_lock.acquire()
core_config = config.get(core.DOMAIN, {})
try:
yield from conf_util.async_process_ha_core_config(hass, core_config)
except vol.Invalid as ex:
async_log_exception(ex, 'homeassistant', core_config, hass)
conf_util.async_log_exception(ex, 'homeassistant', core_config, hass)
return None
yield from hass.loop.run_in_executor(
None, conf_util.process_ha_config_upgrade, hass)
if enable_log:
enable_logging(hass, verbose, log_rotate_days)
async_enable_logging(hass, verbose, log_rotate_days)
hass.config.skip_pip = skip_pip
if skip_pip:
@@ -423,18 +126,26 @@ def async_from_config_dict(config: Dict[str, Any],
_LOGGER.info('Home Assistant core initialized')
# Give event decorators access to HASS
event_decorators.HASS = hass
service.HASS = hass
# stage 1
for component in components:
if component not in FIRST_INIT_COMPONENT:
continue
hass.async_add_job(async_setup_component(hass, component, config))
# Setup the components
for domain in loader.load_order_components(components):
yield from _async_setup_component(hass, domain, config)
yield from hass.async_block_till_done()
setup_lock.release()
# stage 2
for component in components:
if component in FIRST_INIT_COMPONENT:
continue
hass.async_add_job(async_setup_component(hass, component, config))
yield from hass.async_stop_track_tasks()
stop = time()
_LOGGER.info('Home Assistant initialized in %ss', round(stop-start, 2))
async_register_signal_handling(hass)
return hass
@@ -451,22 +162,13 @@ def from_config_file(config_path: str,
if hass is None:
hass = core.HomeAssistant()
@asyncio.coroutine
def _async_init_from_config_file(future):
try:
re_hass = yield from async_from_config_file(
config_path, hass, verbose, skip_pip, log_rotate_days)
future.set_result(re_hass)
# pylint: disable=broad-except
except Exception as exc:
future.set_exception(exc)
# run task
future = asyncio.Future(loop=hass.loop)
hass.loop.create_task(_async_init_from_config_file(future))
hass.loop.run_until_complete(future)
hass = hass.loop.run_until_complete(
async_from_config_file(
config_path, hass, verbose, skip_pip, log_rotate_days)
)
return future.result()
return hass
@asyncio.coroutine
@@ -486,12 +188,13 @@ def async_from_config_file(config_path: str,
yield from hass.loop.run_in_executor(
None, mount_local_lib_path, config_dir)
enable_logging(hass, verbose, log_rotate_days)
async_enable_logging(hass, verbose, log_rotate_days)
try:
config_dict = yield from hass.loop.run_in_executor(
None, conf_util.load_yaml_config_file, config_path)
except HomeAssistantError:
except HomeAssistantError as err:
_LOGGER.error('Error loading %s: %s', config_path, err)
return None
finally:
clear_secret_cache()
@@ -501,11 +204,12 @@ def async_from_config_file(config_path: str,
return hass
def enable_logging(hass: core.HomeAssistant, verbose: bool=False,
log_rotate_days=None) -> None:
@core.callback
def async_enable_logging(hass: core.HomeAssistant, verbose: bool=False,
log_rotate_days=None) -> None:
"""Setup the logging.
Async friendly.
This method must be run in the event loop.
"""
logging.basicConfig(level=logging.INFO)
fmt = ("%(asctime)s %(levelname)s (%(threadName)s) "
@@ -535,10 +239,6 @@ def enable_logging(hass: core.HomeAssistant, verbose: bool=False,
except ImportError:
pass
# AsyncHandler allready exists?
if hass.data.get(core.DATA_ASYNCHANDLER):
return
# Log errors to a file if we have write access to file or config dir
err_log_path = hass.config.path(ERROR_LOG_FILENAME)
err_path_exists = os.path.isfile(err_log_path)
@@ -559,7 +259,15 @@ def enable_logging(hass: core.HomeAssistant, verbose: bool=False,
err_handler.setFormatter(logging.Formatter(fmt, datefmt=datefmt))
async_handler = AsyncHandler(hass.loop, err_handler)
hass.data[core.DATA_ASYNCHANDLER] = async_handler
@asyncio.coroutine
def async_stop_async_handler(event):
"""Cleanup async handler."""
logging.getLogger('').removeHandler(async_handler)
yield from async_handler.async_close(blocking=True)
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_CLOSE, async_stop_async_handler)
logger = logging.getLogger('')
logger.addHandler(async_handler)
@@ -570,57 +278,6 @@ def enable_logging(hass: core.HomeAssistant, verbose: bool=False,
'Unable to setup error log %s (access denied)', err_log_path)
def log_exception(ex, domain, config, hass):
"""Generate log exception for config validation."""
run_callback_threadsafe(
hass.loop, async_log_exception, ex, domain, config, hass).result()
@core.callback
def _async_persistent_notification(hass: core.HomeAssistant, component: str,
link: Optional[bool]=False):
"""Print a persistent notification.
This method must be run in the event loop.
"""
_PERSISTENT_ERRORS[component] = _PERSISTENT_ERRORS.get(component) or link
_lst = [HA_COMPONENT_URL.format(name.replace('_', '-'), name)
if link else name for name, link in _PERSISTENT_ERRORS.items()]
message = ('The following components and platforms could not be set up:\n'
'* ' + '\n* '.join(list(_lst)) + '\nPlease check your config')
persistent_notification.async_create(
hass, message, 'Invalid config', 'invalid_config')
@core.callback
def async_log_exception(ex, domain, config, hass):
"""Generate log exception for config validation.
This method must be run in the event loop.
"""
message = 'Invalid config for [{}]: '.format(domain)
if hass is not None:
_async_persistent_notification(hass, domain, True)
if 'extra keys not allowed' in ex.error_message:
message += '[{}] is an invalid option for [{}]. Check: {}->{}.'\
.format(ex.path[-1], domain, domain,
'->'.join(str(m) for m in ex.path))
else:
message += '{}.'.format(humanize_error(config, ex))
domain_config = config.get(domain, config)
message += " (See {}, line {}). ".format(
getattr(domain_config, '__config_file__', '?'),
getattr(domain_config, '__line__', '?'))
if domain != 'homeassistant':
message += ('Please check the docs at '
'https://home-assistant.io/components/{}/'.format(domain))
_LOGGER.error(message)
def mount_local_lib_path(config_dir: str) -> str:
"""Add local library to Python Path.

View File

@@ -12,14 +12,19 @@ import itertools as it
import logging
import homeassistant.core as ha
import homeassistant.config as conf_util
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.service import extract_entity_ids
from homeassistant.loader import get_component
from homeassistant.const import (
ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE)
ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE,
SERVICE_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_RESTART,
RESTART_EXIT_CODE)
_LOGGER = logging.getLogger(__name__)
SERVICE_RELOAD_CORE_CONFIG = 'reload_core_config'
SERVICE_CHECK_CONFIG = 'check_config'
def is_on(hass, entity_id=None):
@@ -75,6 +80,21 @@ def toggle(hass, entity_id=None, **service_data):
hass.services.call(ha.DOMAIN, SERVICE_TOGGLE, service_data)
def stop(hass):
"""Stop Home Assistant."""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP)
def restart(hass):
"""Stop Home Assistant."""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_RESTART)
def check_config(hass):
"""Check the config files."""
hass.services.call(ha.DOMAIN, SERVICE_CHECK_CONFIG)
def reload_core_config(hass):
"""Reload the core config."""
hass.services.call(ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG)
@@ -84,7 +104,7 @@ def reload_core_config(hass):
def async_setup(hass, config):
"""Setup general services related to Home Assistant."""
@asyncio.coroutine
def handle_turn_service(service):
def async_handle_turn_service(service):
"""Method to handle calls to homeassistant.turn_on/off."""
entity_ids = extract_entity_ids(hass, service)
@@ -122,18 +142,45 @@ def async_setup(hass, config):
yield from asyncio.wait(tasks, loop=hass.loop)
hass.services.async_register(
ha.DOMAIN, SERVICE_TURN_OFF, handle_turn_service)
ha.DOMAIN, SERVICE_TURN_OFF, async_handle_turn_service)
hass.services.async_register(
ha.DOMAIN, SERVICE_TURN_ON, handle_turn_service)
ha.DOMAIN, SERVICE_TURN_ON, async_handle_turn_service)
hass.services.async_register(
ha.DOMAIN, SERVICE_TOGGLE, handle_turn_service)
ha.DOMAIN, SERVICE_TOGGLE, async_handle_turn_service)
@asyncio.coroutine
def handle_reload_config(call):
"""Service handler for reloading core config."""
from homeassistant.exceptions import HomeAssistantError
from homeassistant import config as conf_util
def async_handle_core_service(call):
"""Service handler for handling core services."""
if call.service == SERVICE_HOMEASSISTANT_STOP:
hass.async_add_job(hass.async_stop())
return
try:
errors = yield from conf_util.async_check_ha_config_file(hass)
except HomeAssistantError:
return
if errors:
notif = get_component('persistent_notification')
_LOGGER.error(errors)
notif.async_create(
hass, "Config error. See dev-info panel for details.",
"Config validating", "{0}.check_config".format(ha.DOMAIN))
return
if call.service == SERVICE_HOMEASSISTANT_RESTART:
hass.async_add_job(hass.async_stop(RESTART_EXIT_CODE))
hass.services.async_register(
ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP, async_handle_core_service)
hass.services.async_register(
ha.DOMAIN, SERVICE_HOMEASSISTANT_RESTART, async_handle_core_service)
hass.services.async_register(
ha.DOMAIN, SERVICE_CHECK_CONFIG, async_handle_core_service)
@asyncio.coroutine
def async_handle_reload_config(call):
"""Service handler for reloading core config."""
try:
conf = yield from conf_util.async_hass_config_yaml(hass)
except HomeAssistantError as err:
@@ -144,6 +191,6 @@ def async_setup(hass, config):
hass, conf.get(ha.DOMAIN) or {})
hass.services.async_register(
ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG, handle_reload_config)
ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG, async_handle_reload_config)
return True

View File

@@ -113,7 +113,7 @@ def async_setup(hass, config):
if not alarm.should_poll:
continue
update_coro = hass.loop.create_task(
update_coro = hass.async_add_job(
alarm.async_update_ha_state(True))
if hasattr(alarm, 'async_update'):
update_tasks.append(update_coro)

View File

@@ -4,16 +4,20 @@ Support for Envisalink-based alarm control panels (Honeywell/DSC).
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.envisalink/
"""
from os import path
import asyncio
import logging
import os
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
import homeassistant.components.alarm_control_panel as alarm
import homeassistant.helpers.config_validation as cv
from homeassistant.config import load_yaml_config_file
from homeassistant.components.envisalink import (
EVL_CONTROLLER, EnvisalinkDevice, PARTITION_SCHEMA, CONF_CODE, CONF_PANIC,
CONF_PARTITIONNAME, SIGNAL_PARTITION_UPDATE, SIGNAL_KEYPAD_UPDATE)
DATA_EVL, EnvisalinkDevice, PARTITION_SCHEMA, CONF_CODE, CONF_PANIC,
CONF_PARTITIONNAME, SIGNAL_KEYPAD_UPDATE, SIGNAL_PARTITION_UPDATE)
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
STATE_UNKNOWN, STATE_ALARM_TRIGGERED, STATE_ALARM_PENDING, ATTR_ENTITY_ID)
@@ -22,8 +26,6 @@ _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['envisalink']
DEVICES = []
SERVICE_ALARM_KEYPRESS = 'envisalink_alarm_keypress'
ATTR_KEYPRESS = 'keypress'
ALARM_KEYPRESS_SCHEMA = vol.Schema({
@@ -32,68 +34,75 @@ ALARM_KEYPRESS_SCHEMA = vol.Schema({
})
def alarm_keypress_handler(service):
"""Map services to methods on Alarm."""
entity_ids = service.data.get(ATTR_ENTITY_ID)
keypress = service.data.get(ATTR_KEYPRESS)
_target_devices = [device for device in DEVICES
if device.entity_id in entity_ids]
for device in _target_devices:
EnvisalinkAlarm.alarm_keypress(device, keypress)
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Perform the setup for Envisalink alarm panels."""
_configured_partitions = discovery_info['partitions']
_code = discovery_info[CONF_CODE]
_panic_type = discovery_info[CONF_PANIC]
for part_num in _configured_partitions:
_device_config_data = PARTITION_SCHEMA(
_configured_partitions[part_num])
_device = EnvisalinkAlarm(
part_num,
_device_config_data[CONF_PARTITIONNAME],
_code,
_panic_type,
EVL_CONTROLLER.alarm_state['partition'][part_num],
EVL_CONTROLLER)
DEVICES.append(_device)
configured_partitions = discovery_info['partitions']
code = discovery_info[CONF_CODE]
panic_type = discovery_info[CONF_PANIC]
add_devices(DEVICES)
devices = []
for part_num in configured_partitions:
device_config_data = PARTITION_SCHEMA(configured_partitions[part_num])
device = EnvisalinkAlarm(
hass,
part_num,
device_config_data[CONF_PARTITIONNAME],
code,
panic_type,
hass.data[DATA_EVL].alarm_state['partition'][part_num],
hass.data[DATA_EVL]
)
devices.append(device)
async_add_devices(devices)
@callback
def alarm_keypress_handler(service):
"""Map services to methods on Alarm."""
entity_ids = service.data.get(ATTR_ENTITY_ID)
keypress = service.data.get(ATTR_KEYPRESS)
target_devices = [device for device in devices
if device.entity_id in entity_ids]
for device in target_devices:
device.async_alarm_keypress(keypress)
# Register Envisalink specific services
descriptions = load_yaml_config_file(
path.join(path.dirname(__file__), 'services.yaml'))
descriptions = yield from hass.loop.run_in_executor(
None, load_yaml_config_file, os.path.join(
os.path.dirname(__file__), 'services.yaml'))
hass.services.async_register(
alarm.DOMAIN, SERVICE_ALARM_KEYPRESS, alarm_keypress_handler,
descriptions.get(SERVICE_ALARM_KEYPRESS), schema=ALARM_KEYPRESS_SCHEMA)
hass.services.register(alarm.DOMAIN, SERVICE_ALARM_KEYPRESS,
alarm_keypress_handler,
descriptions.get(SERVICE_ALARM_KEYPRESS),
schema=ALARM_KEYPRESS_SCHEMA)
return True
class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
"""Representation of an Envisalink-based alarm panel."""
def __init__(self, partition_number, alarm_name, code, panic_type, info,
controller):
def __init__(self, hass, partition_number, alarm_name, code, panic_type,
info, controller):
"""Initialize the alarm panel."""
from pydispatch import dispatcher
self._partition_number = partition_number
self._code = code
self._panic_type = panic_type
_LOGGER.debug("Setting up alarm: %s", alarm_name)
EnvisalinkDevice.__init__(self, alarm_name, info, controller)
dispatcher.connect(
self._update_callback, signal=SIGNAL_PARTITION_UPDATE,
sender=dispatcher.Any)
dispatcher.connect(
self._update_callback, signal=SIGNAL_KEYPAD_UPDATE,
sender=dispatcher.Any)
_LOGGER.debug("Setting up alarm: %s", alarm_name)
super().__init__(alarm_name, info, controller)
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
async_dispatcher_connect(
self.hass, SIGNAL_PARTITION_UPDATE, self._update_callback)
@callback
def _update_callback(self, partition):
"""Update HA state, if needed."""
if partition is None or int(partition) == self._partition_number:
@@ -126,39 +135,44 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
state = STATE_ALARM_DISARMED
return state
def alarm_disarm(self, code=None):
@asyncio.coroutine
def async_alarm_disarm(self, code=None):
"""Send disarm command."""
if code:
EVL_CONTROLLER.disarm_partition(str(code),
self._partition_number)
self.hass.data[DATA_EVL].disarm_partition(
str(code), self._partition_number)
else:
EVL_CONTROLLER.disarm_partition(str(self._code),
self._partition_number)
self.hass.data[DATA_EVL].disarm_partition(
str(self._code), self._partition_number)
def alarm_arm_home(self, code=None):
@asyncio.coroutine
def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
if code:
EVL_CONTROLLER.arm_stay_partition(str(code),
self._partition_number)
self.hass.data[DATA_EVL].arm_stay_partition(
str(code), self._partition_number)
else:
EVL_CONTROLLER.arm_stay_partition(str(self._code),
self._partition_number)
self.hass.data[DATA_EVL].arm_stay_partition(
str(self._code), self._partition_number)
def alarm_arm_away(self, code=None):
@asyncio.coroutine
def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
if code:
EVL_CONTROLLER.arm_away_partition(str(code),
self._partition_number)
self.hass.data[DATA_EVL].arm_away_partition(
str(code), self._partition_number)
else:
EVL_CONTROLLER.arm_away_partition(str(self._code),
self._partition_number)
self.hass.data[DATA_EVL].arm_away_partition(
str(self._code), self._partition_number)
def alarm_trigger(self, code=None):
@asyncio.coroutine
def async_alarm_trigger(self, code=None):
"""Alarm trigger command. Will be used to trigger a panic alarm."""
EVL_CONTROLLER.panic_alarm(self._panic_type)
self.hass.data[DATA_EVL].panic_alarm(self._panic_type)
def alarm_keypress(self, keypress=None):
@callback
def async_alarm_keypress(self, keypress=None):
"""Send custom keypress."""
if keypress:
EVL_CONTROLLER.keypresses_to_partition(self._partition_number,
keypress)
self.hass.data[DATA_EVL].keypresses_to_partition(
self._partition_number, keypress)

View File

@@ -4,10 +4,12 @@ This platform enables the possibility to control a MQTT alarm.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/alarm_control_panel.mqtt/
"""
import asyncio
import logging
import voluptuous as vol
from homeassistant.core import callback
import homeassistant.components.alarm_control_panel as alarm
import homeassistant.components.mqtt as mqtt
from homeassistant.const import (
@@ -41,10 +43,10 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend({
})
def setup_platform(hass, config, add_devices, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup the MQTT platform."""
add_devices([MqttAlarm(
hass,
async_add_devices([MqttAlarm(
config.get(CONF_NAME),
config.get(CONF_STATE_TOPIC),
config.get(CONF_COMMAND_TOPIC),
@@ -58,11 +60,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class MqttAlarm(alarm.AlarmControlPanel):
"""Representation of a MQTT alarm status."""
def __init__(self, hass, name, state_topic, command_topic, qos,
payload_disarm, payload_arm_home, payload_arm_away, code):
def __init__(self, name, state_topic, command_topic, qos, payload_disarm,
payload_arm_home, payload_arm_away, code):
"""Initalize the MQTT alarm panel."""
self._state = STATE_UNKNOWN
self._hass = hass
self._name = name
self._state_topic = state_topic
self._command_topic = command_topic
@@ -72,6 +73,12 @@ class MqttAlarm(alarm.AlarmControlPanel):
self._payload_arm_away = payload_arm_away
self._code = code
def async_added_to_hass(self):
"""Subscribe mqtt events.
This method must be run in the event loop and returns a coroutine.
"""
@callback
def message_received(topic, payload, qos):
"""A new MQTT message has been received."""
if payload not in (STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME,
@@ -80,9 +87,10 @@ class MqttAlarm(alarm.AlarmControlPanel):
_LOGGER.warning('Received unexpected payload: %s', payload)
return
self._state = payload
self.update_ha_state()
self.hass.async_add_job(self.async_update_ha_state())
mqtt.subscribe(hass, self._state_topic, message_received, self._qos)
return mqtt.async_subscribe(
self.hass, self._state_topic, message_received, self._qos)
@property
def should_poll(self):
@@ -104,26 +112,38 @@ class MqttAlarm(alarm.AlarmControlPanel):
"""One or more characters if code is defined."""
return None if self._code is None else '.+'
def alarm_disarm(self, code=None):
"""Send disarm command."""
@asyncio.coroutine
def async_alarm_disarm(self, code=None):
"""Send disarm command.
This method is a coroutine.
"""
if not self._validate_code(code, 'disarming'):
return
mqtt.publish(self.hass, self._command_topic,
self._payload_disarm, self._qos)
mqtt.async_publish(
self.hass, self._command_topic, self._payload_disarm, self._qos)
def alarm_arm_home(self, code=None):
"""Send arm home command."""
@asyncio.coroutine
def async_alarm_arm_home(self, code=None):
"""Send arm home command.
This method is a coroutine.
"""
if not self._validate_code(code, 'arming home'):
return
mqtt.publish(self.hass, self._command_topic,
self._payload_arm_home, self._qos)
mqtt.async_publish(
self.hass, self._command_topic, self._payload_arm_home, self._qos)
def alarm_arm_away(self, code=None):
"""Send arm away command."""
@asyncio.coroutine
def async_alarm_arm_away(self, code=None):
"""Send arm away command.
This method is a coroutine.
"""
if not self._validate_code(code, 'arming away'):
return
mqtt.publish(self.hass, self._command_topic,
self._payload_arm_away, self._qos)
mqtt.async_publish(
self.hass, self._command_topic, self._payload_arm_away, self._qos)
def _validate_code(self, code, state):
"""Validate given code."""

View File

@@ -12,16 +12,19 @@ import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, STATE_UNKNOWN, CONF_CODE, CONF_NAME,
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY)
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
EVENT_HOMEASSISTANT_STOP)
import homeassistant.helpers.config_validation as cv
import homeassistant.loader as loader
REQUIREMENTS = ['https://github.com/w1ll1am23/simplisafe-python/archive/'
'586fede0e85fd69e56e516aaa8e97eb644ca8866.zip#'
'simplisafe-python==0.0.1']
REQUIREMENTS = ['simplisafe-python==1.0.2']
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'SimpliSafe'
DOMAIN = 'simplisafe'
NOTIFICATION_ID = 'simplisafe_notification'
NOTIFICATION_TITLE = 'SimpliSafe Setup'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_PASSWORD): cv.string,
@@ -33,33 +36,44 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the SimpliSafe platform."""
from simplipy.api import SimpliSafeApiInterface, get_systems
name = config.get(CONF_NAME)
code = config.get(CONF_CODE)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
add_devices([SimpliSafeAlarm(name, username, password, code)])
persistent_notification = loader.get_component('persistent_notification')
simplisafe = SimpliSafeApiInterface()
status = simplisafe.set_credentials(username, password)
if status:
hass.data[DOMAIN] = simplisafe
locations = get_systems(simplisafe)
for location in locations:
add_devices([SimpliSafeAlarm(location, name, code)])
else:
message = 'Failed to log into SimpliSafe. Check credentials.'
_LOGGER.error(message)
persistent_notification.create(
hass, message,
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID)
return False
def logout(event):
"""Logout of the SimpliSafe API."""
hass.data[DOMAIN].logout()
hass.bus.listen(EVENT_HOMEASSISTANT_STOP, logout)
class SimpliSafeAlarm(alarm.AlarmControlPanel):
"""Representation a SimpliSafe alarm."""
def __init__(self, name, username, password, code):
def __init__(self, simplisafe, name, code):
"""Initialize the SimpliSafe alarm."""
from simplisafe import SimpliSafe
self.simplisafe = SimpliSafe(username, password)
self.simplisafe = simplisafe
self._name = name
self._code = str(code) if code else None
self._id = self.simplisafe.get_id()
status = self.simplisafe.get_state()
if status == 'Off':
self._state = STATE_ALARM_DISARMED
elif status == 'Home':
self._state = STATE_ALARM_ARMED_HOME
elif status == 'Away':
self._state = STATE_ALARM_ARMED_AWAY
else:
self._state = STATE_UNKNOWN
@property
def name(self):
@@ -67,7 +81,7 @@ class SimpliSafeAlarm(alarm.AlarmControlPanel):
if self._name is not None:
return self._name
else:
return 'Alarm {}'.format(self._id)
return 'Alarm {}'.format(self.simplisafe.location_id())
@property
def code_format(self):
@@ -77,21 +91,32 @@ class SimpliSafeAlarm(alarm.AlarmControlPanel):
@property
def state(self):
"""Return the state of the device."""
return self._state
status = self.simplisafe.state()
if status == 'Off':
state = STATE_ALARM_DISARMED
elif status == 'Home':
state = STATE_ALARM_ARMED_HOME
elif status == 'Away':
state = STATE_ALARM_ARMED_AWAY
else:
state = STATE_UNKNOWN
return state
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {
'temperature': self.simplisafe.temperature(),
'co': self.simplisafe.carbon_monoxide(),
'fire': self.simplisafe.fire(),
'alarm': self.simplisafe.alarm(),
'last_event': self.simplisafe.last_event(),
'flood': self.simplisafe.flood()
}
def update(self):
"""Update alarm status."""
self.simplisafe.get_location()
status = self.simplisafe.get_state()
if status == 'Off':
self._state = STATE_ALARM_DISARMED
elif status == 'Home':
self._state = STATE_ALARM_ARMED_HOME
elif status == 'Away':
self._state = STATE_ALARM_ARMED_AWAY
else:
self._state = STATE_UNKNOWN
self.simplisafe.update()
def alarm_disarm(self, code=None):
"""Send disarm command."""

View File

@@ -11,7 +11,7 @@ from homeassistant.const import (STATE_UNKNOWN,
STATE_ALARM_DISARMED,
STATE_ALARM_ARMED_HOME,
STATE_ALARM_ARMED_AWAY)
from homeassistant.components.wink import WinkDevice
from homeassistant.components.wink import WinkDevice, DOMAIN
_LOGGER = logging.getLogger(__name__)
@@ -24,7 +24,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import pywink
for camera in pywink.get_cameras():
add_devices([WinkCameraDevice(camera, hass)])
# get_cameras returns multiple device types.
# Only add those that aren't sensors.
try:
camera.capability()
except AttributeError:
_id = camera.object_id() + camera.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkCameraDevice(camera, hass)])
class WinkCameraDevice(WinkDevice, alarm.AlarmControlPanel):
@@ -32,7 +39,7 @@ class WinkCameraDevice(WinkDevice, alarm.AlarmControlPanel):
def __init__(self, wink, hass):
"""Initialize the Wink alarm."""
WinkDevice.__init__(self, wink, hass)
super().__init__(wink, hass)
@property
def state(self):

View File

@@ -0,0 +1,276 @@
"""
Support for repeating alerts when conditions are met.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/alert/
"""
import asyncio
from datetime import datetime, timedelta
import logging
import os
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.config import load_yaml_config_file
from homeassistant.const import (
CONF_ENTITY_ID, STATE_IDLE, CONF_NAME, CONF_STATE, STATE_ON, STATE_OFF,
SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_ENTITY_ID)
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers import service, event
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'alert'
ENTITY_ID_FORMAT = DOMAIN + '.{}'
CONF_CAN_ACK = 'can_acknowledge'
CONF_NOTIFIERS = 'notifiers'
CONF_REPEAT = 'repeat'
CONF_SKIP_FIRST = 'skip_first'
DEFAULT_CAN_ACK = True
DEFAULT_SKIP_FIRST = False
ALERT_SCHEMA = vol.Schema({
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_ENTITY_ID): cv.entity_id,
vol.Required(CONF_STATE, default=STATE_ON): cv.string,
vol.Required(CONF_REPEAT): vol.All(cv.ensure_list, [vol.Coerce(float)]),
vol.Required(CONF_CAN_ACK, default=DEFAULT_CAN_ACK): cv.boolean,
vol.Required(CONF_SKIP_FIRST, default=DEFAULT_SKIP_FIRST): cv.boolean,
vol.Required(CONF_NOTIFIERS): cv.ensure_list})
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
cv.slug: ALERT_SCHEMA,
}),
}, extra=vol.ALLOW_EXTRA)
ALERT_SERVICE_SCHEMA = vol.Schema({
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
})
def is_on(hass, entity_id):
"""Return if the alert is firing and not acknowledged."""
return hass.states.is_state(entity_id, STATE_ON)
def turn_on(hass, entity_id):
"""Reset the alert."""
hass.add_job(async_turn_on, hass, entity_id)
@callback
def async_turn_on(hass, entity_id):
"""Async reset the alert."""
data = {ATTR_ENTITY_ID: entity_id}
hass.async_add_job(
hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data))
def turn_off(hass, entity_id):
"""Acknowledge alert."""
hass.add_job(async_turn_off, hass, entity_id)
@callback
def async_turn_off(hass, entity_id):
"""Async acknowledge the alert."""
data = {ATTR_ENTITY_ID: entity_id}
hass.async_add_job(
hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data))
def toggle(hass, entity_id):
"""Toggle acknowledgement of alert."""
hass.add_job(async_toggle, hass, entity_id)
@callback
def async_toggle(hass, entity_id):
"""Async toggle acknowledgement of alert."""
data = {ATTR_ENTITY_ID: entity_id}
hass.async_add_job(
hass.services.async_call(DOMAIN, SERVICE_TOGGLE, data))
@asyncio.coroutine
def async_setup(hass, config):
"""Set up the Alert component."""
alerts = config.get(DOMAIN)
all_alerts = {}
@asyncio.coroutine
def async_handle_alert_service(service_call):
"""Handle calls to alert services."""
alert_ids = service.extract_entity_ids(hass, service_call)
for alert_id in alert_ids:
alert = all_alerts[alert_id]
if service_call.service == SERVICE_TURN_ON:
yield from alert.async_turn_on()
elif service_call.service == SERVICE_TOGGLE:
yield from alert.async_toggle()
else:
yield from alert.async_turn_off()
# Setup alerts
for entity_id, alert in alerts.items():
entity = Alert(hass, entity_id,
alert[CONF_NAME], alert[CONF_ENTITY_ID],
alert[CONF_STATE], alert[CONF_REPEAT],
alert[CONF_SKIP_FIRST], alert[CONF_NOTIFIERS],
alert[CONF_CAN_ACK])
all_alerts[entity.entity_id] = entity
# Read descriptions
descriptions = yield from hass.loop.run_in_executor(
None, load_yaml_config_file, os.path.join(
os.path.dirname(__file__), 'services.yaml'))
descriptions = descriptions.get(DOMAIN, {})
# Setup service calls
hass.services.async_register(
DOMAIN, SERVICE_TURN_OFF, async_handle_alert_service,
descriptions.get(SERVICE_TURN_OFF), schema=ALERT_SERVICE_SCHEMA)
hass.services.async_register(
DOMAIN, SERVICE_TURN_ON, async_handle_alert_service,
descriptions.get(SERVICE_TURN_ON), schema=ALERT_SERVICE_SCHEMA)
hass.services.async_register(
DOMAIN, SERVICE_TOGGLE, async_handle_alert_service,
descriptions.get(SERVICE_TOGGLE), schema=ALERT_SERVICE_SCHEMA)
tasks = [alert.async_update_ha_state() for alert in all_alerts.values()]
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop)
return True
class Alert(ToggleEntity):
"""Representation of an alert."""
def __init__(self, hass, entity_id, name, watched_entity_id, state,
repeat, skip_first, notifiers, can_ack):
"""Initialize the alert."""
self.hass = hass
self._name = name
self._alert_state = state
self._skip_first = skip_first
self._notifiers = notifiers
self._can_ack = can_ack
self._delay = [timedelta(minutes=val) for val in repeat]
self._next_delay = 0
self._firing = False
self._ack = False
self._cancel = None
self.entity_id = ENTITY_ID_FORMAT.format(entity_id)
event.async_track_state_change(
hass, watched_entity_id, self.watched_entity_change)
@property
def name(self):
"""Return the name of the alert."""
return self._name
@property
def should_poll(self):
"""HASS need not poll these entities."""
return False
@property
def state(self):
"""Return the alert status."""
if self._firing:
if self._ack:
return STATE_OFF
return STATE_ON
return STATE_IDLE
@property
def hidden(self):
"""Hide the alert when it is not firing."""
return not self._can_ack or not self._firing
@asyncio.coroutine
def watched_entity_change(self, entity, from_state, to_state):
"""Determine if the alert should start or stop."""
_LOGGER.debug("Watched entity (%s) has changed", entity)
if to_state.state == self._alert_state and not self._firing:
yield from self.begin_alerting()
if to_state.state != self._alert_state and self._firing:
yield from self.end_alerting()
@asyncio.coroutine
def begin_alerting(self):
"""Begin the alert procedures."""
_LOGGER.debug("Beginning Alert: %s", self._name)
self._ack = False
self._firing = True
self._next_delay = 0
if not self._skip_first:
yield from self._notify()
else:
yield from self._schedule_notify()
self.hass.async_add_job(self.async_update_ha_state)
@asyncio.coroutine
def end_alerting(self):
"""End the alert procedures."""
_LOGGER.debug("Ending Alert: %s", self._name)
self._cancel()
self._ack = False
self._firing = False
self.hass.async_add_job(self.async_update_ha_state)
@asyncio.coroutine
def _schedule_notify(self):
"""Schedule a notification."""
delay = self._delay[self._next_delay]
next_msg = datetime.now() + delay
self._cancel = \
event.async_track_point_in_time(self.hass, self._notify, next_msg)
self._next_delay = min(self._next_delay + 1, len(self._delay) - 1)
@asyncio.coroutine
def _notify(self, *args):
"""Send the alert notification."""
if not self._firing:
return
if not self._ack:
_LOGGER.info("Alerting: %s", self._name)
for target in self._notifiers:
yield from self.hass.services.async_call(
'notify', target, {'message': self._name})
yield from self._schedule_notify()
@asyncio.coroutine
def async_turn_on(self):
"""Async Unacknowledge alert."""
_LOGGER.debug("Reset Alert: %s", self._name)
self._ack = False
yield from self.async_update_ha_state()
@asyncio.coroutine
def async_turn_off(self):
"""Async Acknowledge alert."""
_LOGGER.debug("Acknowledged Alert: %s", self._name)
self._ack = True
yield from self.async_update_ha_state()
@asyncio.coroutine
def async_toggle(self):
"""Async toggle alert."""
if self._ack:
return self.async_turn_on()
return self.async_turn_off()

View File

@@ -0,0 +1,295 @@
"""
Support for IP Webcam, an Android app that acts as a full-featured webcam.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/android_ip_webcam/
"""
import asyncio
import logging
from datetime import timedelta
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import (
CONF_NAME, CONF_HOST, CONF_PORT, CONF_USERNAME, CONF_PASSWORD,
CONF_SENSORS, CONF_SWITCHES, CONF_TIMEOUT, CONF_SCAN_INTERVAL,
CONF_PLATFORM)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import (
async_dispatcher_send, async_dispatcher_connect)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.util.dt import utcnow
from homeassistant.components.camera.mjpeg import (
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL)
DOMAIN = 'android_ip_webcam'
REQUIREMENTS = ["pydroid-ipcam==0.6"]
_LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=10)
DATA_IP_WEBCAM = 'android_ip_webcam'
ATTR_HOST = 'host'
ATTR_VID_CONNS = 'Video Connections'
ATTR_AUD_CONNS = 'Audio Connections'
KEY_MAP = {
'audio_connections': 'Audio Connections',
'adet_limit': 'Audio Trigger Limit',
'antibanding': 'Anti-banding',
'audio_only': 'Audio Only',
'battery_level': 'Battery Level',
'battery_temp': 'Battery Temperature',
'battery_voltage': 'Battery Voltage',
'coloreffect': 'Color Effect',
'exposure': 'Exposure Level',
'exposure_lock': 'Exposure Lock',
'ffc': 'Front-facing Camera',
'flashmode': 'Flash Mode',
'focus': 'Focus',
'focus_homing': 'Focus Homing',
'focus_region': 'Focus Region',
'focusmode': 'Focus Mode',
'gps_active': 'GPS Active',
'idle': 'Idle',
'ip_address': 'IPv4 Address',
'ipv6_address': 'IPv6 Address',
'ivideon_streaming': 'Ivideon Streaming',
'light': 'Light Level',
'mirror_flip': 'Mirror Flip',
'motion': 'Motion',
'motion_active': 'Motion Active',
'motion_detect': 'Motion Detection',
'motion_event': 'Motion Event',
'motion_limit': 'Motion Limit',
'night_vision': 'Night Vision',
'night_vision_average': 'Night Vision Average',
'night_vision_gain': 'Night Vision Gain',
'orientation': 'Orientation',
'overlay': 'Overlay',
'photo_size': 'Photo Size',
'pressure': 'Pressure',
'proximity': 'Proximity',
'quality': 'Quality',
'scenemode': 'Scene Mode',
'sound': 'Sound',
'sound_event': 'Sound Event',
'sound_timeout': 'Sound Timeout',
'torch': 'Torch',
'video_connections': 'Video Connections',
'video_chunk_len': 'Video Chunk Length',
'video_recording': 'Video Recording',
'video_size': 'Video Size',
'whitebalance': 'White Balance',
'whitebalance_lock': 'White Balance Lock',
'zoom': 'Zoom'
}
ICON_MAP = {
'audio_connections': 'mdi:speaker',
'battery_level': 'mdi:battery',
'battery_temp': 'mdi:thermometer',
'battery_voltage': 'mdi:battery-charging-100',
'exposure_lock': 'mdi:camera',
'ffc': 'mdi:camera-front-variant',
'focus': 'mdi:image-filter-center-focus',
'gps_active': 'mdi:crosshairs-gps',
'light': 'mdi:flashlight',
'motion': 'mdi:run',
'night_vision': 'mdi:weather-night',
'overlay': 'mdi:monitor',
'pressure': 'mdi:gauge',
'proximity': 'mdi:map-marker-radius',
'quality': 'mdi:quality-high',
'sound': 'mdi:speaker',
'sound_event': 'mdi:speaker',
'sound_timeout': 'mdi:speaker',
'torch': 'mdi:white-balance-sunny',
'video_chunk_len': 'mdi:video',
'video_connections': 'mdi:eye',
'video_recording': 'mdi:record-rec',
'whitebalance_lock': 'mdi:white-balance-auto'
}
SWITCHES = ['exposure_lock', 'ffc', 'focus', 'gps_active', 'night_vision',
'overlay', 'torch', 'whitebalance_lock', 'video_recording']
SENSORS = ['audio_connections', 'battery_level', 'battery_temp',
'battery_voltage', 'light', 'motion', 'pressure', 'proximity',
'sound', 'video_connections']
SIGNAL_UPDATE_DATA = 'android_ip_webcam_update'
CONF_MOTION_SENSOR = 'motion_sensor'
DEFAULT_NAME = 'IP Webcam'
DEFAULT_PORT = 8080
DEFAULT_TIMEOUT = 10
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.All(cv.ensure_list, [vol.Schema({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL):
cv.time_period,
vol.Inclusive(CONF_USERNAME, 'authentication'): cv.string,
vol.Inclusive(CONF_PASSWORD, 'authentication'): cv.string,
vol.Optional(CONF_SWITCHES, default=None):
vol.All(cv.ensure_list, [vol.In(SWITCHES)]),
vol.Optional(CONF_SENSORS, default=None):
vol.All(cv.ensure_list, [vol.In(SENSORS)]),
vol.Optional(CONF_MOTION_SENSOR, default=None): cv.boolean,
})])
}, extra=vol.ALLOW_EXTRA)
@asyncio.coroutine
def async_setup(hass, config):
"""Setup the IP Webcam component."""
from pydroid_ipcam import PyDroidIPCam
webcams = hass.data[DATA_IP_WEBCAM] = {}
websession = async_get_clientsession(hass)
@asyncio.coroutine
def async_setup_ipcamera(cam_config):
"""Setup a ip camera."""
host = cam_config[CONF_HOST]
username = cam_config.get(CONF_USERNAME)
password = cam_config.get(CONF_PASSWORD)
name = cam_config[CONF_NAME]
interval = cam_config[CONF_SCAN_INTERVAL]
switches = cam_config[CONF_SWITCHES]
sensors = cam_config[CONF_SENSORS]
motion = cam_config[CONF_MOTION_SENSOR]
# init ip webcam
cam = PyDroidIPCam(
hass.loop, websession, host, cam_config[CONF_PORT],
username=username, password=password,
timeout=cam_config[CONF_TIMEOUT]
)
if switches is None:
switches = [setting for setting in cam.enabled_settings
if setting in SWITCHES]
if sensors is None:
sensors = [sensor for sensor in cam.enabled_sensors
if sensor in SENSORS]
sensors.extend(['audio_connections', 'video_connections'])
if motion is None:
motion = 'motion_active' in cam.enabled_sensors
@asyncio.coroutine
def async_update_data(now):
"""Update data from ipcam in SCAN_INTERVAL."""
yield from cam.update()
async_dispatcher_send(hass, SIGNAL_UPDATE_DATA, host)
async_track_point_in_utc_time(
hass, async_update_data, utcnow() + interval)
yield from async_update_data(None)
# load platforms
webcams[host] = cam
mjpeg_camera = {
CONF_PLATFORM: 'mjpeg',
CONF_MJPEG_URL: cam.mjpeg_url,
CONF_STILL_IMAGE_URL: cam.image_url,
CONF_NAME: name,
}
if username and password:
mjpeg_camera.update({
CONF_USERNAME: username,
CONF_PASSWORD: password
})
hass.async_add_job(discovery.async_load_platform(
hass, 'camera', 'mjpeg', mjpeg_camera, config))
if sensors:
hass.async_add_job(discovery.async_load_platform(
hass, 'sensor', DOMAIN, {
CONF_NAME: name,
CONF_HOST: host,
CONF_SENSORS: sensors,
}, config))
if switches:
hass.async_add_job(discovery.async_load_platform(
hass, 'switch', DOMAIN, {
CONF_NAME: name,
CONF_HOST: host,
CONF_SWITCHES: switches,
}, config))
if motion:
hass.async_add_job(discovery.async_load_platform(
hass, 'binary_sensor', DOMAIN, {
CONF_HOST: host,
CONF_NAME: name,
}, config))
tasks = [async_setup_ipcamera(conf) for conf in config[DOMAIN]]
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop)
return True
class AndroidIPCamEntity(Entity):
"""The Android device running IP Webcam."""
def __init__(self, host, ipcam):
"""Initialize the data oject."""
self._host = host
self._ipcam = ipcam
@asyncio.coroutine
def async_added_to_hass(self):
"""Register update dispatcher."""
@callback
def async_ipcam_update(host):
"""Update callback."""
if self._host != host:
return
self.hass.async_add_job(self.async_update_ha_state(True))
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_DATA, async_ipcam_update)
@property
def should_poll(self):
"""Return True if entity has to be polled for state."""
return False
@property
def available(self):
"""Return True if entity is available."""
return self._ipcam.available
@property
def device_state_attributes(self):
"""Return the state attributes."""
state_attr = {ATTR_HOST: self._host}
if self._ipcam.status_data is None:
return state_attr
state_attr[ATTR_VID_CONNS] = \
self._ipcam.status_data.get('video_connections')
state_attr[ATTR_AUD_CONNS] = \
self._ipcam.status_data.get('audio_connections')
return state_attr

View File

@@ -327,6 +327,8 @@ class APIEventForwardingView(HomeAssistantView):
@asyncio.coroutine
def post(self, request):
"""Setup an event forwarder."""
_LOGGER.warning('Event forwarding is deprecated. '
'Will be removed by 0.43')
hass = request.app['hass']
try:
data = yield from request.json()

View File

@@ -0,0 +1,172 @@
"""
Support for API.AI webhook.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/apiai/
"""
import asyncio
import copy
import logging
import voluptuous as vol
from homeassistant.const import PROJECT_NAME, HTTP_BAD_REQUEST
from homeassistant.helpers import template, script, config_validation as cv
from homeassistant.components.http import HomeAssistantView
_LOGGER = logging.getLogger(__name__)
INTENTS_API_ENDPOINT = '/api/apiai'
CONF_INTENTS = 'intents'
CONF_SPEECH = 'speech'
CONF_ACTION = 'action'
CONF_ASYNC_ACTION = 'async_action'
DEFAULT_CONF_ASYNC_ACTION = False
DOMAIN = 'apiai'
DEPENDENCIES = ['http']
CONFIG_SCHEMA = vol.Schema({
DOMAIN: {
CONF_INTENTS: {
cv.string: {
vol.Optional(CONF_SPEECH): cv.template,
vol.Optional(CONF_ACTION): cv.SCRIPT_SCHEMA,
vol.Optional(CONF_ASYNC_ACTION,
default=DEFAULT_CONF_ASYNC_ACTION): cv.boolean
}
}
}
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
"""Activate API.AI component."""
intents = config[DOMAIN].get(CONF_INTENTS, {})
hass.http.register_view(ApiaiIntentsView(hass, intents))
return True
class ApiaiIntentsView(HomeAssistantView):
"""Handle API.AI requests."""
url = INTENTS_API_ENDPOINT
name = 'api:apiai'
def __init__(self, hass, intents):
"""Initialize API.AI view."""
super().__init__()
self.hass = hass
intents = copy.deepcopy(intents)
template.attach(hass, intents)
for name, intent in intents.items():
if CONF_ACTION in intent:
intent[CONF_ACTION] = script.Script(
hass, intent[CONF_ACTION], "Apiai intent {}".format(name))
self.intents = intents
@asyncio.coroutine
def post(self, request):
"""Handle API.AI."""
data = yield from request.json()
_LOGGER.debug("Received api.ai request: %s", data)
req = data.get('result')
if req is None:
_LOGGER.error("Received invalid data from api.ai: %s", data)
return self.json_message(
"Expected result value not received", HTTP_BAD_REQUEST)
action_incomplete = req['actionIncomplete']
if action_incomplete:
return None
# use intent to no mix HASS actions with this parameter
intent = req.get('action')
parameters = req.get('parameters')
# contexts = req.get('contexts')
response = ApiaiResponse(parameters)
# Default Welcome Intent
# Maybe is better to handle this in api.ai directly?
#
# if intent == 'input.welcome':
# response.add_speech(
# "Hello, and welcome to the future. How may I help?")
# return self.json(response)
if intent == "":
_LOGGER.warning("Received intent with empty action")
response.add_speech(
"You have not defined an action in your api.ai intent.")
return self.json(response)
config = self.intents.get(intent)
if config is None:
_LOGGER.warning("Received unknown intent %s", intent)
response.add_speech(
"Intent '%s' is not yet configured within Home Assistant." %
intent)
return self.json(response)
speech = config.get(CONF_SPEECH)
action = config.get(CONF_ACTION)
async_action = config.get(CONF_ASYNC_ACTION)
if action is not None:
# API.AI expects a response in less than 5s
if async_action:
# Do not wait for the action to be executed.
# Needed if the action will take longer than 5s to execute
self.hass.async_add_job(action.async_run(response.parameters))
else:
# Wait for the action to be executed so we can use results to
# render the answer
yield from action.async_run(response.parameters)
# pylint: disable=unsubscriptable-object
if speech is not None:
response.add_speech(speech)
return self.json(response)
class ApiaiResponse(object):
"""Help generating the response for API.AI."""
def __init__(self, parameters):
"""Initialize the response."""
self.speech = None
self.parameters = {}
# Parameter names replace '.' and '-' for '_'
for key, value in parameters.items():
underscored_key = key.replace('.', '_').replace('-', '_')
self.parameters[underscored_key] = value
def add_speech(self, text):
"""Add speech to the response."""
assert self.speech is None
if isinstance(text, template.Template):
text = text.async_render(self.parameters)
self.speech = text
def as_dict(self):
"""Return response in an API.AI valid dict."""
return {
'speech': self.speech,
'displayText': self.speech,
'source': PROJECT_NAME,
}

View File

@@ -11,16 +11,17 @@ import os
import voluptuous as vol
from homeassistant.bootstrap import async_prepare_setup_platform
from homeassistant.setup import async_prepare_setup_platform
from homeassistant import config as conf_util
from homeassistant.const import (
ATTR_ENTITY_ID, CONF_PLATFORM, STATE_ON, SERVICE_TURN_ON, SERVICE_TURN_OFF,
SERVICE_TOGGLE)
SERVICE_TOGGLE, SERVICE_RELOAD)
from homeassistant.components import logbook
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import extract_domain_configs, script, condition
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import async_get_last_state
from homeassistant.loader import get_platform
from homeassistant.util.dt import utcnow
import homeassistant.helpers.config_validation as cv
@@ -28,8 +29,6 @@ import homeassistant.helpers.config_validation as cv
DOMAIN = 'automation'
ENTITY_ID_FORMAT = DOMAIN + '.{}'
DEPENDENCIES = ['group']
GROUP_NAME_ALL_AUTOMATIONS = 'all automations'
CONF_ALIAS = 'alias'
@@ -52,7 +51,6 @@ DEFAULT_INITIAL_STATE = True
ATTR_LAST_TRIGGERED = 'last_triggered'
ATTR_VARIABLES = 'variables'
SERVICE_TRIGGER = 'trigger'
SERVICE_RELOAD = 'reload'
_LOGGER = logging.getLogger(__name__)
@@ -226,7 +224,7 @@ class AutomationEntity(ToggleEntity):
"""Entity to show status of entity."""
def __init__(self, name, async_attach_triggers, cond_func, async_action,
hidden):
hidden, initial_state):
"""Initialize an automation entity."""
self._name = name
self._async_attach_triggers = async_attach_triggers
@@ -236,6 +234,7 @@ class AutomationEntity(ToggleEntity):
self._enabled = False
self._last_triggered = None
self._hidden = hidden
self._initial_state = initial_state
@property
def name(self):
@@ -264,6 +263,18 @@ class AutomationEntity(ToggleEntity):
"""Return True if entity is on."""
return self._enabled
@asyncio.coroutine
def async_added_to_hass(self) -> None:
"""Startup with initial state or previous state."""
state = yield from async_get_last_state(self.hass, self.entity_id)
if state is None:
if self._initial_state:
yield from self.async_enable()
else:
self._last_triggered = state.attributes.get('last_triggered')
if state.state == STATE_ON:
yield from self.async_enable()
@asyncio.coroutine
def async_turn_on(self, **kwargs) -> None:
"""Turn the entity on and update the state."""
@@ -322,7 +333,6 @@ def _async_process_config(hass, config, component):
This method is a coroutine.
"""
entities = []
tasks = []
for config_key in extract_domain_configs(config, DOMAIN):
conf = config[config_key]
@@ -332,6 +342,7 @@ def _async_process_config(hass, config, component):
list_no)
hidden = config_block[CONF_HIDE_ENTITY]
initial_state = config_block[CONF_INITIAL_STATE]
action = _async_get_action(hass, config_block.get(CONF_ACTION, {}),
name)
@@ -348,15 +359,14 @@ def _async_process_config(hass, config, component):
async_attach_triggers = partial(
_async_process_trigger, hass, config,
config_block.get(CONF_TRIGGER, []), name)
entity = AutomationEntity(name, async_attach_triggers, cond_func,
action, hidden)
if config_block[CONF_INITIAL_STATE]:
tasks.append(entity.async_enable())
config_block.get(CONF_TRIGGER, []), name
)
entity = AutomationEntity(
name, async_attach_triggers, cond_func, action, hidden,
initial_state)
entities.append(entity)
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop)
if entities:
yield from component.async_add_entities(entities)
@@ -412,7 +422,7 @@ def _async_process_trigger(hass, config, trigger_configs, name, action):
if platform is None:
return None
remove = platform.async_trigger(hass, conf, action)
remove = yield from platform.async_trigger(hass, conf, action)
if not remove:
_LOGGER.error("Error setting up trigger %s", name)

View File

@@ -4,6 +4,7 @@ Offer event listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#event-trigger
"""
import asyncio
import logging
import voluptuous as vol
@@ -24,6 +25,7 @@ TRIGGER_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for events based on configuration."""
event_type = config.get(CONF_EVENT_TYPE)

View File

@@ -4,6 +4,7 @@ Trigger an automation when a LiteJet switch is released.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/automation.litejet/
"""
import asyncio
import logging
import voluptuous as vol
@@ -32,6 +33,7 @@ TRIGGER_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for events based on configuration."""
number = config.get(CONF_NUMBER)

View File

@@ -4,6 +4,7 @@ Offer MQTT listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#mqtt-trigger
"""
import asyncio
import json
import voluptuous as vol
@@ -24,6 +25,7 @@ TRIGGER_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
topic = config.get(CONF_TOPIC)
@@ -49,4 +51,6 @@ def async_trigger(hass, config, action):
'trigger': data
})
return mqtt.async_subscribe(hass, topic, mqtt_automation_listener)
remove = yield from mqtt.async_subscribe(
hass, topic, mqtt_automation_listener)
return remove

View File

@@ -4,6 +4,7 @@ Offer numeric state listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#numeric-state-trigger
"""
import asyncio
import logging
import voluptuous as vol
@@ -26,6 +27,7 @@ TRIGGER_SCHEMA = vol.All(vol.Schema({
_LOGGER = logging.getLogger(__name__)
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)

View File

@@ -4,6 +4,7 @@ Offer state listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#state-trigger
"""
import asyncio
import voluptuous as vol
from homeassistant.core import callback
@@ -34,6 +35,7 @@ TRIGGER_SCHEMA = vol.All(
)
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)
@@ -43,6 +45,19 @@ def async_trigger(hass, config, action):
async_remove_state_for_cancel = None
async_remove_state_for_listener = None
@callback
def clear_listener():
"""Clear all unsub listener."""
nonlocal async_remove_state_for_cancel, async_remove_state_for_listener
# pylint: disable=not-callable
if async_remove_state_for_listener is not None:
async_remove_state_for_listener()
async_remove_state_for_listener = None
if async_remove_state_for_cancel is not None:
async_remove_state_for_cancel()
async_remove_state_for_cancel = None
@callback
def state_automation_listener(entity, from_s, to_s):
"""Listen for state changes and calls action."""
@@ -64,18 +79,11 @@ def async_trigger(hass, config, action):
call_action()
return
@callback
def clear_listener():
"""Clear all unsub listener."""
nonlocal async_remove_state_for_cancel
nonlocal async_remove_state_for_listener
async_remove_state_for_listener = None
async_remove_state_for_cancel = None
@callback
def state_for_listener(now):
"""Fire on state changes after a delay and calls action."""
async_remove_state_for_cancel()
nonlocal async_remove_state_for_listener
async_remove_state_for_listener = None
clear_listener()
call_action()
@@ -84,10 +92,11 @@ def async_trigger(hass, config, action):
"""Fire on changes and cancel for listener if changed."""
if inner_to_s.state == to_s.state:
return
async_remove_state_for_listener()
async_remove_state_for_cancel()
clear_listener()
# cleanup previous listener
clear_listener()
async_remove_state_for_listener = async_track_point_in_utc_time(
hass, state_for_listener, dt_util.utcnow() + time_delta)
@@ -97,14 +106,10 @@ def async_trigger(hass, config, action):
unsub = async_track_state_change(
hass, entity_id, state_automation_listener, from_state, to_state)
@callback
def async_remove():
"""Remove state listeners async."""
unsub()
# pylint: disable=not-callable
if async_remove_state_for_cancel is not None:
async_remove_state_for_cancel()
if async_remove_state_for_listener is not None:
async_remove_state_for_listener()
clear_listener()
return async_remove

View File

@@ -4,6 +4,7 @@ Offer sun based automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#sun-trigger
"""
import asyncio
from datetime import timedelta
import logging
@@ -26,6 +27,7 @@ TRIGGER_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for events based on configuration."""
event = config.get(CONF_EVENT)

View File

@@ -4,14 +4,14 @@ Offer template automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#template-trigger
"""
import asyncio
import logging
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_VALUE_TEMPLATE, CONF_PLATFORM
from homeassistant.helpers import condition
from homeassistant.helpers.event import async_track_state_change
from homeassistant.helpers.event import async_track_template
import homeassistant.helpers.config_validation as cv
@@ -23,33 +23,22 @@ TRIGGER_SCHEMA = IF_ACTION_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
value_template = config.get(CONF_VALUE_TEMPLATE)
value_template.hass = hass
# Local variable to keep track of if the action has already been triggered
already_triggered = False
@callback
def state_changed_listener(entity_id, from_s, to_s):
def template_listener(entity_id, from_s, to_s):
"""Listen for state changes and calls action."""
nonlocal already_triggered
template_result = condition.async_template(hass, value_template)
hass.async_run_job(action, {
'trigger': {
'platform': 'template',
'entity_id': entity_id,
'from_state': from_s,
'to_state': to_s,
},
})
# Check to see if template returns true
if template_result and not already_triggered:
already_triggered = True
hass.async_run_job(action, {
'trigger': {
'platform': 'template',
'entity_id': entity_id,
'from_state': from_s,
'to_state': to_s,
},
})
elif not template_result:
already_triggered = False
return async_track_state_change(hass, value_template.extract_entities(),
state_changed_listener)
return async_track_template(hass, value_template, template_listener)

View File

@@ -4,6 +4,7 @@ Offer time listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#time-trigger
"""
import asyncio
import logging
import voluptuous as vol
@@ -29,6 +30,7 @@ TRIGGER_SCHEMA = vol.All(vol.Schema({
CONF_SECONDS, CONF_AFTER))
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
if CONF_AFTER in config:

View File

@@ -4,6 +4,7 @@ Offer zone automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#zone-trigger
"""
import asyncio
import voluptuous as vol
from homeassistant.core import callback
@@ -26,6 +27,7 @@ TRIGGER_SCHEMA = vol.Schema({
})
@asyncio.coroutine
def async_trigger(hass, config, action):
"""Listen for state changes based on configuration."""
entity_id = config.get(CONF_ENTITY_ID)

View File

@@ -14,13 +14,13 @@ from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.const import (STATE_ON, STATE_OFF)
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
from homeassistant.helpers.deprecation import deprecated_substitute
DOMAIN = 'binary_sensor'
SCAN_INTERVAL = timedelta(seconds=30)
ENTITY_ID_FORMAT = DOMAIN + '.{}'
SENSOR_CLASSES = [
None, # Generic on/off
DEVICE_CLASSES = [
'cold', # On means cold (or too cold)
'connectivity', # On means connection present, Off = no connection
'gas', # CO, CO2, etc.
@@ -38,7 +38,7 @@ SENSOR_CLASSES = [
'vibration', # On means vibration detected, Off means no vibration
]
SENSOR_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(SENSOR_CLASSES))
DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(DEVICE_CLASSES))
@asyncio.coroutine
@@ -66,16 +66,7 @@ class BinarySensorDevice(Entity):
return STATE_ON if self.is_on else STATE_OFF
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
@deprecated_substitute('sensor_class')
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return None
@property
def state_attributes(self):
"""Return device specific state attributes."""
attr = {}
if self.sensor_class is not None:
attr['sensor_class'] = self.sensor_class
return attr

View File

@@ -0,0 +1,62 @@
"""
Support for IP Webcam binary sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.android_ip_webcam/
"""
import asyncio
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.android_ip_webcam import (
KEY_MAP, DATA_IP_WEBCAM, AndroidIPCamEntity, CONF_HOST, CONF_NAME)
DEPENDENCIES = ['android_ip_webcam']
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup IP Webcam binary sensors."""
if discovery_info is None:
return
host = discovery_info[CONF_HOST]
name = discovery_info[CONF_NAME]
ipcam = hass.data[DATA_IP_WEBCAM][host]
async_add_devices(
[IPWebcamBinarySensor(name, host, ipcam, 'motion_active')], True)
class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorDevice):
"""Represents an IP Webcam binary sensor."""
def __init__(self, name, host, ipcam, sensor):
"""Initialize the binary sensor."""
super().__init__(host, ipcam)
self._sensor = sensor
self._mapped_name = KEY_MAP.get(self._sensor, self._sensor)
self._name = '{} {}'.format(name, self._mapped_name)
self._state = None
self._unit = None
@property
def name(self):
"""Return the name of the binary sensor, if any."""
return self._name
@property
def is_on(self):
"""True if the binary sensor is on."""
return self._state
@asyncio.coroutine
def async_update(self):
"""Retrieve latest state."""
state, _ = self._ipcam.export_sensor(self._sensor)
self._state = state == 1.0
@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return 'motion'

View File

@@ -11,11 +11,12 @@ import requests
import voluptuous as vol
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES_SCHEMA)
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
from homeassistant.const import (
CONF_RESOURCE, CONF_PIN, CONF_NAME, CONF_SENSOR_CLASS)
CONF_RESOURCE, CONF_PIN, CONF_NAME, CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
_LOGGER = logging.getLogger(__name__)
@@ -25,7 +26,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_RESOURCE): cv.url,
vol.Optional(CONF_NAME): cv.string,
vol.Required(CONF_PIN): cv.string,
vol.Optional(CONF_SENSOR_CLASS): SENSOR_CLASSES_SCHEMA,
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
@@ -33,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the aREST binary sensor."""
resource = config.get(CONF_RESOURCE)
pin = config.get(CONF_PIN)
sensor_class = config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
try:
response = requests.get(resource, timeout=10).json()
@@ -49,18 +51,18 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices([ArestBinarySensor(
arest, resource, config.get(CONF_NAME, response[CONF_NAME]),
sensor_class, pin)])
device_class, pin)])
class ArestBinarySensor(BinarySensorDevice):
"""Implement an aREST binary sensor for a pin."""
def __init__(self, arest, resource, name, sensor_class, pin):
def __init__(self, arest, resource, name, device_class, pin):
"""Initialize the aREST device."""
self.arest = arest
self._resource = resource
self._name = name
self._sensor_class = sensor_class
self._device_class = device_class
self._pin = pin
self.update()
@@ -81,9 +83,9 @@ class ArestBinarySensor(BinarySensorDevice):
return bool(self.arest.data.get('state'))
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_class
return self._device_class
def update(self):
"""Get the latest data from aREST API."""

View File

@@ -0,0 +1,148 @@
"""
Support for aurora forecast data sensor.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.aurora/
"""
from datetime import timedelta
import logging
import requests
import voluptuous as vol
from homeassistant.components.binary_sensor \
import (BinarySensorDevice, PLATFORM_SCHEMA)
from homeassistant.const import (CONF_NAME)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
CONF_THRESHOLD = "forecast_threshold"
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'Aurora Visibility'
DEFAULT_DEVICE_CLASS = "visible"
DEFAULT_THRESHOLD = 75
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_THRESHOLD, default=DEFAULT_THRESHOLD): cv.positive_int,
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the aurora sensor."""
if None in (hass.config.latitude, hass.config.longitude):
_LOGGER.error("Lat. or long. not set in Home Assistant config")
return False
name = config.get(CONF_NAME)
threshold = config.get(CONF_THRESHOLD)
try:
aurora_data = AuroraData(
hass.config.latitude,
hass.config.longitude,
threshold
)
aurora_data.update()
except requests.exceptions.HTTPError as error:
_LOGGER.error(
"Connection to aurora forecast service failed: %s", error)
return False
add_devices([AuroraSensor(aurora_data, name)], True)
class AuroraSensor(BinarySensorDevice):
"""Implementation of an aurora sensor."""
def __init__(self, aurora_data, name):
"""Initialize the sensor."""
self.aurora_data = aurora_data
self._name = name
@property
def name(self):
"""Return the name of the sensor."""
return '{}'.format(self._name)
@property
def is_on(self):
"""Return true if aurora is visible."""
return self.aurora_data.is_visible if self.aurora_data else False
@property
def device_class(self):
"""Return the class of this device."""
return DEFAULT_DEVICE_CLASS
@property
def device_state_attributes(self):
"""Return the state attributes."""
attrs = {}
if self.aurora_data:
attrs["visibility_level"] = self.aurora_data.visibility_level
attrs["message"] = self.aurora_data.is_visible_text
return attrs
def update(self):
"""Get the latest data from Aurora API and updates the states."""
self.aurora_data.update()
class AuroraData(object):
"""Get aurora forecast."""
def __init__(self, latitude, longitude, threshold):
"""Initialize the data object."""
self.latitude = latitude
self.longitude = longitude
self.number_of_latitude_intervals = 513
self.number_of_longitude_intervals = 1024
self.api_url = \
"http://services.swpc.noaa.gov/text/aurora-nowcast-map.txt"
self.headers = {"User-Agent": "Home Assistant Aurora Tracker v.0.1.0"}
self.threshold = int(threshold)
self.is_visible = None
self.is_visible_text = None
self.visibility_level = None
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
"""Get the latest data from the Aurora service."""
try:
self.visibility_level = self.get_aurora_forecast()
if int(self.visibility_level) > self.threshold:
self.is_visible = True
self.is_visible_text = "visible!"
else:
self.is_visible = False
self.is_visible_text = "nothing's out"
except requests.exceptions.HTTPError as error:
_LOGGER.error(
"Connection to aurora forecast service failed: %s", error)
return False
def get_aurora_forecast(self):
"""Get forecast data and parse for given long/lat."""
raw_data = requests.get(self.api_url, headers=self.headers).text
forecast_table = [
row.strip(" ").split(" ")
for row in raw_data.split("\n")
if not row.startswith("#")
]
# convert lat and long for data points in table
converted_latitude = round((self.latitude / 180)
* self.number_of_latitude_intervals)
converted_longitude = round((self.longitude / 360)
* self.number_of_longitude_intervals)
return forecast_table[converted_latitude][converted_longitude]

View File

@@ -0,0 +1,74 @@
"""
Support for Blink system camera control.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.blink/
"""
from homeassistant.components.blink import DOMAIN
from homeassistant.components.binary_sensor import BinarySensorDevice
DEPENDENCIES = ['blink']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the blink binary sensors."""
if discovery_info is None:
return
data = hass.data[DOMAIN].blink
devs = list()
for name in data.cameras:
devs.append(BlinkCameraMotionSensor(name, data))
devs.append(BlinkSystemSensor(data))
add_devices(devs, True)
class BlinkCameraMotionSensor(BinarySensorDevice):
"""A representation of a Blink binary sensor."""
def __init__(self, name, data):
"""Initialize the sensor."""
self._name = 'blink_' + name + '_motion_enabled'
self._camera_name = name
self.data = data
self._state = self.data.cameras[self._camera_name].armed
@property
def name(self):
"""Return the name of the blink sensor."""
return self._name
@property
def is_on(self):
"""Return the status of the sensor."""
return self._state
def update(self):
"""Update sensor state."""
self.data.refresh()
self._state = self.data.cameras[self._camera_name].armed
class BlinkSystemSensor(BinarySensorDevice):
"""A representation of a Blink system sensor."""
def __init__(self, data):
"""Initialize the sensor."""
self._name = 'blink armed status'
self.data = data
self._state = self.data.arm
@property
def name(self):
"""Return the name of the blink sensor."""
return self._name.replace(" ", "_")
@property
def is_on(self):
"""Return the status of the sensor."""
return self._state
def update(self):
"""Update sensor state."""
self.data.refresh()
self._state = self.data.arm

View File

@@ -64,8 +64,8 @@ class BloomSkySensor(BinarySensorDevice):
return self._unique_id
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return SENSOR_TYPES.get(self._sensor_name)
@property

View File

@@ -10,12 +10,13 @@ import logging
import voluptuous as vol
from homeassistant.components.binary_sensor import (
BinarySensorDevice, SENSOR_CLASSES_SCHEMA, PLATFORM_SCHEMA)
BinarySensorDevice, DEVICE_CLASSES_SCHEMA, PLATFORM_SCHEMA)
from homeassistant.components.sensor.command_line import CommandSensorData
from homeassistant.const import (
CONF_PAYLOAD_OFF, CONF_PAYLOAD_ON, CONF_NAME, CONF_VALUE_TEMPLATE,
CONF_SENSOR_CLASS, CONF_COMMAND)
CONF_SENSOR_CLASS, CONF_COMMAND, CONF_DEVICE_CLASS)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
_LOGGER = logging.getLogger(__name__)
@@ -30,7 +31,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
vol.Optional(CONF_SENSOR_CLASS): SENSOR_CLASSES_SCHEMA,
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
})
@@ -42,27 +44,27 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
command = config.get(CONF_COMMAND)
payload_off = config.get(CONF_PAYLOAD_OFF)
payload_on = config.get(CONF_PAYLOAD_ON)
sensor_class = config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = hass
data = CommandSensorData(command)
add_devices([CommandBinarySensor(
hass, data, name, sensor_class, payload_on, payload_off,
hass, data, name, device_class, payload_on, payload_off,
value_template)])
class CommandBinarySensor(BinarySensorDevice):
"""Represent a command line binary sensor."""
def __init__(self, hass, data, name, sensor_class, payload_on,
def __init__(self, hass, data, name, device_class, payload_on,
payload_off, value_template):
"""Initialize the Command line binary sensor."""
self._hass = hass
self.data = data
self._name = name
self._sensor_class = sensor_class
self._device_class = device_class
self._state = False
self._payload_on = payload_on
self._payload_off = payload_off
@@ -80,9 +82,9 @@ class CommandBinarySensor(BinarySensorDevice):
return self._state
@ property
def sensor_class(self):
def device_class(self):
"""Return the class of the binary sensor."""
return self._sensor_class
return self._device_class
def update(self):
"""Get the latest data and updates the state."""

View File

@@ -11,7 +11,7 @@ import requests
import voluptuous as vol
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES)
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES)
from homeassistant.const import (CONF_HOST, CONF_PORT)
import homeassistant.helpers.config_validation as cv
@@ -30,7 +30,7 @@ DEFAULT_SSL = False
SCAN_INTERVAL = datetime.timedelta(seconds=1)
ZONE_TYPES_SCHEMA = vol.Schema({
cv.positive_int: vol.In(SENSOR_CLASSES),
cv.positive_int: vol.In(DEVICE_CLASSES),
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@@ -102,8 +102,8 @@ class Concord232ZoneSensor(BinarySensorDevice):
self.update()
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return self._zone_type
@property

View File

@@ -18,14 +18,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoBinarySensor(BinarySensorDevice):
"""A Demo binary sensor."""
def __init__(self, name, state, sensor_class):
def __init__(self, name, state, device_class):
"""Initialize the demo sensor."""
self._name = name
self._state = state
self._sensor_type = sensor_class
self._sensor_type = device_class
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_type

View File

@@ -36,6 +36,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev = []
for droplet in droplets:
droplet_id = digital_ocean.DIGITAL_OCEAN.get_droplet_id(droplet)
if droplet_id is None:
_LOGGER.error("Droplet %s is not available", droplet)
return False
dev.append(DigitalOceanBinarySensor(
digital_ocean.DIGITAL_OCEAN, droplet_id))
@@ -63,7 +66,7 @@ class DigitalOceanBinarySensor(BinarySensorDevice):
return self.data.status == 'active'
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return DEFAULT_SENSOR_CLASS

View File

@@ -38,7 +38,7 @@ class EcobeeBinarySensor(BinarySensorDevice):
self.sensor_name = sensor_name
self.index = sensor_index
self._state = None
self._sensor_class = 'occupancy'
self._device_class = 'occupancy'
self.update()
@property
@@ -57,9 +57,9 @@ class EcobeeBinarySensor(BinarySensorDevice):
return "binary_sensor_ecobee_{}_{}".format(self._name, self.index)
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
return self._sensor_class
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return self._device_class
def update(self):
"""Get the latest state of the sensor."""

View File

@@ -9,10 +9,12 @@ import logging
import voluptuous as vol
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES_SCHEMA)
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
from homeassistant.components import enocean
from homeassistant.const import (CONF_NAME, CONF_ID, CONF_SENSOR_CLASS)
from homeassistant.const import (
CONF_NAME, CONF_ID, CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
_LOGGER = logging.getLogger(__name__)
@@ -22,7 +24,8 @@ DEFAULT_NAME = 'EnOcean binary sensor'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA,
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
@@ -30,15 +33,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Binary Sensor platform fo EnOcean."""
dev_id = config.get(CONF_ID)
devname = config.get(CONF_NAME)
sensor_class = config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
add_devices([EnOceanBinarySensor(dev_id, devname, sensor_class)])
add_devices([EnOceanBinarySensor(dev_id, devname, device_class)])
class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
"""Representation of EnOcean binary sensors such as wall switches."""
def __init__(self, dev_id, devname, sensor_class):
def __init__(self, dev_id, devname, device_class):
"""Initialize the EnOcean binary sensor."""
enocean.EnOceanDevice.__init__(self)
self.stype = "listener"
@@ -46,7 +49,7 @@ class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
self.which = -1
self.onoff = -1
self.devname = devname
self._sensor_class = sensor_class
self._device_class = device_class
@property
def name(self):
@@ -54,9 +57,9 @@ class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
return self.devname
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_class
return self._device_class
def value_changed(self, value, value2):
"""Fire an event with the data that have changed.
@@ -64,7 +67,7 @@ class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
This method is called when there is an incoming packet associated
with this platform.
"""
self.update_ha_state()
self.schedule_update_ha_state()
if value2 == 0x70:
self.which = 0
self.onoff = 0

View File

@@ -4,48 +4,59 @@ Support for Envisalink zone states- represented as binary sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.envisalink/
"""
import asyncio
import logging
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.envisalink import (EVL_CONTROLLER,
ZONE_SCHEMA,
CONF_ZONENAME,
CONF_ZONETYPE,
EnvisalinkDevice,
SIGNAL_ZONE_UPDATE)
from homeassistant.components.envisalink import (
DATA_EVL, ZONE_SCHEMA, CONF_ZONENAME, CONF_ZONETYPE, EnvisalinkDevice,
SIGNAL_ZONE_UPDATE)
from homeassistant.const import ATTR_LAST_TRIP_TIME
DEPENDENCIES = ['envisalink']
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup Envisalink binary sensor devices."""
_configured_zones = discovery_info['zones']
for zone_num in _configured_zones:
_device_config_data = ZONE_SCHEMA(_configured_zones[zone_num])
_device = EnvisalinkBinarySensor(
configured_zones = discovery_info['zones']
devices = []
for zone_num in configured_zones:
device_config_data = ZONE_SCHEMA(configured_zones[zone_num])
device = EnvisalinkBinarySensor(
hass,
zone_num,
_device_config_data[CONF_ZONENAME],
_device_config_data[CONF_ZONETYPE],
EVL_CONTROLLER.alarm_state['zone'][zone_num],
EVL_CONTROLLER)
add_devices_callback([_device])
device_config_data[CONF_ZONENAME],
device_config_data[CONF_ZONETYPE],
hass.data[DATA_EVL].alarm_state['zone'][zone_num],
hass.data[DATA_EVL]
)
devices.append(device)
async_add_devices(devices)
class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
"""Representation of an Envisalink binary sensor."""
def __init__(self, zone_number, zone_name, zone_type, info, controller):
def __init__(self, hass, zone_number, zone_name, zone_type, info,
controller):
"""Initialize the binary_sensor."""
from pydispatch import dispatcher
self._zone_type = zone_type
self._zone_number = zone_number
_LOGGER.debug('Setting up zone: ' + zone_name)
EnvisalinkDevice.__init__(self, zone_name, info, controller)
dispatcher.connect(self._update_callback,
signal=SIGNAL_ZONE_UPDATE,
sender=dispatcher.Any)
super().__init__(zone_name, info, controller)
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
self.hass, SIGNAL_ZONE_UPDATE, self._update_callback)
@property
def device_state_attributes(self):
@@ -60,11 +71,12 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
return self._info['status']['open']
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return self._zone_type
@callback
def _update_callback(self, zone):
"""Update the zone's state, if needed."""
if zone is None or int(zone) == self._zone_number:
self.hass.async_add_job(self.update_ha_state)
self.hass.async_add_job(self.async_update_ha_state())

View File

@@ -1,279 +0,0 @@
"""
Provides a binary sensor which is a collection of ffmpeg tools.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.ffmpeg/
"""
import asyncio
import logging
import os
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, DOMAIN)
from homeassistant.components.ffmpeg import (
DATA_FFMPEG, CONF_INPUT, CONF_OUTPUT, CONF_EXTRA_ARGUMENTS)
from homeassistant.config import load_yaml_config_file
from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START, CONF_NAME,
ATTR_ENTITY_ID)
DEPENDENCIES = ['ffmpeg']
_LOGGER = logging.getLogger(__name__)
SERVICE_START = 'ffmpeg_start'
SERVICE_STOP = 'ffmpeg_stop'
SERVICE_RESTART = 'ffmpeg_restart'
DATA_FFMPEG_DEVICE = 'ffmpeg_binary_sensor'
FFMPEG_SENSOR_NOISE = 'noise'
FFMPEG_SENSOR_MOTION = 'motion'
MAP_FFMPEG_BIN = [
FFMPEG_SENSOR_NOISE,
FFMPEG_SENSOR_MOTION
]
CONF_INITIAL_STATE = 'initial_state'
CONF_TOOL = 'tool'
CONF_PEAK = 'peak'
CONF_DURATION = 'duration'
CONF_RESET = 'reset'
CONF_CHANGES = 'changes'
CONF_REPEAT = 'repeat'
CONF_REPEAT_TIME = 'repeat_time'
DEFAULT_NAME = 'FFmpeg'
DEFAULT_INIT_STATE = True
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_TOOL): vol.In(MAP_FFMPEG_BIN),
vol.Required(CONF_INPUT): cv.string,
vol.Optional(CONF_INITIAL_STATE, default=DEFAULT_INIT_STATE): cv.boolean,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_EXTRA_ARGUMENTS): cv.string,
vol.Optional(CONF_OUTPUT): cv.string,
vol.Optional(CONF_PEAK, default=-30): vol.Coerce(int),
vol.Optional(CONF_DURATION, default=1):
vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_RESET, default=10):
vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_CHANGES, default=10):
vol.All(vol.Coerce(float), vol.Range(min=0, max=99)),
vol.Optional(CONF_REPEAT, default=0):
vol.All(vol.Coerce(int), vol.Range(min=0)),
vol.Optional(CONF_REPEAT_TIME, default=0):
vol.All(vol.Coerce(int), vol.Range(min=0)),
})
SERVICE_FFMPEG_SCHEMA = vol.Schema({
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
})
def restart(hass, entity_id=None):
"""Restart a ffmpeg process on entity."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
hass.services.call(DOMAIN, SERVICE_RESTART, data)
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Create the binary sensor."""
from haffmpeg import SensorNoise, SensorMotion
# check source
if not hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_INPUT)):
return
# generate sensor object
if config.get(CONF_TOOL) == FFMPEG_SENSOR_NOISE:
entity = FFmpegNoise(hass, SensorNoise, config)
else:
entity = FFmpegMotion(hass, SensorMotion, config)
@asyncio.coroutine
def async_shutdown(event):
"""Stop ffmpeg."""
yield from entity.async_shutdown_ffmpeg()
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, async_shutdown)
# start on startup
if config.get(CONF_INITIAL_STATE):
@asyncio.coroutine
def async_start(event):
"""Start ffmpeg."""
yield from entity.async_start_ffmpeg()
yield from entity.async_update_ha_state()
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, async_start)
# add to system
yield from async_add_devices([entity])
# exists service?
if hass.services.has_service(DOMAIN, SERVICE_RESTART):
hass.data[DATA_FFMPEG_DEVICE].append(entity)
return
hass.data[DATA_FFMPEG_DEVICE] = [entity]
descriptions = yield from hass.loop.run_in_executor(
None, load_yaml_config_file,
os.path.join(os.path.dirname(__file__), 'services.yaml'))
# register service
@asyncio.coroutine
def async_service_handle(service):
"""Handle service binary_sensor.ffmpeg_restart."""
entity_ids = service.data.get('entity_id')
if entity_ids:
_devices = [device for device in hass.data[DATA_FFMPEG_DEVICE]
if device.entity_id in entity_ids]
else:
_devices = hass.data[DATA_FFMPEG_DEVICE]
tasks = []
for device in _devices:
if service.service == SERVICE_START:
tasks.append(device.async_start_ffmpeg())
elif service.service == SERVICE_STOP:
tasks.append(device.async_shutdown_ffmpeg())
else:
tasks.append(device.async_restart_ffmpeg())
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop)
hass.services.async_register(
DOMAIN, SERVICE_START, async_service_handle,
descriptions.get(SERVICE_START), schema=SERVICE_FFMPEG_SCHEMA)
hass.services.async_register(
DOMAIN, SERVICE_STOP, async_service_handle,
descriptions.get(SERVICE_STOP), schema=SERVICE_FFMPEG_SCHEMA)
hass.services.async_register(
DOMAIN, SERVICE_RESTART, async_service_handle,
descriptions.get(SERVICE_RESTART), schema=SERVICE_FFMPEG_SCHEMA)
class FFmpegBinarySensor(BinarySensorDevice):
"""A binary sensor which use ffmpeg for noise detection."""
def __init__(self, hass, ffobj, config):
"""Constructor for binary sensor noise detection."""
self._manager = hass.data[DATA_FFMPEG]
self._state = False
self._config = config
self._name = config.get(CONF_NAME)
self._ffmpeg = ffobj(
self._manager.binary, hass.loop, self._async_callback)
def _async_callback(self, state):
"""HA-FFmpeg callback for noise detection."""
self._state = state
self.hass.async_add_job(self.async_update_ha_state())
def async_start_ffmpeg(self):
"""Start a FFmpeg instance.
This method must be run in the event loop and returns a coroutine.
"""
raise NotImplementedError()
def async_shutdown_ffmpeg(self):
"""For STOP event to shutdown ffmpeg.
This method must be run in the event loop and returns a coroutine.
"""
return self._ffmpeg.close()
@asyncio.coroutine
def async_restart_ffmpeg(self):
"""Restart processing."""
yield from self.async_shutdown_ffmpeg()
yield from self.async_start_ffmpeg()
@property
def is_on(self):
"""True if the binary sensor is on."""
return self._state
@property
def should_poll(self):
"""Return True if entity has to be polled for state."""
return False
@property
def name(self):
"""Return the name of the entity."""
return self._name
@property
def available(self):
"""Return True if entity is available."""
return self._ffmpeg.is_running
class FFmpegNoise(FFmpegBinarySensor):
"""A binary sensor which use ffmpeg for noise detection."""
def async_start_ffmpeg(self):
"""Start a FFmpeg instance.
This method must be run in the event loop and returns a coroutine.
"""
# init config
self._ffmpeg.set_options(
time_duration=self._config.get(CONF_DURATION),
time_reset=self._config.get(CONF_RESET),
peak=self._config.get(CONF_PEAK),
)
# run
return self._ffmpeg.open_sensor(
input_source=self._config.get(CONF_INPUT),
output_dest=self._config.get(CONF_OUTPUT),
extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS),
)
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
return "sound"
class FFmpegMotion(FFmpegBinarySensor):
"""A binary sensor which use ffmpeg for noise detection."""
def async_start_ffmpeg(self):
"""Start a FFmpeg instance.
This method must be run in the event loop and returns a coroutine.
"""
# init config
self._ffmpeg.set_options(
time_reset=self._config.get(CONF_RESET),
time_repeat=self._config.get(CONF_REPEAT_TIME),
repeat=self._config.get(CONF_REPEAT),
changes=self._config.get(CONF_CHANGES),
)
# run
return self._ffmpeg.open_sensor(
input_source=self._config.get(CONF_INPUT),
extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS),
)
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
return "motion"

View File

@@ -0,0 +1,128 @@
"""
Provides a binary sensor which is a collection of ffmpeg tools.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.ffmpeg_motion/
"""
import asyncio
import logging
import voluptuous as vol
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA)
from homeassistant.components.ffmpeg import (
FFmpegBase, DATA_FFMPEG, CONF_INPUT, CONF_EXTRA_ARGUMENTS,
CONF_INITIAL_STATE)
from homeassistant.const import CONF_NAME
DEPENDENCIES = ['ffmpeg']
_LOGGER = logging.getLogger(__name__)
CONF_RESET = 'reset'
CONF_CHANGES = 'changes'
CONF_REPEAT = 'repeat'
CONF_REPEAT_TIME = 'repeat_time'
DEFAULT_NAME = 'FFmpeg Motion'
DEFAULT_INIT_STATE = True
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_INPUT): cv.string,
vol.Optional(CONF_INITIAL_STATE, default=DEFAULT_INIT_STATE): cv.boolean,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_EXTRA_ARGUMENTS): cv.string,
vol.Optional(CONF_RESET, default=10):
vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_CHANGES, default=10):
vol.All(vol.Coerce(float), vol.Range(min=0, max=99)),
vol.Inclusive(CONF_REPEAT, 'repeat'):
vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Inclusive(CONF_REPEAT_TIME, 'repeat'):
vol.All(vol.Coerce(int), vol.Range(min=1)),
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Create the binary sensor."""
manager = hass.data[DATA_FFMPEG]
# check source
if not manager.async_run_test(config.get(CONF_INPUT)):
return
# generate sensor object
entity = FFmpegMotion(hass, manager, config)
async_add_devices([entity])
class FFmpegBinarySensor(FFmpegBase, BinarySensorDevice):
"""A binary sensor which use ffmpeg for noise detection."""
def __init__(self, config):
"""Constructor for binary sensor noise detection."""
super().__init__(config.get(CONF_INITIAL_STATE))
self._state = False
self._config = config
self._name = config.get(CONF_NAME)
@callback
def _async_callback(self, state):
"""HA-FFmpeg callback for noise detection."""
self._state = state
self.hass.async_add_job(self.async_update_ha_state())
@property
def is_on(self):
"""True if the binary sensor is on."""
return self._state
@property
def name(self):
"""Return the name of the entity."""
return self._name
class FFmpegMotion(FFmpegBinarySensor):
"""A binary sensor which use ffmpeg for noise detection."""
def __init__(self, hass, manager, config):
"""Initialize ffmpeg motion binary sensor."""
from haffmpeg import SensorMotion
super().__init__(config)
self.ffmpeg = SensorMotion(
manager.binary, hass.loop, self._async_callback)
@asyncio.coroutine
def _async_start_ffmpeg(self, entity_ids):
"""Start a FFmpeg instance.
This method is a coroutine.
"""
if entity_ids is not None and self.entity_id not in entity_ids:
return
# init config
self.ffmpeg.set_options(
time_reset=self._config.get(CONF_RESET),
time_repeat=self._config.get(CONF_REPEAT_TIME, 0),
repeat=self._config.get(CONF_REPEAT, 0),
changes=self._config.get(CONF_CHANGES),
)
# run
yield from self.ffmpeg.open_sensor(
input_source=self._config.get(CONF_INPUT),
extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS),
)
@property
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return "motion"

View File

@@ -0,0 +1,97 @@
"""
Provides a binary sensor which is a collection of ffmpeg tools.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.ffmpeg_noise/
"""
import asyncio
import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA
from homeassistant.components.binary_sensor.ffmpeg_motion import (
FFmpegBinarySensor)
from homeassistant.components.ffmpeg import (
DATA_FFMPEG, CONF_INPUT, CONF_OUTPUT, CONF_EXTRA_ARGUMENTS,
CONF_INITIAL_STATE)
from homeassistant.const import CONF_NAME
DEPENDENCIES = ['ffmpeg']
_LOGGER = logging.getLogger(__name__)
CONF_PEAK = 'peak'
CONF_DURATION = 'duration'
CONF_RESET = 'reset'
DEFAULT_NAME = 'FFmpeg Noise'
DEFAULT_INIT_STATE = True
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_INPUT): cv.string,
vol.Optional(CONF_INITIAL_STATE, default=DEFAULT_INIT_STATE): cv.boolean,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_EXTRA_ARGUMENTS): cv.string,
vol.Optional(CONF_OUTPUT): cv.string,
vol.Optional(CONF_PEAK, default=-30): vol.Coerce(int),
vol.Optional(CONF_DURATION, default=1):
vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_RESET, default=10):
vol.All(vol.Coerce(int), vol.Range(min=1)),
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Create the binary sensor."""
manager = hass.data[DATA_FFMPEG]
# check source
if not manager.async_run_test(config.get(CONF_INPUT)):
return
# generate sensor object
entity = FFmpegNoise(hass, manager, config)
async_add_devices([entity])
class FFmpegNoise(FFmpegBinarySensor):
"""A binary sensor which use ffmpeg for noise detection."""
def __init__(self, hass, manager, config):
"""Initialize ffmpeg noise binary sensor."""
from haffmpeg import SensorNoise
super().__init__(config)
self.ffmpeg = SensorNoise(
manager.binary, hass.loop, self._async_callback)
@asyncio.coroutine
def _async_start_ffmpeg(self, entity_ids):
"""Start a FFmpeg instance.
This method is a coroutine.
"""
if entity_ids is not None and self.entity_id not in entity_ids:
return
# init config
self.ffmpeg.set_options(
time_duration=self._config.get(CONF_DURATION),
time_reset=self._config.get(CONF_RESET),
peak=self._config.get(CONF_PEAK),
)
# run
yield from self.ffmpeg.open_sensor(
input_source=self._config.get(CONF_INPUT),
output_dest=self._config.get(CONF_OUTPUT),
extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS),
)
@property
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return "sound"

View File

@@ -179,12 +179,9 @@ class FlicButton(BinarySensorDevice):
return False
@property
def state_attributes(self):
def device_state_attributes(self):
"""Return device specific state attributes."""
attr = super(FlicButton, self).state_attributes
attr["address"] = self.address
return attr
return {"address": self.address}
def _queued_event_check(self, click_type, time_diff):
"""Generate a log message and returns true if timeout exceeded."""

View File

@@ -15,9 +15,10 @@ from homeassistant.components.binary_sensor import (
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (
CONF_HOST, CONF_PORT, CONF_NAME, CONF_USERNAME, CONF_PASSWORD,
CONF_SSL, EVENT_HOMEASSISTANT_STOP, ATTR_LAST_TRIP_TIME, CONF_CUSTOMIZE)
CONF_SSL, EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START,
ATTR_LAST_TRIP_TIME, CONF_CUSTOMIZE)
REQUIREMENTS = ['pyhik==0.0.7', 'pydispatcher==2.0.5']
REQUIREMENTS = ['pyhik==0.1.0']
_LOGGER = logging.getLogger(__name__)
CONF_IGNORED = 'ignored'
@@ -29,7 +30,7 @@ DEFAULT_DELAY = 0
ATTR_DELAY = 'delay'
SENSOR_CLASS_MAP = {
DEVICE_CLASS_MAP = {
'Motion': 'motion',
'Line Crossing': 'motion',
'IO Trigger': None,
@@ -119,30 +120,32 @@ class HikvisionData(object):
self._password = password
# Establish camera
self._cam = HikCamera(self._url, self._port,
self._username, self._password)
self.camdata = HikCamera(self._url, self._port,
self._username, self._password)
if self._name is None:
self._name = self._cam.get_name
# Start event stream
self._cam.start_stream()
self._name = self.camdata.get_name
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, self.stop_hik)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, self.start_hik)
def stop_hik(self, event):
"""Shutdown Hikvision subscriptions and subscription thread on exit."""
self._cam.disconnect()
self.camdata.disconnect()
def start_hik(self, event):
"""Start Hikvision event stream thread."""
self.camdata.start_stream()
@property
def sensors(self):
"""Return list of available sensors and their states."""
return self._cam.current_event_states
return self.camdata.current_event_states
@property
def cam_id(self):
"""Return camera id."""
return self._cam.get_id
return self.camdata.get_id
@property
def name(self):
@@ -155,8 +158,6 @@ class HikvisionBinarySensor(BinarySensorDevice):
def __init__(self, hass, sensor, cam, delay):
"""Initialize the binary_sensor."""
from pydispatch import dispatcher
self._hass = hass
self._cam = cam
self._name = self._cam.name + ' ' + sensor
@@ -170,12 +171,8 @@ class HikvisionBinarySensor(BinarySensorDevice):
self._timer = None
# Form signal for dispatcher
signal = 'ValueChanged.{}'.format(self._cam.cam_id)
dispatcher.connect(self._update_callback,
signal=signal,
sender=self._sensor)
# Register callback function with pyHik
self._cam.camdata.add_update_callback(self._update_callback, self._id)
def _sensor_state(self):
"""Extract sensor state."""
@@ -201,10 +198,10 @@ class HikvisionBinarySensor(BinarySensorDevice):
return self._sensor_state()
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
try:
return SENSOR_CLASS_MAP[self._sensor]
return DEVICE_CLASS_MAP[self._sensor]
except KeyError:
# Sensor must be unknown to us, add as generic
return None
@@ -225,13 +222,9 @@ class HikvisionBinarySensor(BinarySensorDevice):
return attr
def _update_callback(self, signal, sender):
def _update_callback(self, msg):
"""Update the sensor's state, if needed."""
_LOGGER.debug('Dispatcher callback, signal: %s, sender: %s',
signal, sender)
if sender is not self._sensor:
return
_LOGGER.debug('Callback signal from: %s', msg)
if self._delay > 0 and not self.is_on:
# Set timer to wait until updating the state

View File

@@ -7,8 +7,7 @@ https://home-assistant.io/components/binary_sensor.homematic/
import logging
from homeassistant.const import STATE_UNKNOWN
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.homematic import HMDevice
from homeassistant.loader import get_component
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
_LOGGER = logging.getLogger(__name__)
@@ -29,18 +28,18 @@ SENSOR_TYPES_CLASS = {
}
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Homematic binary sensor platform."""
if discovery_info is None:
return
homematic = get_component("homematic")
return homematic.setup_hmdevice_discovery_helper(
hass,
HMBinarySensor,
discovery_info,
add_callback_devices
)
devices = []
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
new_device = HMBinarySensor(hass, config)
new_device.link_homematic()
devices.append(new_device)
add_devices(devices)
class HMBinarySensor(HMDevice, BinarySensorDevice):
@@ -54,11 +53,8 @@ class HMBinarySensor(HMDevice, BinarySensorDevice):
return bool(self._hm_get_state())
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
if not self.available:
return None
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
# If state is MOTION (RemoteMotion works only)
if self._state == "MOTION":
return "motion"

View File

@@ -0,0 +1,87 @@
"""
Support for INSTEON dimmers via PowerLinc Modem.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/insteon_plm/
"""
import logging
import asyncio
from homeassistant.core import callback
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.loader import get_component
DEPENDENCIES = ['insteon_plm']
_LOGGER = logging.getLogger(__name__)
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the INSTEON PLM device class for the hass platform."""
plm = hass.data['insteon_plm']
device_list = []
for device in discovery_info:
name = device.get('address')
address = device.get('address_hex')
_LOGGER.info('Registered %s with binary_sensor platform.', name)
device_list.append(
InsteonPLMBinarySensorDevice(hass, plm, address, name)
)
hass.async_add_job(async_add_devices(device_list))
class InsteonPLMBinarySensorDevice(BinarySensorDevice):
"""A Class for an Insteon device."""
def __init__(self, hass, plm, address, name):
"""Initialize the binarysensor."""
self._hass = hass
self._plm = plm.protocol
self._address = address
self._name = name
self._plm.add_update_callback(
self.async_binarysensor_update, {'address': self._address})
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def address(self):
"""Return the the address of the node."""
return self._address
@property
def name(self):
"""Return the the name of the node."""
return self._name
@property
def is_on(self):
"""Return the boolean response if the node is on."""
sensorstate = self._plm.get_device_attr(self._address, 'sensorstate')
_LOGGER.info('sensor state for %s is %s', self._address, sensorstate)
return bool(sensorstate)
@property
def device_state_attributes(self):
"""Provide attributes for display on device card."""
insteon_plm = get_component('insteon_plm')
return insteon_plm.common_attributes(self)
def get_attr(self, key):
"""Return specified attribute for this device."""
return self._plm.get_device_attr(self.address, key)
@callback
def async_binarysensor_update(self, message):
"""Receive notification from transport that new data exists."""
_LOGGER.info('Received update calback from PLM for %s', self._address)
self._hass.async_add_job(self.async_update_ha_state())

View File

@@ -26,7 +26,7 @@ ATTR_ISS_NUMBER_PEOPLE_SPACE = 'number_of_people_in_space'
CONF_SHOW_ON_MAP = 'show_on_map'
DEFAULT_NAME = 'ISS'
DEFAULT_SENSOR_CLASS = 'visible'
DEFAULT_DEVICE_CLASS = 'visible'
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
@@ -77,9 +77,9 @@ class IssBinarySensor(BinarySensorDevice):
return self.iss_data.is_above if self.iss_data else False
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return DEFAULT_SENSOR_CLASS
return DEFAULT_DEVICE_CLASS
@property
def device_state_attributes(self):

View File

@@ -0,0 +1,76 @@
"""
Support for MAX! Window Shutter via MAX! Cube.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/maxcube/
"""
import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.maxcube import MAXCUBE_HANDLE
from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Iterate through all MAX! Devices and add window shutters to HASS."""
cube = hass.data[MAXCUBE_HANDLE].cube
# List of devices
devices = []
for device in cube.devices:
# Create device name by concatenating room name + device name
name = "%s %s" % (cube.room_by_id(device.room_id).name, device.name)
# Only add Window Shutters
if cube.is_windowshutter(device):
# add device to HASS
devices.append(MaxCubeShutter(hass, name, device.rf_address))
if len(devices) > 0:
add_devices(devices)
class MaxCubeShutter(BinarySensorDevice):
"""MAX! Cube BinarySensor device."""
def __init__(self, hass, name, rf_address):
"""Initialize MAX! Cube BinarySensorDevice."""
self._name = name
self._sensor_type = 'opening'
self._rf_address = rf_address
self._cubehandle = hass.data[MAXCUBE_HANDLE]
self._state = STATE_UNKNOWN
@property
def should_poll(self):
"""Polling is required."""
return True
@property
def name(self):
"""Return the name of the BinarySensorDevice."""
return self._name
@property
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_type
@property
def is_on(self):
"""Return true if the binary sensor is on/open."""
return self._state
def update(self):
"""Get latest data from MAX! Cube."""
self._cubehandle.update()
# Get the device we want to update
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Update our internal state
self._state = device.is_open

View File

@@ -4,6 +4,7 @@ Support for MQTT binary sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.mqtt/
"""
import asyncio
import logging
import voluptuous as vol
@@ -11,12 +12,13 @@ import voluptuous as vol
from homeassistant.core import callback
import homeassistant.components.mqtt as mqtt
from homeassistant.components.binary_sensor import (
BinarySensorDevice, SENSOR_CLASSES)
BinarySensorDevice, DEVICE_CLASSES_SCHEMA)
from homeassistant.const import (
CONF_NAME, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_ON, CONF_PAYLOAD_OFF,
CONF_SENSOR_CLASS)
CONF_SENSOR_CLASS, CONF_DEVICE_CLASS)
from homeassistant.components.mqtt import (CONF_STATE_TOPIC, CONF_QOS)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
_LOGGER = logging.getLogger(__name__)
@@ -29,22 +31,25 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PAYLOAD_OFF, default=DEFAULT_PAYLOAD_OFF): cv.string,
vol.Optional(CONF_PAYLOAD_ON, default=DEFAULT_PAYLOAD_ON): cv.string,
vol.Optional(CONF_SENSOR_CLASS, default=None):
vol.Any(vol.In(SENSOR_CLASSES), vol.SetTo(None)),
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the MQTT binary sensor."""
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the MQTT binary sensor."""
if discovery_info is not None:
config = PLATFORM_SCHEMA(discovery_info)
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = hass
add_devices([MqttBinarySensor(
hass,
async_add_devices([MqttBinarySensor(
config.get(CONF_NAME),
config.get(CONF_STATE_TOPIC),
config.get(CONF_SENSOR_CLASS),
get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS),
config.get(CONF_QOS),
config.get(CONF_PAYLOAD_ON),
config.get(CONF_PAYLOAD_OFF),
@@ -55,32 +60,38 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class MqttBinarySensor(BinarySensorDevice):
"""Representation a binary sensor that is updated by MQTT."""
def __init__(self, hass, name, state_topic, sensor_class, qos, payload_on,
def __init__(self, name, state_topic, device_class, qos, payload_on,
payload_off, value_template):
"""Initialize the MQTT binary sensor."""
self._hass = hass
self._name = name
self._state = False
self._state_topic = state_topic
self._sensor_class = sensor_class
self._device_class = device_class
self._payload_on = payload_on
self._payload_off = payload_off
self._qos = qos
self._template = value_template
def async_added_to_hass(self):
"""Subscribe mqtt events.
This method must be run in the event loop and returns a coroutine.
"""
@callback
def message_received(topic, payload, qos):
"""A new MQTT message has been received."""
if value_template is not None:
payload = value_template.async_render_with_possible_json_value(
if self._template is not None:
payload = self._template.async_render_with_possible_json_value(
payload)
if payload == self._payload_on:
self._state = True
hass.async_add_job(self.async_update_ha_state())
elif payload == self._payload_off:
self._state = False
hass.async_add_job(self.async_update_ha_state())
mqtt.subscribe(hass, self._state_topic, message_received, self._qos)
self.hass.async_add_job(self.async_update_ha_state())
return mqtt.async_subscribe(
self.hass, self._state_topic, message_received, self._qos)
@property
def should_poll(self):
@@ -98,6 +109,6 @@ class MqttBinarySensor(BinarySensorDevice):
return self._state
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_class
return self._device_class

View File

@@ -7,7 +7,7 @@ https://home-assistant.io/components/binary_sensor.mysensors/
import logging
from homeassistant.components import mysensors
from homeassistant.components.binary_sensor import (SENSOR_CLASSES,
from homeassistant.components.binary_sensor import (DEVICE_CLASSES,
BinarySensorDevice)
from homeassistant.const import STATE_ON
@@ -62,8 +62,8 @@ class MySensorsBinarySensor(
return False
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
pres = self.gateway.const.Presentation
class_map = {
pres.S_DOOR: 'opening',
@@ -78,5 +78,5 @@ class MySensorsBinarySensor(
pres.S_VIBRATION: 'vibration',
pres.S_MOISTURE: 'moisture',
})
if class_map.get(self.child_type) in SENSOR_CLASSES:
if class_map.get(self.child_type) in DEVICE_CLASSES:
return class_map.get(self.child_type)

View File

@@ -154,8 +154,8 @@ class NetatmoBinarySensor(BinarySensorDevice):
return self._unique_id
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
if self._cameratype == "NACamera":
return WELCOME_SENSOR_TYPES.get(self._sensor_name)
elif self._cameratype == "NOC":

View File

@@ -12,7 +12,7 @@ import requests
import voluptuous as vol
from homeassistant.components.binary_sensor import (
SENSOR_CLASSES, BinarySensorDevice, PLATFORM_SCHEMA)
DEVICE_CLASSES, BinarySensorDevice, PLATFORM_SCHEMA)
from homeassistant.const import (CONF_HOST, CONF_PORT)
import homeassistant.helpers.config_validation as cv
@@ -28,7 +28,7 @@ DEFAULT_PORT = '5007'
DEFAULT_SSL = False
ZONE_TYPES_SCHEMA = vol.Schema({
cv.positive_int: vol.In(SENSOR_CLASSES),
cv.positive_int: vol.In(DEVICE_CLASSES),
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@@ -85,8 +85,8 @@ class NX584ZoneSensor(BinarySensorDevice):
self._zone_type = zone_type
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return self._zone_type
@property

View File

@@ -99,8 +99,8 @@ class OctoPrintBinarySensor(BinarySensorDevice):
return STATE_OFF
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return None
def update(self):

View File

@@ -10,14 +10,15 @@ import voluptuous as vol
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
from homeassistant.components.binary_sensor import (
BinarySensorDevice, SENSOR_CLASSES_SCHEMA, PLATFORM_SCHEMA)
BinarySensorDevice, DEVICE_CLASSES_SCHEMA, PLATFORM_SCHEMA)
from homeassistant.components.sensor.rest import RestData
from homeassistant.const import (
CONF_PAYLOAD, CONF_NAME, CONF_VALUE_TEMPLATE, CONF_METHOD, CONF_RESOURCE,
CONF_SENSOR_CLASS, CONF_VERIFY_SSL, CONF_USERNAME, CONF_PASSWORD,
CONF_HEADERS, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
HTTP_DIGEST_AUTHENTICATION)
HTTP_DIGEST_AUTHENTICATION, CONF_DEVICE_CLASS)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
_LOGGER = logging.getLogger(__name__)
@@ -34,7 +35,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PAYLOAD): cv.string,
vol.Optional(CONF_SENSOR_CLASS): SENSOR_CLASSES_SCHEMA,
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_USERNAME): cv.string,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
@@ -51,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
headers = config.get(CONF_HEADERS)
sensor_class = config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = hass
@@ -72,18 +74,18 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return False
add_devices([RestBinarySensor(
hass, rest, name, sensor_class, value_template)])
hass, rest, name, device_class, value_template)])
class RestBinarySensor(BinarySensorDevice):
"""Representation of a REST binary sensor."""
def __init__(self, hass, rest, name, sensor_class, value_template):
def __init__(self, hass, rest, name, device_class, value_template):
"""Initialize a REST binary sensor."""
self._hass = hass
self.rest = rest
self._name = name
self._sensor_class = sensor_class
self._device_class = device_class
self._state = False
self._previous_data = None
self._value_template = value_template
@@ -95,9 +97,9 @@ class RestBinarySensor(BinarySensorDevice):
return self._name
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return self._sensor_class
return self._device_class
@property
def is_on(self):

View File

@@ -1,25 +0,0 @@
# Describes the format for available binary_sensor services
ffmpeg_start:
description: Send a start command to a ffmpeg based sensor.
fields:
entity_id:
description: Name(s) of entites that will start. Platform dependent.
example: 'binary_sensor.ffmpeg_noise'
ffmpeg_stop:
description: Send a stop command to a ffmpeg based sensor.
fields:
entity_id:
description: Name(s) of entites that will stop. Platform dependent.
example: 'binary_sensor.ffmpeg_noise'
ffmpeg_restart:
description: Send a restart command to a ffmpeg based sensor.
fields:
entity_id:
description: Name(s) of entites that will restart. Platform dependent.
example: 'binary_sensor.ffmpeg_noise'

View File

@@ -42,7 +42,7 @@ class IsInBedBinarySensor(sleepiq.SleepIQSensor, BinarySensorDevice):
return self._state is True
@property
def sensor_class(self):
def device_class(self):
"""Return the class of this sensor."""
return "occupancy"

View File

@@ -12,14 +12,17 @@ import voluptuous as vol
from homeassistant.core import callback
from homeassistant.components.binary_sensor import (
BinarySensorDevice, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
SENSOR_CLASSES_SCHEMA)
DEVICE_CLASSES_SCHEMA)
from homeassistant.const import (
ATTR_FRIENDLY_NAME, ATTR_ENTITY_ID, CONF_VALUE_TEMPLATE,
CONF_SENSOR_CLASS, CONF_SENSORS)
CONF_SENSOR_CLASS, CONF_SENSORS, CONF_DEVICE_CLASS,
EVENT_HOMEASSISTANT_START, STATE_ON)
from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.deprecation import get_deprecated
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.event import async_track_state_change
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.restore_state import async_get_last_state
_LOGGER = logging.getLogger(__name__)
@@ -27,7 +30,8 @@ SENSOR_SCHEMA = vol.Schema({
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@@ -45,7 +49,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
entity_ids = (device_config.get(ATTR_ENTITY_ID) or
value_template.extract_entities())
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
sensor_class = device_config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(
device_config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
if value_template is not None:
value_template.hass = hass
@@ -55,7 +60,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
hass,
device,
friendly_name,
sensor_class,
device_class,
value_template,
entity_ids)
)
@@ -63,31 +68,47 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
_LOGGER.error('No sensors added')
return False
yield from async_add_devices(sensors, True)
async_add_devices(sensors, True)
return True
class BinarySensorTemplate(BinarySensorDevice):
"""A virtual binary sensor that triggers from another sensor."""
def __init__(self, hass, device, friendly_name, sensor_class,
def __init__(self, hass, device, friendly_name, device_class,
value_template, entity_ids):
"""Initialize the Template binary sensor."""
self.hass = hass
self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, device,
hass=hass)
self._name = friendly_name
self._sensor_class = sensor_class
self._device_class = device_class
self._template = value_template
self._state = None
self._entities = entity_ids
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
state = yield from async_get_last_state(self.hass, self.entity_id)
if state:
self._state = state.state == STATE_ON
@callback
def template_bsensor_state_listener(entity, old_state, new_state):
"""Called when the target device changes state."""
hass.async_add_job(self.async_update_ha_state, True)
self.hass.async_add_job(self.async_update_ha_state(True))
async_track_state_change(
hass, entity_ids, template_bsensor_state_listener)
@callback
def template_bsensor_startup(event):
"""Update template on startup."""
async_track_state_change(
self.hass, self._entities, template_bsensor_state_listener)
self.hass.async_add_job(self.async_update_ha_state(True))
self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, template_bsensor_startup)
@property
def name(self):
@@ -100,9 +121,9 @@ class BinarySensorTemplate(BinarySensorDevice):
return self._state
@property
def sensor_class(self):
def device_class(self):
"""Return the sensor class of the sensor."""
return self._sensor_class
return self._device_class
@property
def should_poll(self):
@@ -118,7 +139,8 @@ class BinarySensorTemplate(BinarySensorDevice):
if ex.args and ex.args[0].startswith(
"UndefinedError: 'None' has no attribute"):
# Common during HA startup - so just a warning
_LOGGER.warning(ex)
_LOGGER.warning('Could not render template %s,'
' the state is unknown.', self._name)
return
_LOGGER.error(ex)
_LOGGER.error('Could not render template %s: %s', self._name, ex)
self._state = False

View File

@@ -11,11 +11,12 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.binary_sensor import (
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES_SCHEMA)
BinarySensorDevice, PLATFORM_SCHEMA, DEVICE_CLASSES_SCHEMA)
from homeassistant.const import (
CONF_NAME, CONF_ENTITY_ID, CONF_TYPE, STATE_UNKNOWN, CONF_SENSOR_CLASS,
ATTR_ENTITY_ID)
ATTR_ENTITY_ID, CONF_DEVICE_CLASS)
from homeassistant.core import callback
from homeassistant.helpers.deprecation import get_deprecated
from homeassistant.helpers.event import async_track_state_change
_LOGGER = logging.getLogger(__name__)
@@ -37,7 +38,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_THRESHOLD): vol.Coerce(float),
vol.Required(CONF_TYPE): vol.In(SENSOR_TYPES),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA,
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
@@ -48,11 +50,11 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
name = config.get(CONF_NAME)
threshold = config.get(CONF_THRESHOLD)
limit_type = config.get(CONF_TYPE)
sensor_class = config.get(CONF_SENSOR_CLASS)
device_class = get_deprecated(config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
yield from async_add_devices(
async_add_devices(
[ThresholdSensor(hass, entity_id, name, threshold, limit_type,
sensor_class)], True)
device_class)], True)
return True
@@ -60,14 +62,14 @@ class ThresholdSensor(BinarySensorDevice):
"""Representation of a Threshold sensor."""
def __init__(self, hass, entity_id, name, threshold, limit_type,
sensor_class):
device_class):
"""Initialize the Threshold sensor."""
self._hass = hass
self._entity_id = entity_id
self.is_upper = limit_type == 'upper'
self._name = name
self._threshold = threshold
self._sensor_class = sensor_class
self._device_class = device_class
self._deviation = False
self.sensor_value = 0
@@ -105,9 +107,9 @@ class ThresholdSensor(BinarySensorDevice):
return False
@property
def sensor_class(self):
def device_class(self):
"""Return the sensor class of the sensor."""
return self._sensor_class
return self._device_class
@property
def device_state_attributes(self):

View File

@@ -15,12 +15,14 @@ from homeassistant.components.binary_sensor import (
BinarySensorDevice,
ENTITY_ID_FORMAT,
PLATFORM_SCHEMA,
SENSOR_CLASSES_SCHEMA)
DEVICE_CLASSES_SCHEMA)
from homeassistant.const import (
ATTR_FRIENDLY_NAME,
ATTR_ENTITY_ID,
CONF_SENSOR_CLASS,
CONF_DEVICE_CLASS,
STATE_UNKNOWN,)
from homeassistant.helpers.deprecation import get_deprecated
from homeassistant.helpers.entity import generate_entity_id
from homeassistant.helpers.event import track_state_change
@@ -34,8 +36,8 @@ SENSOR_SCHEMA = vol.Schema({
vol.Optional(CONF_ATTRIBUTE): cv.string,
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
vol.Optional(CONF_INVERT, default=False): cv.boolean,
vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA
vol.Optional(CONF_SENSOR_CLASS): DEVICE_CLASSES_SCHEMA,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@@ -52,7 +54,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
entity_id = device_config[ATTR_ENTITY_ID]
attribute = device_config.get(CONF_ATTRIBUTE)
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
sensor_class = device_config[CONF_SENSOR_CLASS]
device_class = get_deprecated(
device_config, CONF_DEVICE_CLASS, CONF_SENSOR_CLASS)
invert = device_config[CONF_INVERT]
sensors.append(
@@ -62,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
friendly_name,
entity_id,
attribute,
sensor_class,
device_class,
invert)
)
if not sensors:
@@ -76,7 +79,7 @@ class SensorTrend(BinarySensorDevice):
"""Representation of a trend Sensor."""
def __init__(self, hass, device_id, friendly_name,
target_entity, attribute, sensor_class, invert):
target_entity, attribute, device_class, invert):
"""Initialize the sensor."""
self._hass = hass
self.entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id,
@@ -84,7 +87,7 @@ class SensorTrend(BinarySensorDevice):
self._name = friendly_name
self._target_entity = target_entity
self._attribute = attribute
self._sensor_class = sensor_class
self._device_class = device_class
self._invert = invert
self._state = None
self.from_state = None
@@ -111,9 +114,9 @@ class SensorTrend(BinarySensorDevice):
return self._state
@property
def sensor_class(self):
def device_class(self):
"""Return the sensor class of the sensor."""
return self._sensor_class
return self._device_class
@property
def should_poll(self):

View File

@@ -7,9 +7,9 @@ https://home-assistant.io/components/binary_sensor.vera/
import logging
from homeassistant.components.binary_sensor import (
BinarySensorDevice)
BinarySensorDevice, ENTITY_ID_FORMAT)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
DEPENDENCIES = ['vera']
@@ -30,6 +30,7 @@ class VeraBinarySensor(VeraDevice, BinarySensorDevice):
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
@property
def is_on(self):

View File

@@ -0,0 +1,40 @@
"""
Support for VOC.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.volvooncall/
"""
import logging
from homeassistant.components.volvooncall import VolvoEntity
from homeassistant.components.binary_sensor import BinarySensorDevice
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Volvo sensors."""
if discovery_info is None:
return
add_devices([VolvoSensor(hass, *discovery_info)])
class VolvoSensor(VolvoEntity, BinarySensorDevice):
"""Representation of a Volvo sensor."""
@property
def is_on(self):
"""Return True if the binary sensor is on."""
val = getattr(self.vehicle, self._attribute)
if self._attribute == 'bulb_failures':
return len(val) > 0
elif self._attribute in ['doors', 'windows']:
return any([val[key] for key in val if 'Open' in key])
else:
return val != 'Normal'
@property
def device_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
return 'safety'

View File

@@ -4,11 +4,14 @@ Support for Wink binary sensors.
For more details about this platform, please refer to the documentation at
at https://home-assistant.io/components/binary_sensor.wink/
"""
import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.sensor.wink import WinkDevice
from homeassistant.components.wink import WinkDevice, DOMAIN
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['wink']
# These are the available sensors mapped to binary_sensor class
@@ -17,11 +20,14 @@ SENSOR_TYPES = {
"brightness": "light",
"vibration": "vibration",
"loudness": "sound",
"noise": "sound",
"capturing_audio": "sound",
"liquid_detected": "moisture",
"motion": "motion",
"presence": "occupancy",
"co_detected": "gas",
"smoke_detected": "smoke"
"smoke_detected": "smoke",
"capturing_video": None
}
@@ -30,26 +36,54 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
import pywink
for sensor in pywink.get_sensors():
if sensor.capability() in SENSOR_TYPES:
add_devices([WinkBinarySensorDevice(sensor, hass)])
_id = sensor.object_id() + sensor.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
if sensor.capability() in SENSOR_TYPES:
add_devices([WinkBinarySensorDevice(sensor, hass)])
for key in pywink.get_keys():
add_devices([WinkBinarySensorDevice(key, hass)])
_id = key.object_id() + key.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkBinarySensorDevice(key, hass)])
for sensor in pywink.get_smoke_and_co_detectors():
add_devices([WinkBinarySensorDevice(sensor, hass)])
_id = sensor.object_id() + sensor.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkSmokeDetector(sensor, hass)])
for hub in pywink.get_hubs():
add_devices([WinkHub(hub, hass)])
_id = hub.object_id() + hub.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkHub(hub, hass)])
for remote in pywink.get_remotes():
add_devices([WinkRemote(remote, hass)])
_id = remote.object_id() + remote.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkRemote(remote, hass)])
for button in pywink.get_buttons():
add_devices([WinkButton(button, hass)])
_id = button.object_id() + button.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkButton(button, hass)])
for gang in pywink.get_gangs():
add_devices([WinkGang(gang, hass)])
_id = gang.object_id() + gang.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkGang(gang, hass)])
for door_bell_sensor in pywink.get_door_bells():
_id = door_bell_sensor.object_id() + door_bell_sensor.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkBinarySensorDevice(door_bell_sensor, hass)])
for camera_sensor in pywink.get_cameras():
_id = camera_sensor.object_id() + camera_sensor.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
try:
if camera_sensor.capability() in SENSOR_TYPES:
add_devices([WinkBinarySensorDevice(camera_sensor, hass)])
except AttributeError:
_LOGGER.info("Device isn't a sensor, skipping.")
class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
@@ -58,8 +92,14 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
self._unit_of_measurement = self.wink.unit()
self.capability = self.wink.capability()
if hasattr(self.wink, 'unit'):
self._unit_of_measurement = self.wink.unit()
else:
self._unit_of_measurement = None
if hasattr(self.wink, 'capability'):
self.capability = self.wink.capability()
else:
self.capability = None
@property
def is_on(self):
@@ -67,22 +107,32 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
return self.wink.state()
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return SENSOR_TYPES.get(self.capability)
class WinkHub(WinkDevice, BinarySensorDevice, Entity):
"""Representation of a Wink Hub."""
class WinkSmokeDetector(WinkBinarySensorDevice):
"""Representation of a Wink Smoke detector."""
def __init(self, wink, hass):
"""Initialize the hub sensor."""
WinkDevice.__init__(self, wink, hass)
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
@property
def is_on(self):
"""Return true if the binary sensor is on."""
return self.wink.state()
def device_state_attributes(self):
"""Return the state attributes."""
return {
'test_activated': self.wink.test_activated()
}
class WinkHub(WinkBinarySensorDevice):
"""Representation of a Wink Hub."""
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
@property
def device_state_attributes(self):
@@ -93,17 +143,12 @@ class WinkHub(WinkDevice, BinarySensorDevice, Entity):
}
class WinkRemote(WinkDevice, BinarySensorDevice, Entity):
class WinkRemote(WinkBinarySensorDevice):
"""Representation of a Wink Lutron Connected bulb remote."""
def __init(self, wink, hass):
"""Initialize the hub sensor."""
WinkDevice.__init__(self, wink, hass)
@property
def is_on(self):
"""Return true if the binary sensor is on."""
return self.wink.state()
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
@property
def device_state_attributes(self):
@@ -115,18 +160,18 @@ class WinkRemote(WinkDevice, BinarySensorDevice, Entity):
'button_down_pressed': self.wink.button_down_pressed()
}
@property
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return None
class WinkButton(WinkDevice, BinarySensorDevice, Entity):
class WinkButton(WinkBinarySensorDevice):
"""Representation of a Wink Relay button."""
def __init(self, wink, hass):
"""Initialize the hub sensor."""
WinkDevice.__init__(self, wink, hass)
@property
def is_on(self):
"""Return true if the binary sensor is on."""
return self.wink.state()
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
@property
def device_state_attributes(self):
@@ -137,12 +182,12 @@ class WinkButton(WinkDevice, BinarySensorDevice, Entity):
}
class WinkGang(WinkDevice, BinarySensorDevice, Entity):
class WinkGang(WinkBinarySensorDevice):
"""Representation of a Wink Relay gang."""
def __init(self, wink, hass):
"""Initialize the gang sensor."""
WinkDevice.__init__(self, wink, hass)
def __init__(self, wink, hass):
"""Initialize the Wink binary sensor."""
super().__init__(wink, hass)
@property
def is_on(self):

View File

@@ -0,0 +1,157 @@
"""Sensor to indicate whether the current day is a workday."""
import asyncio
import logging
import datetime
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (STATE_ON, STATE_OFF, STATE_UNKNOWN,
CONF_NAME, WEEKDAYS)
import homeassistant.util.dt as dt_util
from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['holidays==0.8.1']
# List of all countries currently supported by holidays
# There seems to be no way to get the list out at runtime
ALL_COUNTRIES = ['Australia', 'AU', 'Austria', 'AT', 'Canada', 'CA',
'Colombia', 'CO', 'Czech', 'CZ', 'Denmark', 'DK', 'England',
'EuropeanCentralBank', 'ECB', 'TAR', 'Germany', 'DE',
'Ireland', 'Isle of Man', 'Mexico', 'MX', 'Netherlands', 'NL',
'NewZealand', 'NZ', 'Northern Ireland', 'Norway', 'NO',
'Portugal', 'PT', 'PortugalExt', 'PTE', 'Scotland', 'Spain',
'ES', 'UnitedKingdom', 'UK', 'UnitedStates', 'US', 'Wales']
CONF_COUNTRY = 'country'
CONF_PROVINCE = 'province'
CONF_WORKDAYS = 'workdays'
# By default, Monday - Friday are workdays
DEFAULT_WORKDAYS = ['mon', 'tue', 'wed', 'thu', 'fri']
CONF_EXCLUDES = 'excludes'
# By default, public holidays, Saturdays and Sundays are excluded from workdays
DEFAULT_EXCLUDES = ['sat', 'sun', 'holiday']
DEFAULT_NAME = 'Workday Sensor'
ALLOWED_DAYS = WEEKDAYS + ['holiday']
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_COUNTRY): vol.In(ALL_COUNTRIES),
vol.Optional(CONF_PROVINCE, default=None): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_WORKDAYS, default=DEFAULT_WORKDAYS):
vol.All(cv.ensure_list, [vol.In(ALLOWED_DAYS)]),
vol.Optional(CONF_EXCLUDES, default=DEFAULT_EXCLUDES):
vol.All(cv.ensure_list, [vol.In(ALLOWED_DAYS)]),
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Workday sensor."""
import holidays
# Get the Sensor name from the config
sensor_name = config.get(CONF_NAME)
# Get the country code from the config
country = config.get(CONF_COUNTRY)
# Get the province from the config
province = config.get(CONF_PROVINCE)
# Get the list of workdays from the config
workdays = config.get(CONF_WORKDAYS)
# Get the list of excludes from the config
excludes = config.get(CONF_EXCLUDES)
# Instantiate the holidays module for the current year
year = datetime.datetime.now().year
obj_holidays = getattr(holidays, country)(years=year)
# Also apply the provience, if available for the configured country
if province:
if province not in obj_holidays.PROVINCES:
_LOGGER.error('There is no province/state %s in country %s',
province, country)
return False
else:
year = datetime.datetime.now().year
obj_holidays = getattr(holidays, country)(prov=province,
years=year)
# Output found public holidays via the debug channel
_LOGGER.debug("Found the following holidays for your configuration:")
for date, name in sorted(obj_holidays.items()):
_LOGGER.debug("%s %s", date, name)
# Add ourselves as device
add_devices([IsWorkdaySensor(obj_holidays, workdays,
excludes, sensor_name)], True)
def day_to_string(day):
"""Convert day index 0 - 7 to string."""
try:
return ALLOWED_DAYS[day]
except IndexError:
return None
class IsWorkdaySensor(Entity):
"""Implementation of a Workday sensor."""
def __init__(self, obj_holidays, workdays, excludes, name):
"""Initialize the Workday sensor."""
self._name = name
self._obj_holidays = obj_holidays
self._workdays = workdays
self._excludes = excludes
self._state = STATE_UNKNOWN
@property
def name(self):
"""Return the name of the sensor."""
return self._name
@property
def state(self):
"""Return the state of the device."""
return self._state
def is_include(self, day, now):
"""Check if given day is in the includes list."""
# Check includes
if day in self._workdays:
return True
elif 'holiday' in self._workdays and now in self._obj_holidays:
return True
return False
def is_exclude(self, day, now):
"""Check if given day is in the excludes list."""
# Check excludes
if day in self._excludes:
return True
elif 'holiday' in self._excludes and now in self._obj_holidays:
return True
return False
@asyncio.coroutine
def async_update(self):
"""Get date and look whether it is a holiday."""
# Default is no workday
self._state = STATE_OFF
# Get iso day of the week (1 = Monday, 7 = Sunday)
day = datetime.datetime.today().isoweekday() - 1
day_of_week = day_to_string(day)
if self.is_include(day_of_week, dt_util.now()):
self._state = STATE_ON
if self.is_exclude(day_of_week, dt_util.now()):
self._state = STATE_OFF

View File

@@ -24,7 +24,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ZigBee binary sensor platform."""
add_devices([ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))])
add_devices(
[ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))], True)
class ZigBeeBinarySensor(ZigBeeDigitalIn, BinarySensorDevice):

View File

@@ -9,6 +9,8 @@ import datetime
import homeassistant.util.dt as dt_util
from homeassistant.helpers.event import track_point_in_time
from homeassistant.components import zwave
from homeassistant.components.zwave import workaround
from homeassistant.components.zwave import async_setup_platform # noqa # pylint: disable=unused-import
from homeassistant.components.binary_sensor import (
DOMAIN,
BinarySensorDevice)
@@ -16,109 +18,72 @@ from homeassistant.components.binary_sensor import (
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = []
PHILIO = 0x013c
PHILIO_SLIM_SENSOR = 0x0002
PHILIO_SLIM_SENSOR_MOTION = (PHILIO, PHILIO_SLIM_SENSOR, 0)
PHILIO_3_IN_1_SENSOR_GEN_4 = 0x000d
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION = (PHILIO, PHILIO_3_IN_1_SENSOR_GEN_4, 0)
WENZHOU = 0x0118
WENZHOU_SLIM_SENSOR_MOTION = (WENZHOU, PHILIO_SLIM_SENSOR, 0)
WORKAROUND_NO_OFF_EVENT = 'trigger_no_off_event'
def get_device(values, **kwargs):
"""Create zwave entity device."""
device_mapping = workaround.get_device_mapping(values.primary)
if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT:
# Default the multiplier to 4
re_arm_multiplier = zwave.get_config_value(values.primary.node, 9) or 4
return ZWaveTriggerSensor(values, "motion", re_arm_multiplier * 8)
DEVICE_MAPPINGS = {
PHILIO_SLIM_SENSOR_MOTION: WORKAROUND_NO_OFF_EVENT,
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION: WORKAROUND_NO_OFF_EVENT,
WENZHOU_SLIM_SENSOR_MOTION: WORKAROUND_NO_OFF_EVENT,
}
if workaround.get_device_component_mapping(values.primary) == DOMAIN:
return ZWaveBinarySensor(values, None)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Z-Wave platform for binary sensors."""
if discovery_info is None or zwave.NETWORK is None:
return
node = zwave.NETWORK.nodes[discovery_info[zwave.const.ATTR_NODE_ID]]
value = node.values[discovery_info[zwave.const.ATTR_VALUE_ID]]
value.set_change_verified(False)
# Make sure that we have values for the key before converting to int
if (value.node.manufacturer_id.strip() and
value.node.product_id.strip()):
specific_sensor_key = (int(value.node.manufacturer_id, 16),
int(value.node.product_id, 16),
value.index)
if specific_sensor_key in DEVICE_MAPPINGS:
if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_NO_OFF_EVENT:
# Default the multiplier to 4
re_arm_multiplier = (zwave.get_config_value(value.node,
9) or 4)
add_devices([
ZWaveTriggerSensor(value, "motion",
hass, re_arm_multiplier * 8)
])
return
if value.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY:
add_devices([ZWaveBinarySensor(value, None)])
if values.primary.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY:
return ZWaveBinarySensor(values, None)
return None
class ZWaveBinarySensor(BinarySensorDevice, zwave.ZWaveDeviceEntity):
"""Representation of a binary sensor within Z-Wave."""
def __init__(self, value, sensor_class):
def __init__(self, values, device_class):
"""Initialize the sensor."""
self._sensor_type = sensor_class
zwave.ZWaveDeviceEntity.__init__(self, value, DOMAIN)
zwave.ZWaveDeviceEntity.__init__(self, values, DOMAIN)
self._sensor_type = device_class
self._state = self.values.primary.data
def update_properties(self):
"""Callback on data changes for node values."""
self._state = self.values.primary.data
@property
def is_on(self):
"""Return True if the binary sensor is on."""
return self._value.data
return self._state
@property
def sensor_class(self):
"""Return the class of this sensor, from SENSOR_CLASSES."""
def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return self._sensor_type
@property
def should_poll(self):
"""No polling needed."""
return False
class ZWaveTriggerSensor(ZWaveBinarySensor):
"""Representation of a stateless sensor within Z-Wave."""
def __init__(self, value, sensor_class, hass, re_arm_sec=60):
def __init__(self, values, device_class, re_arm_sec=60):
"""Initialize the sensor."""
super(ZWaveTriggerSensor, self).__init__(value, sensor_class)
self._hass = hass
super(ZWaveTriggerSensor, self).__init__(values, device_class)
self.re_arm_sec = re_arm_sec
self.invalidate_after = None
def update_properties(self):
"""Called when a value for this entity's node has changed."""
self._state = self.values.primary.data
# only allow this value to be true for re_arm secs
if not self.hass:
return
self.invalidate_after = dt_util.utcnow() + datetime.timedelta(
seconds=self.re_arm_sec)
# If it's active make sure that we set the timeout tracker
if value.data:
track_point_in_time(
self._hass, self.async_update_ha_state,
self.invalidate_after)
def value_changed(self, value):
"""Called when a value for this entity's node has changed."""
if self._value.value_id == value.value_id:
self.schedule_update_ha_state()
if value.data:
# only allow this value to be true for re_arm secs
self.invalidate_after = dt_util.utcnow() + datetime.timedelta(
seconds=self.re_arm_sec)
track_point_in_time(
self._hass, self.async_update_ha_state,
self.invalidate_after)
track_point_in_time(
self.hass, self.async_update_ha_state,
self.invalidate_after)
@property
def is_on(self):
"""Return True if movement has happened within the rearm time."""
return self._value.data and \
return self._state and \
(self.invalidate_after is None or
self.invalidate_after > dt_util.utcnow())

View File

@@ -0,0 +1,87 @@
"""
Support for Blink Home Camera System.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/blink/
"""
import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (CONF_USERNAME,
CONF_PASSWORD,
ATTR_FRIENDLY_NAME,
ATTR_ARMED)
from homeassistant.helpers import discovery
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'blink'
REQUIREMENTS = ['blinkpy==0.5.2']
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string
})
}, extra=vol.ALLOW_EXTRA)
ARM_SYSTEM_SCHEMA = vol.Schema({
vol.Optional(ATTR_ARMED): cv.boolean
})
ARM_CAMERA_SCHEMA = vol.Schema({
vol.Required(ATTR_FRIENDLY_NAME): cv.string,
vol.Optional(ATTR_ARMED): cv.boolean
})
SNAP_PICTURE_SCHEMA = vol.Schema({
vol.Required(ATTR_FRIENDLY_NAME): cv.string
})
class BlinkSystem(object):
"""Blink System class."""
def __init__(self, config_info):
"""Initialize the system."""
import blinkpy
self.blink = blinkpy.Blink(username=config_info[DOMAIN][CONF_USERNAME],
password=config_info[DOMAIN][CONF_PASSWORD])
self.blink.setup_system()
def setup(hass, config):
"""Setup Blink System."""
hass.data[DOMAIN] = BlinkSystem(config)
discovery.load_platform(hass, 'camera', DOMAIN, {}, config)
discovery.load_platform(hass, 'sensor', DOMAIN, {}, config)
discovery.load_platform(hass, 'binary_sensor', DOMAIN, {}, config)
def snap_picture(call):
"""Take a picture."""
cameras = hass.data[DOMAIN].blink.cameras
name = call.data.get(ATTR_FRIENDLY_NAME, '')
if name in cameras:
cameras[name].snap_picture()
def arm_camera(call):
"""Arm a camera."""
cameras = hass.data[DOMAIN].blink.cameras
name = call.data.get(ATTR_FRIENDLY_NAME, '')
value = call.data.get(ATTR_ARMED, True)
if name in cameras:
cameras[name].set_motion_detect(value)
def arm_system(call):
"""Arm the system."""
value = call.data.get(ATTR_ARMED, True)
hass.data[DOMAIN].blink.arm = value
hass.data[DOMAIN].blink.refresh()
hass.services.register(DOMAIN, 'snap_picture', snap_picture,
schema=SNAP_PICTURE_SCHEMA)
hass.services.register(DOMAIN, 'arm_camera', arm_camera,
schema=ARM_CAMERA_SCHEMA)
hass.services.register(DOMAIN, 'arm_system', arm_system,
schema=ARM_SYSTEM_SCHEMA)
return True

View File

@@ -3,8 +3,8 @@ Support for Google Calendar event device sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/calendar/
"""
import asyncio
import logging
from datetime import timedelta
@@ -27,13 +27,13 @@ DOMAIN = 'calendar'
ENTITY_ID_FORMAT = DOMAIN + '.{}'
def setup(hass, config):
@asyncio.coroutine
def async_setup(hass, config):
"""Track states and offer events for calendars."""
component = EntityComponent(
logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL, DOMAIN)
component.setup(config)
yield from component.async_setup(config)
return True
@@ -155,7 +155,7 @@ class CalendarEventDevice(Entity):
start = _get_date(self.data.event['start'])
end = _get_date(self.data.event['end'])
summary = self.data.event['summary']
summary = self.data.event.get('summary', '')
# check if we have an offset tag in the message
# time is HH:MM or MM

View File

@@ -66,7 +66,7 @@ class GoogleCalendarData(object):
"""Get the latest data."""
service = self.calendar_service.get()
params = dict(DEFAULT_GOOGLE_SEARCH_PARAMS)
params['timeMin'] = dt.start_of_local_day().isoformat('T')
params['timeMin'] = dt.now().isoformat('T')
params['calendarId'] = self.calendar_id
if self.search:
params['q'] = self.search

View File

@@ -0,0 +1,81 @@
"""
Support for Blink system camera.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.blink/
"""
import logging
from datetime import timedelta
import requests
from homeassistant.components.blink import DOMAIN
from homeassistant.components.camera import Camera
from homeassistant.util import Throttle
DEPENDENCIES = ['blink']
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=90)
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup a Blink Camera."""
if discovery_info is None:
return
data = hass.data[DOMAIN].blink
devs = list()
for name in data.cameras:
devs.append(BlinkCamera(hass, config, data, name))
add_devices(devs)
class BlinkCamera(Camera):
"""An implementation of a Blink Camera."""
def __init__(self, hass, config, data, name):
"""Initialize a camera."""
super().__init__()
self.data = data
self.hass = hass
self._name = name
self.notifications = self.data.cameras[self._name].notifications
self.response = None
_LOGGER.info("Initialized blink camera %s", self._name)
@property
def name(self):
"""A camera name."""
return self._name
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def request_image(self):
"""An image request from Blink servers."""
_LOGGER.info("Requesting new image from blink servers")
image_url = self.check_for_motion()
header = self.data.cameras[self._name].header
self.response = requests.get(image_url, headers=header, stream=True)
def check_for_motion(self):
"""A method to check if motion has been detected since last update."""
self.data.refresh()
notifs = self.data.cameras[self._name].notifications
if notifs > self.notifications:
# We detected motion at some point
self.data.last_motion()
self.notifications = notifs
# returning motion image currently not working
# return self.data.cameras[self._name].motion['image']
elif notifs < self.notifications:
self.notifications = notifs
return self.data.camera_thumbs[self._name]
def camera_image(self):
"""Return a still image reponse from the camera."""
self.request_image()
return self.response.content

View File

@@ -34,7 +34,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup a FFmpeg Camera."""
if not hass.data[DATA_FFMPEG].async_run_test(config.get(CONF_INPUT)):
return
yield from async_add_devices([FFmpegCamera(hass, config)])
async_add_devices([FFmpegCamera(hass, config)])
class FFmpegCamera(Camera):

View File

@@ -47,15 +47,21 @@ class FoscamCamera(Camera):
port = device_info.get(CONF_PORT)
self._base_url = 'http://{}:{}/'.format(ip_address, port)
uri_template = self._base_url \
+ 'cgi-bin/CGIProxy.fcgi?' \
+ 'cmd=snapPicture2&usr={}&pwd={}'
self._username = device_info.get(CONF_USERNAME)
self._password = device_info.get(CONF_PASSWORD)
self._snap_picture_url = self._base_url \
+ 'cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=' \
+ self._username + '&pwd=' + self._password
self._snap_picture_url = uri_template.format(
self._username,
self._password
)
self._name = device_info.get(CONF_NAME)
_LOGGER.info('Using the following URL for %s: %s',
self._name, self._snap_picture_url)
self._name, uri_template.format('***', '***'))
def camera_image(self):
"""Return a still image reponse from the camera."""

View File

@@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup a generic IP Camera."""
yield from async_add_devices([GenericCamera(hass, config)])
async_add_devices([GenericCamera(hass, config)])
class GenericCamera(Camera):
@@ -118,12 +118,13 @@ class GenericCamera(Camera):
_LOGGER.error('Timeout getting camera image')
return self._last_image
except (aiohttp.errors.ClientError,
aiohttp.errors.ClientDisconnectedError) as err:
aiohttp.errors.DisconnectedError,
aiohttp.errors.HttpProcessingError) as err:
_LOGGER.error('Error getting new camera image: %s', err)
return self._last_image
finally:
if response is not None:
self.hass.async_add_job(response.release())
yield from response.release()
self._last_url = url
return self._last_image

View File

@@ -20,7 +20,7 @@ CONF_FILE_PATH = 'file_path'
DEFAULT_NAME = 'Local File'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_FILE_PATH): cv.isfile,
vol.Required(CONF_FILE_PATH): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string
})
@@ -31,8 +31,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# check filepath given is readable
if not os.access(file_path, os.R_OK):
_LOGGER.error("file path is not readable")
return False
_LOGGER.warning("Could not read camera %s image from file: %s",
config[CONF_NAME], file_path)
add_devices([LocalFile(config[CONF_NAME], file_path)])
@@ -49,8 +49,12 @@ class LocalFile(Camera):
def camera_image(self):
"""Return image response."""
with open(self._file_path, 'rb') as file:
return file.read()
try:
with open(self._file_path, 'rb') as file:
return file.read()
except FileNotFoundError:
_LOGGER.warning("Could not read camera %s image from file: %s",
self._name, self._file_path)
@property
def name(self):

View File

@@ -45,7 +45,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup a MJPEG IP Camera."""
yield from async_add_devices([MjpegCamera(hass, config)])
if discovery_info:
config = PLATFORM_SCHEMA(discovery_info)
async_add_devices([MjpegCamera(hass, config)])
def extract_image_from_mjpeg(stream):

View File

@@ -14,7 +14,7 @@ import async_timeout
from homeassistant.const import (
CONF_NAME, CONF_USERNAME, CONF_PASSWORD,
CONF_URL, CONF_WHITELIST, CONF_VERIFY_SSL)
CONF_URL, CONF_WHITELIST, CONF_VERIFY_SSL, CONF_TIMEOUT)
from homeassistant.components.camera import (
Camera, PLATFORM_SCHEMA)
from homeassistant.helpers.aiohttp_client import (
@@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'Synology Camera'
DEFAULT_STREAM_ID = '0'
TIMEOUT = 5
DEFAULT_TIMEOUT = 5
CONF_CAMERA_NAME = 'camera_name'
CONF_STREAM_ID = 'stream_id'
@@ -51,6 +51,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_URL): cv.string,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
vol.Optional(CONF_WHITELIST, default=[]): cv.ensure_list,
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
})
@@ -60,6 +61,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup a Synology IP Camera."""
verify_ssl = config.get(CONF_VERIFY_SSL)
timeout = config.get(CONF_TIMEOUT)
websession_init = async_get_clientsession(hass, verify_ssl)
# Determine API to use for authentication
@@ -74,7 +76,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
}
query_req = None
try:
with async_timeout.timeout(TIMEOUT, loop=hass.loop):
with async_timeout.timeout(timeout, loop=hass.loop):
query_req = yield from websession_init.get(
syno_api_url,
params=query_payload
@@ -103,7 +105,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
websession_init,
config.get(CONF_USERNAME),
config.get(CONF_PASSWORD),
syno_auth_url
syno_auth_url,
timeout
)
# init websession
@@ -120,7 +123,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
'version': '1'
}
try:
with async_timeout.timeout(TIMEOUT, loop=hass.loop):
with async_timeout.timeout(timeout, loop=hass.loop):
camera_req = yield from websession.get(
syno_camera_url,
params=camera_payload
@@ -149,15 +152,16 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
snapshot_path,
streaming_path,
camera_path,
auth_path
auth_path,
timeout
)
devices.append(device)
yield from async_add_devices(devices)
async_add_devices(devices)
@asyncio.coroutine
def get_session_id(hass, websession, username, password, login_url):
def get_session_id(hass, websession, username, password, login_url, timeout):
"""Get a session id."""
auth_payload = {
'api': AUTH_API,
@@ -170,7 +174,7 @@ def get_session_id(hass, websession, username, password, login_url):
}
auth_req = None
try:
with async_timeout.timeout(TIMEOUT, loop=hass.loop):
with async_timeout.timeout(timeout, loop=hass.loop):
auth_req = yield from websession.get(
login_url,
params=auth_payload
@@ -192,7 +196,7 @@ class SynologyCamera(Camera):
def __init__(self, hass, websession, config, camera_id,
camera_name, snapshot_path, streaming_path, camera_path,
auth_path):
auth_path, timeout):
"""Initialize a Synology Surveillance Station camera."""
super().__init__()
self.hass = hass
@@ -206,6 +210,7 @@ class SynologyCamera(Camera):
self._streaming_path = streaming_path
self._camera_path = camera_path
self._auth_path = auth_path
self._timeout = timeout
def camera_image(self):
"""Return bytes of camera image."""
@@ -225,7 +230,7 @@ class SynologyCamera(Camera):
'cameraId': self._camera_id
}
try:
with async_timeout.timeout(TIMEOUT, loop=self.hass.loop):
with async_timeout.timeout(self._timeout, loop=self.hass.loop):
response = yield from self._websession.get(
image_url,
params=image_payload

View File

@@ -0,0 +1,114 @@
"""
Support for ZoneMinder camera streaming.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.zoneminder/
"""
import asyncio
import logging
from urllib.parse import urljoin, urlencode
from homeassistant.const import CONF_NAME
from homeassistant.components.camera.mjpeg import (
CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera)
import homeassistant.components.zoneminder as zoneminder
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['zoneminder']
DOMAIN = 'zoneminder'
# From ZoneMinder's web/includes/config.php.in
ZM_STATE_ALARM = "2"
def _get_image_url(hass, monitor, mode):
zm_data = hass.data[DOMAIN]
query = urlencode({
'mode': mode,
'buffer': monitor['StreamReplayBuffer'],
'monitor': monitor['Id'],
})
url = '{zms_url}?{query}'.format(
zms_url=urljoin(zm_data['server_origin'], zm_data['path_zms']),
query=query,
)
_LOGGER.debug('Monitor %s %s URL (without auth): %s',
monitor['Id'], mode, url)
if not zm_data['username']:
return url
url += '&user={:s}'.format(zm_data['username'])
if not zm_data['password']:
return url
return url + '&pass={:s}'.format(zm_data['password'])
@asyncio.coroutine
# pylint: disable=unused-argument
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup ZoneMinder cameras."""
cameras = []
monitors = zoneminder.get_state('api/monitors.json')
if not monitors:
_LOGGER.warning('Could not fetch monitors from ZoneMinder')
return
for i in monitors['monitors']:
monitor = i['Monitor']
if monitor['Function'] == 'None':
_LOGGER.info('Skipping camera %s', monitor['Id'])
continue
_LOGGER.info('Initializing camera %s', monitor['Id'])
device_info = {
CONF_NAME: monitor['Name'],
CONF_MJPEG_URL: _get_image_url(hass, monitor, 'jpeg'),
CONF_STILL_IMAGE_URL: _get_image_url(hass, monitor, 'single')
}
cameras.append(ZoneMinderCamera(hass, device_info, monitor))
if not cameras:
_LOGGER.warning('No active cameras found')
return
async_add_devices(cameras)
class ZoneMinderCamera(MjpegCamera):
"""Representation of a ZoneMinder Monitor Stream."""
def __init__(self, hass, device_info, monitor):
"""Initialize as a subclass of MjpegCamera."""
super().__init__(hass, device_info)
self._monitor_id = int(monitor['Id'])
self._is_recording = None
@property
def should_poll(self):
"""Update the recording state periodically."""
return True
def update(self):
"""Update our recording state from the ZM API."""
_LOGGER.debug('Updating camera state for monitor %i', self._monitor_id)
status_response = zoneminder.get_state(
'api/monitors/alarm/id:%i/command:status.json' % self._monitor_id
)
if not status_response:
_LOGGER.warning('Could not get status for monitor %i',
self._monitor_id)
return
self._is_recording = status_response['status'] == ZM_STATE_ALARM
@property
def is_recording(self):
"""Return whether the monitor is in alarm mode."""
return self._is_recording

View File

@@ -122,8 +122,6 @@ def set_away_mode(hass, away_mode, entity_id=None):
if entity_id:
data[ATTR_ENTITY_ID] = entity_id
_LOGGER.warning(
'This service has been deprecated; use climate.set_hold_mode')
hass.services.call(DOMAIN, SERVICE_SET_AWAY_MODE, data)
@@ -226,7 +224,7 @@ def async_setup(hass, config):
if not climate.should_poll:
continue
update_coro = hass.loop.create_task(
update_coro = hass.async_add_job(
climate.async_update_ha_state(True))
if hasattr(climate, 'async_update'):
update_tasks.append(update_coro)
@@ -243,14 +241,6 @@ def async_setup(hass, config):
away_mode = service.data.get(ATTR_AWAY_MODE)
if away_mode is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_AWAY_MODE, ATTR_AWAY_MODE)
return
_LOGGER.warning(
'This service has been deprecated; use climate.set_hold_mode')
for climate in target_climate:
if away_mode:
yield from climate.async_turn_away_mode_on()
@@ -288,12 +278,6 @@ def async_setup(hass, config):
aux_heat = service.data.get(ATTR_AUX_HEAT)
if aux_heat is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_AUX_HEAT, ATTR_AUX_HEAT)
return
for climate in target_climate:
if aux_heat:
yield from climate.async_turn_aux_heat_on()
@@ -340,12 +324,6 @@ def async_setup(hass, config):
humidity = service.data.get(ATTR_HUMIDITY)
if humidity is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_HUMIDITY, ATTR_HUMIDITY)
return
for climate in target_climate:
yield from climate.async_set_humidity(humidity)
@@ -363,12 +341,6 @@ def async_setup(hass, config):
fan = service.data.get(ATTR_FAN_MODE)
if fan is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_FAN_MODE, ATTR_FAN_MODE)
return
for climate in target_climate:
yield from climate.async_set_fan_mode(fan)
@@ -386,12 +358,6 @@ def async_setup(hass, config):
operation_mode = service.data.get(ATTR_OPERATION_MODE)
if operation_mode is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_OPERATION_MODE, ATTR_OPERATION_MODE)
return
for climate in target_climate:
yield from climate.async_set_operation_mode(operation_mode)
@@ -409,12 +375,6 @@ def async_setup(hass, config):
swing_mode = service.data.get(ATTR_SWING_MODE)
if swing_mode is None:
_LOGGER.error(
"Received call to %s without attribute %s",
SERVICE_SET_SWING_MODE, ATTR_SWING_MODE)
return
for climate in target_climate:
yield from climate.async_set_swing_mode(swing_mode)

View File

@@ -135,27 +135,27 @@ class DemoClimate(ClimateDevice):
kwargs.get(ATTR_TARGET_TEMP_LOW) is not None:
self._target_temperature_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
self._target_temperature_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
self.update_ha_state()
self.schedule_update_ha_state()
def set_humidity(self, humidity):
"""Set new target temperature."""
self._target_humidity = humidity
self.update_ha_state()
self.schedule_update_ha_state()
def set_swing_mode(self, swing_mode):
"""Set new target temperature."""
self._current_swing_mode = swing_mode
self.update_ha_state()
self.schedule_update_ha_state()
def set_fan_mode(self, fan):
"""Set new target temperature."""
self._current_fan_mode = fan
self.update_ha_state()
self.schedule_update_ha_state()
def set_operation_mode(self, operation_mode):
"""Set new target temperature."""
self._current_operation = operation_mode
self.update_ha_state()
self.schedule_update_ha_state()
@property
def current_swing_mode(self):
@@ -170,24 +170,24 @@ class DemoClimate(ClimateDevice):
def turn_away_mode_on(self):
"""Turn away mode on."""
self._away = True
self.update_ha_state()
self.schedule_update_ha_state()
def turn_away_mode_off(self):
"""Turn away mode off."""
self._away = False
self.update_ha_state()
self.schedule_update_ha_state()
def set_hold_mode(self, hold):
"""Update hold mode on."""
self._hold = hold
self.update_ha_state()
self.schedule_update_ha_state()
def turn_aux_heat_on(self):
"""Turn away auxillary heater on."""
self._aux = True
self.update_ha_state()
self.schedule_update_ha_state()
def turn_aux_heat_off(self):
"""Turn auxillary heater off."""
self._aux = False
self.update_ha_state()
self.schedule_update_ha_state()

View File

@@ -25,6 +25,8 @@ ATTR_FAN_MIN_ON_TIME = 'fan_min_on_time'
ATTR_RESUME_ALL = 'resume_all'
DEFAULT_RESUME_ALL = False
TEMPERATURE_HOLD = 'temp'
VACATION_HOLD = 'vacation'
DEPENDENCIES = ['ecobee']
@@ -69,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
for thermostat in target_thermostats:
thermostat.set_fan_min_on_time(str(fan_min_on_time))
thermostat.update_ha_state(True)
thermostat.schedule_update_ha_state(True)
def resume_program_set_service(service):
"""Resume the program on the target thermostats."""
@@ -85,7 +87,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
for thermostat in target_thermostats:
thermostat.resume_program(resume_all)
thermostat.update_ha_state(True)
thermostat.schedule_update_ha_state(True)
descriptions = load_yaml_config_file(
path.join(path.dirname(__file__), 'services.yaml'))
@@ -112,6 +114,8 @@ class Thermostat(ClimateDevice):
self.thermostat_index)
self._name = self.thermostat['name']
self.hold_temp = hold_temp
self.vacation = None
self._climate_list = self.climate_list
self._operation_list = ['auto', 'auxHeatOnly', 'cool',
'heat', 'off']
self.update_without_throttle = False
@@ -186,15 +190,31 @@ class Thermostat(ClimateDevice):
@property
def current_hold_mode(self):
"""Return current hold mode."""
if self.is_away_mode_on:
hold = 'away'
elif self.is_home_mode_on:
hold = 'home'
elif self.is_temp_hold_on():
hold = 'temp'
else:
hold = None
return hold
events = self.thermostat['events']
for event in events:
if event['running']:
if event['type'] == 'hold':
if event['holdClimateRef'] == 'away':
if int(event['endDate'][0:4]) - \
int(event['startDate'][0:4]) <= 1:
# a temporary hold from away climate is a hold
return 'away'
else:
# a premanent hold from away climate is away_mode
return None
elif event['holdClimateRef'] != "":
# any other hold based on climate
return event['holdClimateRef']
else:
# any hold not based on a climate is a temp hold
return TEMPERATURE_HOLD
elif event['type'].startswith('auto'):
# all auto modes are treated as holds
return event['type'][4:].lower()
elif event['type'] == 'vacation':
self.vacation = event['name']
return VACATION_HOLD
return None
@property
def current_operation(self):
@@ -217,8 +237,11 @@ class Thermostat(ClimateDevice):
@property
def mode(self):
"""Return current mode ie. home, away, sleep."""
return self.thermostat['program']['currentClimateRef']
"""Return current mode, as the user-visible name."""
cur = self.thermostat['program']['currentClimateRef']
climates = self.thermostat['program']['climates']
current = list(filter(lambda x: x['climateRef'] == cur, climates))
return current[0]['name']
@property
def fan_min_on_time(self):
@@ -246,68 +269,44 @@ class Thermostat(ClimateDevice):
"fan": self.fan,
"mode": self.mode,
"operation": operation,
"climate_list": self.climate_list,
"fan_min_on_time": self.fan_min_on_time
}
def is_vacation_on(self):
"""Return true if vacation mode is on."""
events = self.thermostat['events']
return any(event['type'] == 'vacation' and event['running']
for event in events)
def is_temp_hold_on(self):
"""Return true if temperature hold is on."""
events = self.thermostat['events']
return any(event['type'] == 'hold' and event['running']
for event in events)
@property
def is_away_mode_on(self):
"""Return true if away mode is on."""
events = self.thermostat['events']
return any(event['holdClimateRef'] == 'away' or
event['type'] == 'autoAway'
for event in events)
return self.current_hold_mode == 'away'
def turn_away_mode_on(self):
"""Turn away on."""
self.data.ecobee.set_climate_hold(self.thermostat_index,
"away", self.hold_preference())
self.update_without_throttle = True
self.set_hold_mode('away')
def turn_away_mode_off(self):
"""Turn away off."""
self.set_hold_mode(None)
@property
def is_home_mode_on(self):
"""Return true if home mode is on."""
events = self.thermostat['events']
return any(event['holdClimateRef'] == 'home' or
event['type'] == 'autoHome'
for event in events)
def turn_home_mode_on(self):
"""Turn home on."""
self.data.ecobee.set_climate_hold(self.thermostat_index,
"home", self.hold_preference())
self.update_without_throttle = True
def set_hold_mode(self, hold_mode):
"""Set hold mode (away, home, temp)."""
"""Set hold mode (away, home, temp, sleep, etc.)."""
hold = self.current_hold_mode
if hold == hold_mode:
# no change, so no action required
return
elif hold_mode == 'away':
self.turn_away_mode_on()
elif hold_mode == 'home':
self.turn_home_mode_on()
elif hold_mode == 'temp':
self.set_temp_hold(int(self.current_temperature))
elif hold_mode == 'None' or hold_mode is None:
if hold == VACATION_HOLD:
self.data.ecobee.delete_vacation(self.thermostat_index,
self.vacation)
else:
self.data.ecobee.resume_program(self.thermostat_index)
else:
self.data.ecobee.resume_program(self.thermostat_index)
self.update_without_throttle = True
if hold_mode == TEMPERATURE_HOLD:
self.set_temp_hold(int(self.current_temperature))
else:
self.data.ecobee.set_climate_hold(self.thermostat_index,
hold_mode,
self.hold_preference())
self.update_without_throttle = True
def set_auto_temp_hold(self, heat_temp, cool_temp):
"""Set temperature hold in auto mode."""
@@ -378,17 +377,14 @@ class Thermostat(ClimateDevice):
default = self.thermostat['settings']['holdAction']
if default == 'nextTransition':
return default
elif default == 'indefinite':
return default
# add further conditions if other hold durations should be
# supported; note that this should not include 'indefinite'
# as an indefinite away hold is interpreted as away_mode
else:
return 'nextTransition'
# Sleep mode isn't used in UI yet:
# def turn_sleep_mode_on(self):
# """ Turns sleep mode on. """
# self.data.ecobee.set_climate_hold(self.thermostat_index, "sleep")
# def turn_sleep_mode_off(self):
# """ Turns sleep mode off. """
# self.data.ecobee.resume_program(self.thermostat_index)
@property
def climate_list(self):
"""Return the list of climates currently available."""
climates = self.thermostat['program']['climates']
return list(map((lambda x: x['name']), climates))

View File

@@ -10,14 +10,14 @@ import voluptuous as vol
from homeassistant.components.climate import (
ClimateDevice, PLATFORM_SCHEMA, PRECISION_HALVES,
STATE_UNKNOWN, STATE_AUTO, STATE_ON, STATE_OFF,
STATE_AUTO, STATE_ON, STATE_OFF,
)
from homeassistant.const import (
CONF_MAC, TEMP_CELSIUS, CONF_DEVICES, ATTR_TEMPERATURE)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['python-eq3bt==0.1.4']
REQUIREMENTS = ['python-eq3bt==0.1.5']
_LOGGER = logging.getLogger(__name__)
@@ -61,15 +61,12 @@ class EQ3BTSmartThermostat(ClimateDevice):
# we want to avoid name clash with this module..
import eq3bt as eq3
self.modes = {None: STATE_UNKNOWN, # When not yet connected.
eq3.Mode.Unknown: STATE_UNKNOWN,
eq3.Mode.Auto: STATE_AUTO,
# away handled separately, here just for reverse mapping
eq3.Mode.Away: STATE_AWAY,
self.modes = {eq3.Mode.Open: STATE_ON,
eq3.Mode.Closed: STATE_OFF,
eq3.Mode.Open: STATE_ON,
eq3.Mode.Auto: STATE_AUTO,
eq3.Mode.Manual: STATE_MANUAL,
eq3.Mode.Boost: STATE_BOOST}
eq3.Mode.Boost: STATE_BOOST,
eq3.Mode.Away: STATE_AWAY}
self.reverse_modes = {v: k for k, v in self.modes.items()}
@@ -79,7 +76,7 @@ class EQ3BTSmartThermostat(ClimateDevice):
@property
def available(self) -> bool:
"""Return if thermostat is available."""
return self.current_operation != STATE_UNKNOWN
return self.current_operation is not None
@property
def name(self):
@@ -116,6 +113,8 @@ class EQ3BTSmartThermostat(ClimateDevice):
@property
def current_operation(self):
"""Current mode."""
if self._thermostat.mode < 0:
return None
return self.modes[self._thermostat.mode]
@property

View File

@@ -4,17 +4,20 @@ Adds support for generic thermostat units.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.generic_thermostat/
"""
import asyncio
import logging
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.components import switch
from homeassistant.components.climate import (
STATE_HEAT, STATE_COOL, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA)
from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE)
from homeassistant.helpers import condition
from homeassistant.helpers.event import track_state_change
from homeassistant.helpers.event import (
async_track_state_change, async_track_time_interval)
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
@@ -33,6 +36,7 @@ CONF_TARGET_TEMP = 'target_temp'
CONF_AC_MODE = 'ac_mode'
CONF_MIN_DUR = 'min_cycle_duration'
CONF_TOLERANCE = 'tolerance'
CONF_KEEP_ALIVE = 'keep_alive'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@@ -45,10 +49,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TOLERANCE, default=DEFAULT_TOLERANCE): vol.Coerce(float),
vol.Optional(CONF_TARGET_TEMP): vol.Coerce(float),
vol.Optional(CONF_KEEP_ALIVE): vol.All(
cv.time_period, cv.positive_timedelta),
})
def setup_platform(hass, config, add_devices, discovery_info=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup the generic thermostat."""
name = config.get(CONF_NAME)
heater_entity_id = config.get(CONF_HEATER)
@@ -59,10 +66,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
ac_mode = config.get(CONF_AC_MODE)
min_cycle_duration = config.get(CONF_MIN_DUR)
tolerance = config.get(CONF_TOLERANCE)
keep_alive = config.get(CONF_KEEP_ALIVE)
add_devices([GenericThermostat(
async_add_devices([GenericThermostat(
hass, name, heater_entity_id, sensor_entity_id, min_temp, max_temp,
target_temp, ac_mode, min_cycle_duration, tolerance)])
target_temp, ac_mode, min_cycle_duration, tolerance, keep_alive)])
class GenericThermostat(ClimateDevice):
@@ -70,7 +78,7 @@ class GenericThermostat(ClimateDevice):
def __init__(self, hass, name, heater_entity_id, sensor_entity_id,
min_temp, max_temp, target_temp, ac_mode, min_cycle_duration,
tolerance):
tolerance, keep_alive):
"""Initialize the thermostat."""
self.hass = hass
self._name = name
@@ -78,6 +86,7 @@ class GenericThermostat(ClimateDevice):
self.ac_mode = ac_mode
self.min_cycle_duration = min_cycle_duration
self._tolerance = tolerance
self._keep_alive = keep_alive
self._active = False
self._cur_temp = None
@@ -86,12 +95,18 @@ class GenericThermostat(ClimateDevice):
self._target_temp = target_temp
self._unit = hass.config.units.temperature_unit
track_state_change(hass, sensor_entity_id, self._sensor_changed)
track_state_change(hass, heater_entity_id, self._switch_changed)
async_track_state_change(
hass, sensor_entity_id, self._async_sensor_changed)
async_track_state_change(
hass, heater_entity_id, self._async_switch_changed)
if self._keep_alive:
async_track_time_interval(
hass, self._async_keep_alive, self._keep_alive)
sensor_state = hass.states.get(sensor_entity_id)
if sensor_state:
self._update_temp(sensor_state)
self._async_update_temp(sensor_state)
@property
def should_poll(self):
@@ -128,14 +143,15 @@ class GenericThermostat(ClimateDevice):
"""Return the temperature we try to reach."""
return self._target_temp
def set_temperature(self, **kwargs):
@asyncio.coroutine
def async_set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
self._target_temp = temperature
self._control_heating()
self.schedule_update_ha_state()
self._async_control_heating()
yield from self.async_update_ha_state()
@property
def min_temp(self):
@@ -157,22 +173,33 @@ class GenericThermostat(ClimateDevice):
# Get default temp from super class
return ClimateDevice.max_temp.fget(self)
def _sensor_changed(self, entity_id, old_state, new_state):
@asyncio.coroutine
def _async_sensor_changed(self, entity_id, old_state, new_state):
"""Called when temperature changes."""
if new_state is None:
return
self._update_temp(new_state)
self._control_heating()
self.schedule_update_ha_state()
self._async_update_temp(new_state)
self._async_control_heating()
yield from self.async_update_ha_state()
def _switch_changed(self, entity_id, old_state, new_state):
@callback
def _async_switch_changed(self, entity_id, old_state, new_state):
"""Called when heater switch changes state."""
if new_state is None:
return
self.schedule_update_ha_state()
self.hass.async_add_job(self.async_update_ha_state())
def _update_temp(self, state):
@callback
def _async_keep_alive(self, time):
"""Called at constant intervals for keep-alive purposes."""
if self.current_operation in [STATE_COOL, STATE_HEAT]:
switch.async_turn_on(self.hass, self.heater_entity_id)
else:
switch.async_turn_off(self.hass, self.heater_entity_id)
@callback
def _async_update_temp(self, state):
"""Update thermostat with latest state from sensor."""
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
@@ -182,7 +209,8 @@ class GenericThermostat(ClimateDevice):
except ValueError as ex:
_LOGGER.error('Unable to update from sensor: %s', ex)
def _control_heating(self):
@callback
def _async_control_heating(self):
"""Check if we need to turn heating on or off."""
if not self._active and None not in (self._cur_temp,
self._target_temp):
@@ -198,9 +226,9 @@ class GenericThermostat(ClimateDevice):
current_state = STATE_ON
else:
current_state = STATE_OFF
long_enough = condition.state(self.hass, self.heater_entity_id,
current_state,
self.min_cycle_duration)
long_enough = condition.state(
self.hass, self.heater_entity_id, current_state,
self.min_cycle_duration)
if not long_enough:
return
@@ -210,12 +238,12 @@ class GenericThermostat(ClimateDevice):
too_cold = self._target_temp - self._cur_temp > self._tolerance
if too_cold:
_LOGGER.info('Turning off AC %s', self.heater_entity_id)
switch.turn_off(self.hass, self.heater_entity_id)
switch.async_turn_off(self.hass, self.heater_entity_id)
else:
too_hot = self._cur_temp - self._target_temp > self._tolerance
if too_hot:
_LOGGER.info('Turning on AC %s', self.heater_entity_id)
switch.turn_on(self.hass, self.heater_entity_id)
switch.async_turn_on(self.hass, self.heater_entity_id)
else:
is_heating = self._is_device_active
if is_heating:
@@ -223,12 +251,12 @@ class GenericThermostat(ClimateDevice):
if too_hot:
_LOGGER.info('Turning off heater %s',
self.heater_entity_id)
switch.turn_off(self.hass, self.heater_entity_id)
switch.async_turn_off(self.hass, self.heater_entity_id)
else:
too_cold = self._target_temp - self._cur_temp > self._tolerance
if too_cold:
_LOGGER.info('Turning on heater %s', self.heater_entity_id)
switch.turn_on(self.hass, self.heater_entity_id)
switch.async_turn_on(self.hass, self.heater_entity_id)
@property
def _is_device_active(self):

View File

@@ -6,13 +6,14 @@ https://home-assistant.io/components/climate.homematic/
"""
import logging
from homeassistant.components.climate import ClimateDevice, STATE_AUTO
from homeassistant.components.homematic import HMDevice
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
from homeassistant.util.temperature import convert
from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN, ATTR_TEMPERATURE
from homeassistant.loader import get_component
DEPENDENCIES = ['homematic']
_LOGGER = logging.getLogger(__name__)
STATE_MANUAL = "manual"
STATE_BOOST = "boost"
@@ -22,21 +23,31 @@ HM_STATE_MAP = {
"BOOST_MODE": STATE_BOOST,
}
_LOGGER = logging.getLogger(__name__)
HM_TEMP_MAP = [
'ACTUAL_TEMPERATURE',
'TEMPERATURE',
]
HM_HUMI_MAP = [
'ACTUAL_HUMIDITY',
'HUMIDITY',
]
HM_CONTROL_MODE = 'CONTROL_MODE'
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Homematic thermostat platform."""
if discovery_info is None:
return
homematic = get_component("homematic")
return homematic.setup_hmdevice_discovery_helper(
hass,
HMThermostat,
discovery_info,
add_callback_devices
)
devices = []
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
new_device = HMThermostat(hass, config)
new_device.link_homematic()
devices.append(new_device)
add_devices(devices)
class HMThermostat(HMDevice, ClimateDevice):
@@ -50,7 +61,7 @@ class HMThermostat(HMDevice, ClimateDevice):
@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
if not self.available:
if HM_CONTROL_MODE not in self._data:
return None
# read state and search
@@ -62,8 +73,6 @@ class HMThermostat(HMDevice, ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes."""
if not self.available:
return None
op_list = []
# generate list
@@ -76,31 +85,29 @@ class HMThermostat(HMDevice, ClimateDevice):
@property
def current_humidity(self):
"""Return the current humidity."""
if not self.available:
return None
return self._data.get('ACTUAL_HUMIDITY', None)
for node in HM_HUMI_MAP:
if node in self._data:
return self._data[node]
@property
def current_temperature(self):
"""Return the current temperature."""
if not self.available:
return None
return self._data.get('ACTUAL_TEMPERATURE', None)
for node in HM_TEMP_MAP:
if node in self._data:
return self._data[node]
@property
def target_temperature(self):
"""Return the target temperature."""
if not self.available:
return None
return self._data.get('SET_TEMPERATURE', None)
return self._data.get(self._state)
def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if not self.available or temperature is None:
if temperature is None:
return None
self._hmdevice.set_temperature(temperature)
self._hmdevice.writeNodeData(self._state, float(temperature))
def set_operation_mode(self, operation_mode):
"""Set new target operation mode."""
@@ -122,10 +129,12 @@ class HMThermostat(HMDevice, ClimateDevice):
def _init_data_struct(self):
"""Generate a data dict (self._data) from the Homematic metadata."""
# Add state to data dict
self._data.update({"CONTROL_MODE": STATE_UNKNOWN,
"SET_TEMPERATURE": STATE_UNKNOWN,
"ACTUAL_TEMPERATURE": STATE_UNKNOWN})
self._state = next(iter(self._hmdevice.WRITENODE.keys()))
self._data[self._state] = STATE_UNKNOWN
# support humidity
if 'ACTUAL_HUMIDITY' in self._hmdevice.SENSORNODE:
self._data.update({'ACTUAL_HUMIDITY': STATE_UNKNOWN})
# support state
if HM_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE:
self._data[HM_CONTROL_MODE] = STATE_UNKNOWN
for node in self._hmdevice.SENSORNODE.keys():
self._data[node] = STATE_UNKNOWN

View File

@@ -6,10 +6,15 @@ https://home-assistant.io/components/climate.honeywell/
"""
import logging
import socket
import datetime
import voluptuous as vol
import requests
from homeassistant.components.climate import (ClimateDevice, PLATFORM_SCHEMA)
from homeassistant.components.climate import (ClimateDevice, PLATFORM_SCHEMA,
ATTR_FAN_MODE, ATTR_FAN_LIST,
ATTR_OPERATION_MODE,
ATTR_OPERATION_LIST)
from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS, TEMP_FAHRENHEIT,
ATTR_TEMPERATURE)
@@ -21,27 +26,35 @@ REQUIREMENTS = ['evohomeclient==0.2.5',
_LOGGER = logging.getLogger(__name__)
ATTR_FAN = 'fan'
ATTR_FANMODE = 'fanmode'
ATTR_SYSTEM_MODE = 'system_mode'
ATTR_CURRENT_OPERATION = 'equipment_output_status'
CONF_AWAY_TEMPERATURE = 'away_temperature'
CONF_COOL_AWAY_TEMPERATURE = 'away_cool_temperature'
CONF_HEAT_AWAY_TEMPERATURE = 'away_heat_temperature'
CONF_REGION = 'region'
DEFAULT_AWAY_TEMPERATURE = 16
DEFAULT_COOL_AWAY_TEMPERATURE = 30
DEFAULT_HEAT_AWAY_TEMPERATURE = 16
DEFAULT_REGION = 'eu'
REGIONS = ['eu', 'us']
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_AWAY_TEMPERATURE, default=DEFAULT_AWAY_TEMPERATURE):
vol.Coerce(float),
vol.Optional(CONF_AWAY_TEMPERATURE,
default=DEFAULT_AWAY_TEMPERATURE): vol.Coerce(float),
vol.Optional(CONF_COOL_AWAY_TEMPERATURE,
default=DEFAULT_COOL_AWAY_TEMPERATURE): vol.Coerce(float),
vol.Optional(CONF_HEAT_AWAY_TEMPERATURE,
default=DEFAULT_HEAT_AWAY_TEMPERATURE): vol.Coerce(float),
vol.Optional(CONF_REGION, default=DEFAULT_REGION): vol.In(REGIONS),
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the HoneywelL thermostat."""
"""Setup the Honeywell thermostat."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
region = config.get(CONF_REGION)
@@ -88,8 +101,11 @@ def _setup_us(username, password, config, add_devices):
dev_id = config.get('thermostat')
loc_id = config.get('location')
cool_away_temp = config.get(CONF_COOL_AWAY_TEMPERATURE)
heat_away_temp = config.get(CONF_HEAT_AWAY_TEMPERATURE)
add_devices([HoneywellUSThermostat(client, device)
add_devices([HoneywellUSThermostat(client, device, cool_away_temp,
heat_away_temp, username, password)
for location in client.locations_by_id.values()
for device in location.devices_by_id.values()
if ((not loc_id or location.locationid == loc_id) and
@@ -160,7 +176,7 @@ class RoundThermostat(ClimateDevice):
def turn_away_mode_on(self):
"""Turn away on.
Evohome does have a proprietary away mode, but it doesn't really work
Honeywell does have a proprietary away mode, but it doesn't really work
the way it should. For example: If you set a temperature manually
it doesn't get overwritten when away mode is switched on.
"""
@@ -199,10 +215,16 @@ class RoundThermostat(ClimateDevice):
class HoneywellUSThermostat(ClimateDevice):
"""Representation of a Honeywell US Thermostat."""
def __init__(self, client, device):
def __init__(self, client, device, cool_away_temp,
heat_away_temp, username, password):
"""Initialize the thermostat."""
self._client = client
self._device = device
self._cool_away_temp = cool_away_temp
self._heat_away_temp = heat_away_temp
self._away = False
self._username = username
self._password = password
@property
def is_fan_on(self):
@@ -236,7 +258,10 @@ class HoneywellUSThermostat(ClimateDevice):
@property
def current_operation(self: ClimateDevice) -> str:
"""Return current operation ie. heat, cool, idle."""
return getattr(self._device, ATTR_SYSTEM_MODE, None)
oper = getattr(self._device, ATTR_CURRENT_OPERATION, None)
if oper == "off":
oper = "idle"
return oper
def set_temperature(self, **kwargs):
"""Set target temperature."""
@@ -245,29 +270,84 @@ class HoneywellUSThermostat(ClimateDevice):
return
import somecomfort
try:
if self._device.system_mode == 'cool':
self._device.setpoint_cool = temperature
else:
self._device.setpoint_heat = temperature
# Get current mode
mode = self._device.system_mode
# Set hold if this is not the case
if getattr(self._device, "hold_{}".format(mode)) is False:
# Get next period key
next_period_key = '{}NextPeriod'.format(mode.capitalize())
# Get next period raw value
next_period = self._device.raw_ui_data.get(next_period_key)
# Get next period time
hour, minute = divmod(next_period * 15, 60)
# Set hold time
setattr(self._device,
"hold_{}".format(mode),
datetime.time(hour, minute))
# Set temperature
setattr(self._device,
"setpoint_{}".format(mode),
temperature)
except somecomfort.SomeComfortError:
_LOGGER.error('Temperature %.1f out of range', temperature)
@property
def device_state_attributes(self):
"""Return the device specific state attributes."""
return {
import somecomfort
data = {
ATTR_FAN: (self.is_fan_on and 'running' or 'idle'),
ATTR_FANMODE: self._device.fan_mode,
ATTR_SYSTEM_MODE: self._device.system_mode,
ATTR_FAN_MODE: self._device.fan_mode,
ATTR_OPERATION_MODE: self._device.system_mode,
}
data[ATTR_FAN_LIST] = somecomfort.FAN_MODES
data[ATTR_OPERATION_LIST] = somecomfort.SYSTEM_MODES
return data
@property
def is_away_mode_on(self):
"""Return true if away mode is on."""
return self._away
def turn_away_mode_on(self):
"""Turn away on."""
pass
"""Turn away on.
Somecomfort does have a proprietary away mode, but it doesn't really
work the way it should. For example: If you set a temperature manually
it doesn't get overwritten when away mode is switched on.
"""
self._away = True
import somecomfort
try:
# Get current mode
mode = self._device.system_mode
except somecomfort.SomeComfortError:
_LOGGER.error('Can not get system mode')
return
try:
# Set permanent hold
setattr(self._device,
"hold_{}".format(mode),
True)
# Set temperature
setattr(self._device,
"setpoint_{}".format(mode),
getattr(self, "_{}_away_temp".format(mode)))
except somecomfort.SomeComfortError:
_LOGGER.error('Temperature %.1f out of range',
getattr(self, "_{}_away_temp".format(mode)))
def turn_away_mode_off(self):
"""Turn away off."""
pass
self._away = False
import somecomfort
try:
# Disabling all hold modes
self._device.hold_cool = False
self._device.hold_heat = False
except somecomfort.SomeComfortError:
_LOGGER.error('Can not stop hold mode')
def set_operation_mode(self: ClimateDevice, operation_mode: str) -> None:
"""Set the system mode (Cool, Heat, etc)."""
@@ -276,4 +356,49 @@ class HoneywellUSThermostat(ClimateDevice):
def update(self):
"""Update the state."""
self._device.refresh()
import somecomfort
retries = 3
while retries > 0:
try:
self._device.refresh()
break
except (somecomfort.client.APIRateLimited, OSError,
requests.exceptions.ReadTimeout) as exp:
retries -= 1
if retries == 0:
raise exp
if not self._retry():
raise exp
_LOGGER.error("SomeComfort update failed, Retrying "
"- Error: %s", exp)
def _retry(self):
"""Recreate a new somecomfort client.
When we got an error, the best way to be sure that the next query
will succeed, is to recreate a new somecomfort client.
"""
import somecomfort
try:
self._client = somecomfort.SomeComfort(self._username,
self._password)
except somecomfort.AuthError:
_LOGGER.error('Failed to login to honeywell account %s',
self._username)
return False
except somecomfort.SomeComfortError as ex:
_LOGGER.error('Failed to initialize honeywell client: %s',
str(ex))
return False
devices = [device
for location in self._client.locations_by_id.values()
for device in location.devices_by_id.values()
if device.name == self._device.name]
if len(devices) != 1:
_LOGGER.error('Failed to find device %s', self._device.name)
return False
self._device = devices[0]
return True

View File

@@ -0,0 +1,216 @@
"""
Support for MAX! Thermostats via MAX! Cube.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/maxcube/
"""
import socket
import logging
from homeassistant.components.climate import ClimateDevice, STATE_AUTO
from homeassistant.components.maxcube import MAXCUBE_HANDLE
from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE
from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__)
STATE_MANUAL = "manual"
STATE_BOOST = "boost"
STATE_VACATION = "vacation"
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Iterate through all MAX! Devices and add thermostats to HASS."""
cube = hass.data[MAXCUBE_HANDLE].cube
# List of devices
devices = []
for device in cube.devices:
# Create device name by concatenating room name + device name
name = "%s %s" % (cube.room_by_id(device.room_id).name, device.name)
# Only add thermostats and wallthermostats
if cube.is_thermostat(device) or cube.is_wallthermostat(device):
# Add device to HASS
devices.append(MaxCubeClimate(hass, name, device.rf_address))
# Add all devices at once
if len(devices) > 0:
add_devices(devices)
class MaxCubeClimate(ClimateDevice):
"""MAX! Cube ClimateDevice."""
def __init__(self, hass, name, rf_address):
"""Initialize MAX! Cube ClimateDevice."""
self._name = name
self._unit_of_measurement = TEMP_CELSIUS
self._operation_list = [STATE_AUTO, STATE_MANUAL, STATE_BOOST,
STATE_VACATION]
self._rf_address = rf_address
self._cubehandle = hass.data[MAXCUBE_HANDLE]
@property
def should_poll(self):
"""Polling is required."""
return True
@property
def name(self):
"""Return the name of the ClimateDevice."""
return self._name
@property
def min_temp(self):
"""Return the minimum temperature."""
# Get the device we want (does not do any IO, just reads from memory)
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Map and return minimum temperature
return self.map_temperature_max_hass(device.min_temperature)
@property
def max_temp(self):
"""Return the maximum temperature."""
# Get the device we want (does not do any IO, just reads from memory)
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Map and return maximum temperature
return self.map_temperature_max_hass(device.max_temperature)
@property
def temperature_unit(self):
"""Return the unit of measurement."""
return self._unit_of_measurement
@property
def current_temperature(self):
"""Return the current temperature."""
# Get the device we want (does not do any IO, just reads from memory)
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Map and return current temperature
return self.map_temperature_max_hass(device.actual_temperature)
@property
def current_operation(self):
"""Return current operation (auto, manual, boost, vacation)."""
# Get the device we want (does not do any IO, just reads from memory)
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Mode Mapping
return self.map_mode_max_hass(device.mode)
@property
def operation_list(self):
"""List of available operation modes."""
return self._operation_list
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
# Get the device we want (does not do any IO, just reads from memory)
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Map and return target temperature
return self.map_temperature_max_hass(device.target_temperature)
def set_temperature(self, **kwargs):
"""Set new target temperatures."""
# Fail is target temperature has not been supplied as argument
if kwargs.get(ATTR_TEMPERATURE) is None:
return False
# Determine the new target temperature
target_temperature = kwargs.get(ATTR_TEMPERATURE)
# Write the target temperature to the MAX! Cube.
device = self._cubehandle.cube.device_by_rf(self._rf_address)
cube = self._cubehandle.cube
with self._cubehandle.mutex:
try:
cube.set_target_temperature(device, target_temperature)
except (socket.timeout, socket.error):
_LOGGER.error("Setting target temperature failed")
return False
def set_operation_mode(self, operation_mode):
"""Set new operation mode."""
# Get the device we want to update
device = self._cubehandle.cube.device_by_rf(self._rf_address)
# Mode Mapping
mode = self.map_mode_hass_max(operation_mode)
# Write new mode to thermostat
if mode is None:
return False
with self._cubehandle.mutex:
try:
self._cubehandle.cube.set_mode(device, mode)
except (socket.timeout, socket.error):
_LOGGER.error("Setting operation mode failed")
return False
def update(self):
"""Get latest data from MAX! Cube."""
# Update the CubeHandle
self._cubehandle.update()
@staticmethod
def map_temperature_max_hass(temperature):
"""Map Temperature from MAX! to HASS."""
if temperature is None:
return STATE_UNKNOWN
return temperature
@staticmethod
def map_mode_hass_max(operation_mode):
"""Map HASS Operation Modes to MAX! Operation Modes."""
from maxcube.device import \
MAX_DEVICE_MODE_AUTOMATIC, \
MAX_DEVICE_MODE_MANUAL, \
MAX_DEVICE_MODE_VACATION, \
MAX_DEVICE_MODE_BOOST
if operation_mode == STATE_AUTO:
mode = MAX_DEVICE_MODE_AUTOMATIC
elif operation_mode == STATE_MANUAL:
mode = MAX_DEVICE_MODE_MANUAL
elif operation_mode == STATE_VACATION:
mode = MAX_DEVICE_MODE_VACATION
elif operation_mode == STATE_BOOST:
mode = MAX_DEVICE_MODE_BOOST
else:
mode = None
return mode
@staticmethod
def map_mode_max_hass(mode):
"""Map MAX! Operation Modes to HASS Operation Modes."""
from maxcube.device import \
MAX_DEVICE_MODE_AUTOMATIC, \
MAX_DEVICE_MODE_MANUAL, \
MAX_DEVICE_MODE_VACATION, \
MAX_DEVICE_MODE_BOOST
if mode == MAX_DEVICE_MODE_AUTOMATIC:
operation_mode = STATE_AUTO
elif mode == MAX_DEVICE_MODE_MANUAL:
operation_mode = STATE_MANUAL
elif mode == MAX_DEVICE_MODE_VACATION:
operation_mode = STATE_VACATION
elif mode == MAX_DEVICE_MODE_BOOST:
operation_mode = STATE_BOOST
else:
operation_mode = None
return operation_mode

View File

@@ -135,7 +135,7 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
if self.gateway.optimistic:
# optimistically assume that switch has changed state
self._values[value_type] = value
self.update_ha_state()
self.schedule_update_ha_state()
def set_fan_mode(self, fan):
"""Set new target temperature."""
@@ -145,7 +145,7 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
if self.gateway.optimistic:
# optimistically assume that switch has changed state
self._values[set_req.V_HVAC_SPEED] = fan
self.update_ha_state()
self.schedule_update_ha_state()
def set_operation_mode(self, operation_mode):
"""Set new target temperature."""
@@ -156,7 +156,7 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
if self.gateway.optimistic:
# optimistically assume that switch has changed state
self._values[set_req.V_HVAC_FLOW_STATE] = operation_mode
self.update_ha_state()
self.schedule_update_ha_state()
def update(self):
"""Update the controller with the latest value from a sensor."""

View File

@@ -111,7 +111,6 @@ class NetatmoThermostat(ClimateDevice):
temp = None
self._data.thermostatdata.setthermpoint(mode, temp, endTimeOffset=None)
self._away = True
self.update_ha_state()
def turn_away_mode_off(self):
"""Turn away off."""
@@ -119,7 +118,6 @@ class NetatmoThermostat(ClimateDevice):
temp = None
self._data.thermostatdata.setthermpoint(mode, temp, endTimeOffset=None)
self._away = False
self.update_ha_state()
def set_temperature(self, endTimeOffset=DEFAULT_TIME_OFFSET, **kwargs):
"""Set new target temperature for 2 hours."""
@@ -131,7 +129,6 @@ class NetatmoThermostat(ClimateDevice):
mode, temperature, endTimeOffset)
self._target_temperature = temperature
self._away = False
self.update_ha_state()
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):

View File

@@ -0,0 +1,148 @@
"""
OpenEnergyMonitor Thermostat Support.
This provides a climate component for the ESP8266 based thermostat sold by
OpenEnergyMonitor.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.oem/
"""
import logging
import requests
import voluptuous as vol
# Import the device class from the component that you want to support
from homeassistant.components.climate import (
ClimateDevice, PLATFORM_SCHEMA, STATE_HEAT, STATE_IDLE, ATTR_TEMPERATURE)
from homeassistant.const import (CONF_HOST, CONF_USERNAME, CONF_PASSWORD,
CONF_PORT, TEMP_CELSIUS, CONF_NAME)
import homeassistant.helpers.config_validation as cv
# Home Assistant depends on 3rd party packages for API specific code.
REQUIREMENTS = ['oemthermostat==1.1']
_LOGGER = logging.getLogger(__name__)
# Local configs
CONF_AWAY_TEMP = 'away_temp'
# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default="Thermostat"): cv.string,
vol.Optional(CONF_PORT, default=80): cv.port,
vol.Inclusive(CONF_USERNAME, 'authentication'): cv.string,
vol.Inclusive(CONF_PASSWORD, 'authentication'): cv.string,
vol.Optional(CONF_AWAY_TEMP, default=14): vol.Coerce(float)
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup oemthermostat."""
from oemthermostat import Thermostat
# Assign configuration variables. The configuration check takes care they
# are present.
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
away_temp = config.get(CONF_AWAY_TEMP)
# If creating the class raises an exception, it failed to connect or
# something else went wrong.
try:
therm = Thermostat(host, port=port,
username=username, password=password)
except (ValueError, AssertionError, requests.RequestException):
return False
# Add devices
add_devices((ThermostatDevice(hass, therm, name, away_temp), ), True)
class ThermostatDevice(ClimateDevice):
"""Interface class for the oemthermostat module and HA."""
def __init__(self, hass, thermostat, name, away_temp):
"""Initialize the device."""
self._name = name
self.hass = hass
# Away mode stuff
self._away = False
self._away_temp = away_temp
self._prev_temp = thermostat.setpoint
self.thermostat = thermostat
# Set the thermostat mode to manual
self.thermostat.mode = 2
# set up internal state varS
self._state = None
self._temperature = None
self._setpoint = None
@property
def name(self):
"""Name of this Thermostat."""
return self._name
@property
def temperature_unit(self):
"""The unit of measurement used by the platform."""
return TEMP_CELSIUS
@property
def current_operation(self):
"""Return current operation i.e. heat, cool, idle."""
if self._state:
return STATE_HEAT
else:
return STATE_IDLE
@property
def current_temperature(self):
"""Return the current temperature."""
return self._temperature
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self._setpoint
def set_temperature(self, **kwargs):
"""Change the setpoint of the thermostat."""
# If we are setting the temp, then we don't want away mode anymore.
self.turn_away_mode_off()
temp = kwargs.get(ATTR_TEMPERATURE)
self.thermostat.setpoint = temp
@property
def is_away_mode_on(self):
"""Return true if away mode is on."""
return self._away
def turn_away_mode_on(self):
"""Turn away mode on."""
if not self._away:
self._prev_temp = self._setpoint
self.thermostat.setpoint = self._away_temp
self._away = True
def turn_away_mode_off(self):
"""Turn away mode off."""
if self._away:
self.thermostat.setpoint = self._prev_temp
self._away = False
def update(self):
"""Update local state."""
self._setpoint = self.thermostat.setpoint
self._temperature = self.thermostat.temperature
self._state = self.thermostat.state

View File

@@ -78,7 +78,7 @@ set_fan_mode:
description: Name(s) of entities to change
example: 'climate.nest'
fan:
fan_mode:
description: New value of fan mode
example: On Low

View File

@@ -0,0 +1,296 @@
"""tado component to create a climate device for each zone."""
import logging
from homeassistant.const import TEMP_CELSIUS
from homeassistant.components.climate import (
ClimateDevice)
from homeassistant.const import (
ATTR_TEMPERATURE)
from homeassistant.components.tado import (
DATA_TADO)
CONST_MODE_SMART_SCHEDULE = "SMART_SCHEDULE" # Default mytado mode
CONST_MODE_OFF = "OFF" # Switch off heating in a zone
# When we change the temperature setting, we need an overlay mode
# wait until tado changes the mode automatic
CONST_OVERLAY_TADO_MODE = "TADO_MODE"
# the user has change the temperature or mode manually
CONST_OVERLAY_MANUAL = "MANUAL"
# the temperature will be reset after a timespan
CONST_OVERLAY_TIMER = "TIMER"
OPERATION_LIST = {
CONST_OVERLAY_MANUAL: "Manual",
CONST_OVERLAY_TIMER: "Timer",
CONST_OVERLAY_TADO_MODE: "Tado mode",
CONST_MODE_SMART_SCHEDULE: "Smart schedule",
CONST_MODE_OFF: "Off"}
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the climate platform."""
# get the PyTado object from the hub component
tado = hass.data[DATA_TADO]
try:
zones = tado.get_zones()
except RuntimeError:
_LOGGER.error("Unable to get zone info from mytado")
return False
climate_devices = []
for zone in zones:
climate_devices.append(create_climate_device(tado, hass,
zone,
zone['name'],
zone['id']))
if len(climate_devices) > 0:
add_devices(climate_devices, True)
return True
else:
return False
def create_climate_device(tado, hass, zone, name, zone_id):
"""Create a climate device."""
capabilities = tado.get_capabilities(zone_id)
unit = TEMP_CELSIUS
min_temp = float(capabilities["temperatures"]["celsius"]["min"])
max_temp = float(capabilities["temperatures"]["celsius"]["max"])
ac_mode = capabilities["type"] != "HEATING"
data_id = 'zone {} {}'.format(name, zone_id)
device = TadoClimate(tado,
name, zone_id, data_id,
hass.config.units.temperature(min_temp, unit),
hass.config.units.temperature(max_temp, unit),
ac_mode)
tado.add_sensor(data_id, {
"id": zone_id,
"zone": zone,
"name": name,
"climate": device
})
return device
class TadoClimate(ClimateDevice):
"""Representation of a tado climate device."""
def __init__(self, store, zone_name, zone_id, data_id,
min_temp, max_temp, ac_mode,
tolerance=0.3):
"""Initialization of TadoClimate device."""
self._store = store
self._data_id = data_id
self.zone_name = zone_name
self.zone_id = zone_id
self.ac_mode = ac_mode
self._active = False
self._device_is_active = False
self._unit = TEMP_CELSIUS
self._cur_temp = None
self._cur_humidity = None
self._is_away = False
self._min_temp = min_temp
self._max_temp = max_temp
self._target_temp = None
self._tolerance = tolerance
self._current_operation = CONST_MODE_SMART_SCHEDULE
self._overlay_mode = CONST_MODE_SMART_SCHEDULE
@property
def name(self):
"""Return the name of the sensor."""
return self.zone_name
@property
def current_humidity(self):
"""Return the current humidity."""
return self._cur_humidity
@property
def current_temperature(self):
"""Return the sensor temperature."""
return self._cur_temp
@property
def current_operation(self):
"""Return current readable operation mode."""
return OPERATION_LIST.get(self._current_operation)
@property
def operation_list(self):
"""List of available operation modes (readable)."""
return list(OPERATION_LIST.values())
@property
def temperature_unit(self):
"""The unit of measurement used by the platform."""
return self._unit
@property
def is_away_mode_on(self):
"""Return true if away mode is on."""
return self._is_away
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self._target_temp
def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is None:
return
self._current_operation = CONST_OVERLAY_TADO_MODE
self._overlay_mode = None
self._target_temp = temperature
self._control_heating()
def set_operation_mode(self, readable_operation_mode):
"""Set new operation mode."""
operation_mode = CONST_MODE_SMART_SCHEDULE
for mode, readable in OPERATION_LIST.items():
if readable == readable_operation_mode:
operation_mode = mode
break
self._current_operation = operation_mode
self._overlay_mode = None
self._control_heating()
@property
def min_temp(self):
"""Return the minimum temperature."""
if self._min_temp:
return self._min_temp
else:
# get default temp from super class
return super().min_temp
@property
def max_temp(self):
"""Return the maximum temperature."""
if self._max_temp:
return self._max_temp
else:
# Get default temp from super class
return super().max_temp
def update(self):
"""Update the state of this climate device."""
self._store.update()
data = self._store.get_data(self._data_id)
if data is None:
_LOGGER.debug('Recieved no data for zone %s',
self.zone_name)
return
if 'sensorDataPoints' in data:
sensor_data = data['sensorDataPoints']
temperature = float(
sensor_data['insideTemperature']['celsius'])
humidity = float(
sensor_data['humidity']['percentage'])
setting = 0
# temperature setting will not exist when device is off
if 'temperature' in data['setting'] and \
data['setting']['temperature'] is not None:
setting = float(
data['setting']['temperature']['celsius'])
unit = TEMP_CELSIUS
self._cur_temp = self.hass.config.units.temperature(
temperature, unit)
self._target_temp = self.hass.config.units.temperature(
setting, unit)
self._cur_humidity = humidity
if 'tadoMode' in data:
mode = data['tadoMode']
self._is_away = mode == "AWAY"
if 'setting' in data:
power = data['setting']['power']
if power == "OFF":
self._current_operation = CONST_MODE_OFF
self._device_is_active = False
else:
self._device_is_active = True
if 'overlay' in data and data['overlay'] is not None:
overlay = True
termination = data['overlay']['termination']['type']
else:
overlay = False
termination = ""
# if you set mode manualy to off, there will be an overlay
# and a termination, but we want to see the mode "OFF"
if overlay and self._device_is_active:
# there is an overlay the device is on
self._overlay_mode = termination
self._current_operation = termination
else:
# there is no overlay, the mode will always be
# "SMART_SCHEDULE"
self._overlay_mode = CONST_MODE_SMART_SCHEDULE
self._current_operation = CONST_MODE_SMART_SCHEDULE
def _control_heating(self):
"""Send new target temperature to mytado."""
if not self._active and None not in (self._cur_temp,
self._target_temp):
self._active = True
_LOGGER.info('Obtained current and target temperature. '
'tado thermostat active.')
if not self._active or self._current_operation == self._overlay_mode:
return
if self._current_operation == CONST_MODE_SMART_SCHEDULE:
_LOGGER.info('Switching mytado.com to SCHEDULE (default) '
'for zone %s', self.zone_name)
self._store.reset_zone_overlay(self.zone_id)
self._overlay_mode = self._current_operation
return
if self._current_operation == CONST_MODE_OFF:
_LOGGER.info('Switching mytado.com to OFF for zone %s',
self.zone_name)
self._store.set_zone_overlay(self.zone_id, CONST_OVERLAY_MANUAL)
self._overlay_mode = self._current_operation
return
_LOGGER.info('Switching mytado.com to %s mode for zone %s',
self._current_operation, self.zone_name)
self._store.set_zone_overlay(self.zone_id,
self._current_operation,
self._target_temp)
self._overlay_mode = self._current_operation

View File

@@ -7,14 +7,14 @@ https://home-assistant.io/components/switch.vera/
import logging
from homeassistant.util import convert
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate import ClimateDevice, ENTITY_ID_FORMAT
from homeassistant.const import (
TEMP_FAHRENHEIT,
TEMP_CELSIUS,
ATTR_TEMPERATURE)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
DEPENDENCIES = ['vera']
@@ -37,6 +37,7 @@ class VeraThermostat(VeraDevice, ClimateDevice):
def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
@property
def current_operation(self):
@@ -84,11 +85,11 @@ class VeraThermostat(VeraDevice, ClimateDevice):
return self.vera_device.fan_cycle()
@property
def current_power_mwh(self):
"""Current power usage in mWh."""
def current_power_w(self):
"""Current power usage in W."""
power = self.vera_device.power
if power:
return convert(power, float, 0.0) * 1000
return convert(power, float, 0.0)
def update(self):
"""Called by the vera device callback to update state."""

View File

@@ -4,7 +4,7 @@ Support for Wink thermostats.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/climate.wink/
"""
from homeassistant.components.wink import WinkDevice
from homeassistant.components.wink import WinkDevice, DOMAIN
from homeassistant.components.climate import (
STATE_AUTO, STATE_COOL, STATE_HEAT, ClimateDevice,
ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW,
@@ -13,12 +13,16 @@ from homeassistant.components.climate import (
from homeassistant.const import (
TEMP_CELSIUS, STATE_ON,
STATE_OFF, STATE_UNKNOWN)
from homeassistant.loader import get_component
DEPENDENCIES = ['wink']
STATE_AUX = 'aux'
STATE_ECO = 'eco'
STATE_FAN = 'fan'
SPEED_LOWEST = 'lowest'
SPEED_LOW = 'low'
SPEED_MEDIUM = 'medium'
SPEED_HIGH = 'high'
ATTR_EXTERNAL_TEMPERATURE = "external_temperature"
ATTR_SMART_TEMPERATURE = "smart_temperature"
@@ -30,8 +34,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Wink thermostat."""
import pywink
temp_unit = hass.config.units.temperature_unit
add_devices(WinkThermostat(thermostat, hass, temp_unit)
for thermostat in pywink.get_thermostats())
for climate in pywink.get_thermostats():
_id = climate.object_id() + climate.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkThermostat(climate, hass, temp_unit)])
for climate in pywink.get_air_conditioners():
_id = climate.object_id() + climate.name()
if _id not in hass.data[DOMAIN]['unique_ids']:
add_devices([WinkAC(climate, hass, temp_unit)])
# pylint: disable=abstract-method,too-many-public-methods, too-many-branches
@@ -41,7 +51,6 @@ class WinkThermostat(WinkDevice, ClimateDevice):
def __init__(self, wink, hass, temp_unit):
"""Initialize the Wink device."""
super().__init__(wink, hass)
wink = get_component('wink')
self._config_temp_unit = temp_unit
@property
@@ -329,3 +338,131 @@ class WinkThermostat(WinkDevice, ClimateDevice):
else:
return_value = maximum
return return_value
class WinkAC(WinkDevice, ClimateDevice):
"""Representation of a Wink air conditioner."""
def __init__(self, wink, hass, temp_unit):
"""Initialize the Wink device."""
super().__init__(wink, hass)
self._config_temp_unit = temp_unit
@property
def temperature_unit(self):
"""Return the unit of measurement."""
# The Wink API always returns temp in Celsius
return TEMP_CELSIUS
@property
def device_state_attributes(self):
"""Return the optional state attributes."""
data = {}
target_temp_high = self.target_temperature_high
target_temp_low = self.target_temperature_low
if target_temp_high is not None:
data[ATTR_TARGET_TEMP_HIGH] = self._convert_for_display(
self.target_temperature_high)
if target_temp_low is not None:
data[ATTR_TARGET_TEMP_LOW] = self._convert_for_display(
self.target_temperature_low)
data["total_consumption"] = self.wink.total_consumption()
data["schedule_enabled"] = self.wink.schedule_enabled()
return data
@property
def current_temperature(self):
"""Return the current temperature."""
return self.wink.current_temperature()
@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
if not self.wink.is_on():
current_op = STATE_OFF
elif self.wink.current_mode() == 'cool_only':
current_op = STATE_COOL
elif self.wink.current_mode() == 'auto_eco':
current_op = STATE_ECO
elif self.wink.current_mode() == 'fan_only':
current_op = STATE_FAN
else:
current_op = STATE_UNKNOWN
return current_op
@property
def operation_list(self):
"""List of available operation modes."""
op_list = ['off']
modes = self.wink.modes()
if 'cool_only' in modes:
op_list.append(STATE_COOL)
if 'auto_eco' in modes:
op_list.append(STATE_ECO)
if 'fan_eco' in modes:
op_list.append(STATE_FAN)
return op_list
def set_temperature(self, **kwargs):
"""Set new target temperature."""
target_temp = kwargs.get(ATTR_TEMPERATURE)
self.wink.set_temperature(target_temp)
def set_operation_mode(self, operation_mode):
"""Set operation mode."""
if operation_mode == STATE_COOL:
self.wink.set_operation_mode('cool_only')
elif operation_mode == STATE_ECO:
self.wink.set_operation_mode('auto_eco')
elif operation_mode == STATE_OFF:
self.wink.set_operation_mode('off')
elif operation_mode == STATE_FAN:
self.wink.set_operation_mode('fan_only')
@property
def target_temperature(self):
"""Return the temperature we try to reach."""
return self.wink.current_max_set_point()
@property
def target_temperature_low(self):
"""Only supports cool."""
return None
@property
def target_temperature_high(self):
"""Only supports cool."""
return None
@property
def current_fan_mode(self):
"""Return the current fan mode."""
speed = self.wink.current_fan_speed()
if speed <= 0.3 and speed >= 0.0:
return SPEED_LOWEST
elif speed <= 0.5 and speed > 0.3:
return SPEED_LOW
elif speed <= 0.8 and speed > 0.5:
return SPEED_MEDIUM
elif speed <= 1.0 and speed > 0.8:
return SPEED_HIGH
else:
return STATE_UNKNOWN
@property
def fan_list(self):
"""List of available fan modes."""
return [SPEED_LOWEST, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def set_fan_mode(self, mode):
"""Set fan speed."""
if mode == SPEED_LOWEST:
speed = 0.3
elif mode == SPEED_LOW:
speed = 0.5
elif mode == SPEED_MEDIUM:
speed = 0.8
elif mode == SPEED_HIGH:
speed = 1.0
self.wink.set_ac_fan_speed(speed)

View File

@@ -10,7 +10,7 @@ import logging
from homeassistant.components.climate import DOMAIN
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.zwave import ZWaveDeviceEntity
from homeassistant.components import zwave
from homeassistant.components.zwave import async_setup_platform # noqa # pylint: disable=unused-import
from homeassistant.const import (
TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_TEMPERATURE)
@@ -32,29 +32,18 @@ DEVICE_MAPPINGS = {
}
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Z-Wave Climate devices."""
if discovery_info is None or zwave.NETWORK is None:
_LOGGER.debug("No discovery_info=%s or no NETWORK=%s",
discovery_info, zwave.NETWORK)
return
def get_device(hass, values, **kwargs):
"""Create zwave entity device."""
temp_unit = hass.config.units.temperature_unit
node = zwave.NETWORK.nodes[discovery_info[zwave.const.ATTR_NODE_ID]]
value = node.values[discovery_info[zwave.const.ATTR_VALUE_ID]]
value.set_change_verified(False)
add_devices([ZWaveClimate(value, temp_unit)])
_LOGGER.debug("discovery_info=%s and zwave.NETWORK=%s",
discovery_info, zwave.NETWORK)
return ZWaveClimate(values, temp_unit)
class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
"""Representation of a Z-Wave Climate device."""
def __init__(self, value, temp_unit):
def __init__(self, values, temp_unit):
"""Initialize the Z-Wave climate device."""
ZWaveDeviceEntity.__init__(self, value, DOMAIN)
self._index = value.index
self._node = value.node
ZWaveDeviceEntity.__init__(self, values, DOMAIN)
self._target_temperature = None
self._current_temperature = None
self._current_operation = None
@@ -68,95 +57,74 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
self._unit = temp_unit
_LOGGER.debug("temp_unit is %s", self._unit)
self._zxt_120 = None
self.update_properties()
# Make sure that we have values for the key before converting to int
if (value.node.manufacturer_id.strip() and
value.node.product_id.strip()):
specific_sensor_key = (int(value.node.manufacturer_id, 16),
int(value.node.product_id, 16))
if (self.node.manufacturer_id.strip() and
self.node.product_id.strip()):
specific_sensor_key = (
int(self.node.manufacturer_id, 16),
int(self.node.product_id, 16))
if specific_sensor_key in DEVICE_MAPPINGS:
if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_ZXT_120:
_LOGGER.debug("Remotec ZXT-120 Zwave Thermostat"
" workaround")
self._zxt_120 = 1
self.update_properties()
def update_properties(self):
"""Callback on data changes for node values."""
# Operation Mode
for value in self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_MODE).values():
self._current_operation = value.data
self._operation_list = list(value.data_items)
_LOGGER.debug("self._operation_list=%s", self._operation_list)
_LOGGER.debug("self._current_operation=%s",
self._current_operation)
if self.values.mode:
self._current_operation = self.values.mode.data
operation_list = self.values.mode.data_items
if operation_list:
self._operation_list = list(operation_list)
_LOGGER.debug("self._operation_list=%s", self._operation_list)
_LOGGER.debug("self._current_operation=%s", self._current_operation)
# Current Temp
for value in (
self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_SENSOR_MULTILEVEL)
.values()):
if value.label == 'Temperature':
self._current_temperature = round((float(value.data)), 1)
self._unit = value.units
if self.values.temperature:
self._current_temperature = self.values.temperature.data
device_unit = self.values.temperature.units
if device_unit is not None:
self._unit = device_unit
# Fan Mode
for value in (
self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_FAN_MODE)
.values()):
self._current_fan_mode = value.data
self._fan_list = list(value.data_items)
_LOGGER.debug("self._fan_list=%s", self._fan_list)
_LOGGER.debug("self._current_fan_mode=%s",
self._current_fan_mode)
if self.values.fan_mode:
self._current_fan_mode = self.values.fan_mode.data
fan_list = self.values.fan_mode.data_items
if fan_list:
self._fan_list = list(fan_list)
_LOGGER.debug("self._fan_list=%s", self._fan_list)
_LOGGER.debug("self._current_fan_mode=%s",
self._current_fan_mode)
# Swing mode
if self._zxt_120 == 1:
for value in (
self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_CONFIGURATION)
.values()):
if value.command_class == \
zwave.const.COMMAND_CLASS_CONFIGURATION and \
value.index == 33:
self._current_swing_mode = value.data
self._swing_list = list(value.data_items)
_LOGGER.debug("self._swing_list=%s", self._swing_list)
_LOGGER.debug("self._current_swing_mode=%s",
self._current_swing_mode)
if self.values.zxt_120_swing_mode:
self._current_swing_mode = self.values.zxt_120_swing_mode.data
swing_list = self.values.zxt_120_swing_mode.data_items
if swing_list:
self._swing_list = list(swing_list)
_LOGGER.debug("self._swing_list=%s", self._swing_list)
_LOGGER.debug("self._current_swing_mode=%s",
self._current_swing_mode)
# Set point
temps = []
for value in (
self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_SETPOINT)
.values()):
temps.append((round(float(value.data)), 1))
if value.index == self._index:
if value.data == 0:
_LOGGER.debug("Setpoint is 0, setting default to "
"current_temperature=%s",
self._current_temperature)
self._target_temperature = (
round((float(self._current_temperature)), 1))
break
else:
self._target_temperature = round((float(value.data)), 1)
if self.values.primary.data == 0:
_LOGGER.debug("Setpoint is 0, setting default to "
"current_temperature=%s",
self._current_temperature)
self._target_temperature = (
round((float(self._current_temperature)), 1))
else:
self._target_temperature = round(
(float(self.values.primary.data)), 1)
# Operating state
for value in (
self._node.get_values(
class_id=zwave.const
.COMMAND_CLASS_THERMOSTAT_OPERATING_STATE).values()):
self._operating_state = value.data
if self.values.operating_state:
self._operating_state = self.values.operating_state.data
# Fan operating state
for value in (
self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_FAN_STATE)
.values()):
self._fan_state = value.data
@property
def should_poll(self):
"""No polling on Z-Wave."""
return False
if self.values.fan_state:
self._fan_state = self.values.fan_state.data
@property
def current_fan_mode(self):
@@ -215,57 +183,31 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
else:
return
for value in (self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_SETPOINT)
.values()):
if value.index == self._index:
if self._zxt_120:
# ZXT-120 responds only to whole int
value.data = round(temperature, 0)
self._target_temperature = temperature
self.update_ha_state()
else:
value.data = temperature
self.update_ha_state()
break
self.values.primary.data = temperature
def set_fan_mode(self, fan):
"""Set new target fan mode."""
for value in (self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_FAN_MODE).
values()):
if value.command_class == \
zwave.const.COMMAND_CLASS_THERMOSTAT_FAN_MODE and \
value.index == 0:
value.data = bytes(fan, 'utf-8')
break
if self.values.fan_mode:
self.values.fan_mode.data = bytes(fan, 'utf-8')
def set_operation_mode(self, operation_mode):
"""Set new target operation mode."""
for value in self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_THERMOSTAT_MODE).values():
if value.command_class == \
zwave.const.COMMAND_CLASS_THERMOSTAT_MODE and value.index == 0:
value.data = bytes(operation_mode, 'utf-8')
break
if self.values.mode:
self.values.mode.data = bytes(operation_mode, 'utf-8')
def set_swing_mode(self, swing_mode):
"""Set new target swing mode."""
if self._zxt_120 == 1:
for value in self._node.get_values(
class_id=zwave.const.COMMAND_CLASS_CONFIGURATION).values():
if value.command_class == \
zwave.const.COMMAND_CLASS_CONFIGURATION and \
value.index == 33:
value.data = bytes(swing_mode, 'utf-8')
break
if self.values.zxt_120_swing_mode:
self.values.zxt_120_swing_mode.data = bytes(
swing_mode, 'utf-8')
@property
def device_state_attributes(self):
"""Return the device specific state attributes."""
data = super().device_state_attributes
if self._operating_state:
data[ATTR_OPERATING_STATE] = self._operating_state,
data[ATTR_OPERATING_STATE] = self._operating_state
if self._fan_state:
data[ATTR_FAN_STATE] = self._fan_state
return data

View File

@@ -0,0 +1,136 @@
"""Component to configure Home Assistant via an API."""
import asyncio
import os
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import EVENT_COMPONENT_LOADED
from homeassistant.setup import (
async_prepare_setup_platform, ATTR_COMPONENT)
from homeassistant.components.frontend import register_built_in_panel
from homeassistant.components.http import HomeAssistantView
from homeassistant.util.yaml import load_yaml, dump
DOMAIN = 'config'
DEPENDENCIES = ['http']
SECTIONS = ('core', 'group', 'hassbian')
ON_DEMAND = ('zwave', )
@asyncio.coroutine
def async_setup(hass, config):
"""Setup the config component."""
register_built_in_panel(hass, 'config', 'Configuration', 'mdi:settings')
@asyncio.coroutine
def setup_panel(panel_name):
"""Setup a panel."""
panel = yield from async_prepare_setup_platform(hass, config, DOMAIN,
panel_name)
if not panel:
return
success = yield from panel.async_setup(hass)
if success:
key = '{}.{}'.format(DOMAIN, panel_name)
hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: key})
hass.config.components.add(key)
tasks = [setup_panel(panel_name) for panel_name in SECTIONS]
for panel_name in ON_DEMAND:
if panel_name in hass.config.components:
tasks.append(setup_panel(panel_name))
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop)
@callback
def component_loaded(event):
"""Respond to components being loaded."""
panel_name = event.data.get(ATTR_COMPONENT)
if panel_name in ON_DEMAND:
hass.async_add_job(setup_panel(panel_name))
hass.bus.async_listen(EVENT_COMPONENT_LOADED, component_loaded)
return True
class EditKeyBasedConfigView(HomeAssistantView):
"""Configure a Group endpoint."""
def __init__(self, component, config_type, path, key_schema, data_schema,
*, post_write_hook=None):
"""Initialize a config view."""
self.url = '/api/config/%s/%s/{config_key}' % (component, config_type)
self.name = 'api:config:%s:%s' % (component, config_type)
self.path = path
self.key_schema = key_schema
self.data_schema = data_schema
self.post_write_hook = post_write_hook
@asyncio.coroutine
def get(self, request, config_key):
"""Fetch device specific config."""
hass = request.app['hass']
current = yield from hass.loop.run_in_executor(
None, _read, hass.config.path(self.path))
return self.json(current.get(config_key, {}))
@asyncio.coroutine
def post(self, request, config_key):
"""Validate config and return results."""
try:
data = yield from request.json()
except ValueError:
return self.json_message('Invalid JSON specified', 400)
try:
self.key_schema(config_key)
except vol.Invalid as err:
return self.json_message('Key malformed: {}'.format(err), 400)
try:
# We just validate, we don't store that data because
# we don't want to store the defaults.
self.data_schema(data)
except vol.Invalid as err:
return self.json_message('Message malformed: {}'.format(err), 400)
hass = request.app['hass']
path = hass.config.path(self.path)
current = yield from hass.loop.run_in_executor(None, _read, path)
current.setdefault(config_key, {}).update(data)
yield from hass.loop.run_in_executor(None, _write, path, current)
if self.post_write_hook is not None:
hass.async_add_job(self.post_write_hook(hass))
return self.json({
'result': 'ok',
})
def _read(path):
"""Read YAML helper."""
if not os.path.isfile(path):
with open(path, 'w'):
pass
return {}
return load_yaml(path)
def _write(path, data):
"""Write YAML helper."""
# Do it before opening file. If dump causes error it will now not
# truncate the file.
data = dump(data)
with open(path, 'w', encoding='utf-8') as outfile:
outfile.write(data)

View File

@@ -0,0 +1,31 @@
"""Component to interact with Hassbian tools."""
import asyncio
from homeassistant.components.http import HomeAssistantView
from homeassistant.config import async_check_ha_config_file
@asyncio.coroutine
def async_setup(hass):
"""Setup the hassbian config."""
hass.http.register_view(CheckConfigView)
return True
class CheckConfigView(HomeAssistantView):
"""Hassbian packages endpoint."""
url = '/api/config/core/check_config'
name = 'api:config:core:check_config'
@asyncio.coroutine
def post(self, request):
"""Validate config and return results."""
errors = yield from async_check_ha_config_file(request.app['hass'])
state = 'invalid' if errors else 'valid'
return self.json({
"result": state,
"errors": errors,
})

View File

@@ -0,0 +1,19 @@
"""Provide configuration end points for Groups."""
import asyncio
from homeassistant.components.config import EditKeyBasedConfigView
from homeassistant.components.group import GROUP_SCHEMA
import homeassistant.helpers.config_validation as cv
CONFIG_PATH = 'groups.yaml'
@asyncio.coroutine
def async_setup(hass):
"""Setup the Group config API."""
hass.http.register_view(EditKeyBasedConfigView(
'group', 'config', CONFIG_PATH, cv.slug,
GROUP_SCHEMA
))
return True

View File

@@ -0,0 +1,91 @@
"""Component to interact with Hassbian tools."""
import asyncio
import json
import os
from homeassistant.components.http import HomeAssistantView
_TEST_OUTPUT = """
{
"suites":{
"libcec":{
"state":"Uninstalled",
"description":"Installs the libcec package for controlling CEC devices from this Pi"
},
"mosquitto":{
"state":"failed",
"description":"Installs the Mosquitto package for setting up a local MQTT server"
},
"openzwave":{
"state":"Uninstalled",
"description":"Installs the Open Z-wave package for setting up your zwave network"
},
"samba":{
"state":"installing",
"description":"Installs the samba package for sharing the hassbian configuration files over the Pi's network."
}
}
}
""" # noqa
@asyncio.coroutine
def async_setup(hass):
"""Setup the hassbian config."""
# Test if is hassbian
test_mode = 'FORCE_HASSBIAN' in os.environ
is_hassbian = test_mode
if not is_hassbian:
return False
hass.http.register_view(HassbianSuitesView(test_mode))
hass.http.register_view(HassbianSuiteInstallView(test_mode))
return True
@asyncio.coroutine
def hassbian_status(hass, test_mode=False):
"""Query for the Hassbian status."""
# fetch real output when not in test mode
if test_mode:
return json.loads(_TEST_OUTPUT)
raise Exception('Real mode not implemented yet.')
class HassbianSuitesView(HomeAssistantView):
"""Hassbian packages endpoint."""
url = '/api/config/hassbian/suites'
name = 'api:config:hassbian:suites'
def __init__(self, test_mode):
"""Initialize suites view."""
self._test_mode = test_mode
@asyncio.coroutine
def get(self, request):
"""Request suite status."""
inp = yield from hassbian_status(request.app['hass'], self._test_mode)
return self.json(inp['suites'])
class HassbianSuiteInstallView(HomeAssistantView):
"""Hassbian packages endpoint."""
url = '/api/config/hassbian/suites/{suite}/install'
name = 'api:config:hassbian:suite'
def __init__(self, test_mode):
"""Initialize suite view."""
self._test_mode = test_mode
@asyncio.coroutine
def post(self, request, suite):
"""Request suite status."""
# do real install if not in test mode
return self.json({"status": "ok"})

View File

@@ -0,0 +1,19 @@
"""Provide configuration end points for Z-Wave."""
import asyncio
from homeassistant.components.config import EditKeyBasedConfigView
from homeassistant.components.zwave import DEVICE_CONFIG_SCHEMA_ENTRY
import homeassistant.helpers.config_validation as cv
CONFIG_PATH = 'zwave_device_config.yaml'
@asyncio.coroutine
def async_setup(hass):
"""Setup the Z-Wave config API."""
hass.http.register_view(EditKeyBasedConfigView(
'zwave', 'device_config', CONFIG_PATH, cv.entity_id,
DEVICE_CONFIG_SCHEMA_ENTRY
))
return True

View File

@@ -6,15 +6,16 @@ This will return a request id that has to be used for future calls.
A callback has to be provided to `request_config` which will be called when
the user has submitted configuration information.
"""
import asyncio
import logging
from homeassistant.const import EVENT_TIME_CHANGED, ATTR_FRIENDLY_NAME, \
ATTR_ENTITY_PICTURE
from homeassistant.helpers.entity import generate_entity_id
_INSTANCES = {}
_LOGGER = logging.getLogger(__name__)
_REQUESTS = {}
_KEY_INSTANCE = 'configurator'
ATTR_CONFIGURE_ID = 'configure_id'
ATTR_DESCRIPTION = 'description'
@@ -72,22 +73,20 @@ def request_done(request_id):
pass
def setup(hass, config):
@asyncio.coroutine
def async_setup(hass, config):
"""Setup the configurator component."""
return True
def _get_instance(hass):
"""Get an instance per hass object."""
try:
return _INSTANCES[hass]
except KeyError:
_INSTANCES[hass] = Configurator(hass)
instance = hass.data.get(_KEY_INSTANCE)
if DOMAIN not in hass.config.components:
hass.config.components.append(DOMAIN)
if instance is None:
instance = hass.data[_KEY_INSTANCE] = Configurator(hass)
return _INSTANCES[hass]
return instance
class Configurator(object):

Some files were not shown because too many files have changed in this diff Show More