Commit Graph

393 Commits (2502e7669c9fce7b4f1074a79713db968e85151c)

Author SHA1 Message Date
Ville Skyttä 54242cd65c Type hint additions (#26765) 2019-09-20 08:23:34 -07:00
Erik Montnemery 10572a62b1 Add support for automation description (#26662)
* Add support for automation annotation

* Rename annotation to description
2019-09-17 12:12:54 -07:00
Robert Svensson c680c07c65 deCONZ device automations (#26366)
* Early draft

* Getting there

* Working fully with Hue dimmer remote

* Fix Balloobs comments

* No side effects in constructor

* Improve hue dimmer

* Add Ikea remote control

* Add xiaomi button support

* Refactor getting deconz event

* Added xiaomi devices and tradfri wireless dimmer

* Resolve unique id from device id

* Add Hue Tap and Tradfri on off switch

* More triggers for ikea on off switch and Aqara double wall switch

* Add support for Tradfri open close remote

* Fix changes after rebase

* Initial test

* Change id to event_id

* Fix translations and add subtypes

* Try if tests pass without the new tests

* Revert disabling tests
Add new exception InvalidDeviceAutomationConfig

* Ignore places calling remotes

* Enable all gateway tests

* Found the issue, now to identify which test creates it

* Remove block till done

* See if device automation test passes in azure

* Register event to device registry

* Enable test sensors

* Skip deconz event tests currently failing

* Added reason why skipping tests
2019-09-10 16:56:28 -07:00
Erik Montnemery f7dc537275
Add device automation condition (#26313)
* Add support for device conditions

* Lint

* Update test case

* Make and+or conditions async, adjust tests

* Cleanup tests

* Remove non callback versions of conditions, correct typing

* Correct typing

* Update light/strings.json

* Address review comments

* Make device automation lists simple lists, not dicts

* Add device_automation/const.py

* Use IS_ON/IS_OFF everywhere for conditions
2019-09-05 16:49:32 +02:00
Erik Montnemery 3aa2729716 Add improvements of device_automation from frontend PR 3514 (#26295)
* Add improvements from frontend PR 3514

* Fix test

* Tweak
2019-09-01 21:40:18 -07:00
Franck Nijhof decf13b948 Use literal string interpolation in core (f-strings) (#26166) 2019-08-23 09:53:33 -07:00
Ville Skyttä b738082dad Type check various base components (#25878)
* Type check various component base classes, disabling bunch of checks for now

* Type hint fixes

* Help mypy out some

* Add more type hints
2019-08-11 20:38:18 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Aaron Bach 0caab133e6
Add area support to automation service schemas (#25403)
* Add area support to automation service schemas

* Fixed import

* Mispelling
2019-07-23 11:07:13 -06:00
Phil Bruckner c80683bb15 Restore automation last_triggered as datetime & fix test (#24951)
* Restore automation last_triggered as datetime & fix test

* last_triggered is always a string
2019-07-10 20:42:38 -07:00
Phil Bruckner 9944e675a5 Add template support to state trigger's for option (#24912) 2019-07-08 13:59:58 -07:00
Phil Bruckner f9b9883aba Add template support to numeric_state trigger's for option (#24955) 2019-07-08 13:58:50 -07:00
Phil Bruckner 8dca73d08e Add missing trigger.for variable to template trigger (#24893) 2019-07-02 17:46:26 +02:00
Phil Bruckner 3f4ce70414 Fix 'same state' monitoring in state trigger (#24904) 2019-07-02 17:29:38 +02:00
Phil Bruckner 945afbc6d4 Fix 'same state' monitoring in numeric_state trigger (#24910) 2019-07-02 17:28:02 +02:00
Phil Bruckner 03e6a92cf3 Add template support to template trigger's for option (#24810) 2019-06-28 22:30:47 -07:00
Erik Montnemery 935240f8c3 Add websock command to query device for triggers (#24044)
* Add websock command to query device for triggers

* Lint

* Refactor

* Add support for domain automations

* Make device automation an automation platform

* lint

* Support device_id in light trigger

* Review comments

* Add tests

* Add tests

* lint
2019-06-10 15:36:11 -07:00
Franck Nijhof 9235b52828 Restore automation last_triggered with initial_state override (#24400)
* Restore automation last_triggered with initial_state override

* Made test async/await

* Fixes linter warning

* Update test_init.py
2019-06-08 12:48:36 -07:00
Paulus Schoutsen 7887d6d6e4
Fix automation failing to restore state (#24390)
* Fix automation off

* Fix tests
2019-06-07 23:08:22 -07:00
Phil Bruckner 61dabae6ab Add for option for template triggers (#24330) 2019-06-07 21:45:37 -07:00
Paulus Schoutsen f995ab9d54
Don't pass in loop (#23984)
* Don't pass in loop

* Revert some changes

* Lint + Axis revert

* reinstate loop

* Fix a test

* Set loop

* Update camera.py

* Lint
2019-05-22 21:09:59 -07:00
Penny Wood d9fb3c8c28 Potential None (#23187) 2019-04-18 14:04:30 +02:00
ActuallyRuben df580b2322 Add URL query parameters to webhook trigger result data (#23043)
* Added query parameters to webhook data

* Added test for query webhook

* Add second blank line in new test for webhook trigger
2019-04-14 10:53:35 -07:00
cgtobi 2c07bfb9e0 Remove dependencies and requirements (#23024)
* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit fe7171b4cd.

* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit 391355ee2c.

* Remove dependencies and requirements

* Fix flake8 complaints

* Fix more flake8 complaints

* Revert non-component removals
2019-04-12 10:13:30 -07:00
Rohan Kapoor 6ba9ccf052 Load requirements and dependencies from manifests. Fallback to current `REQUIREMENTS` and `DEPENDENCIES` (#22717)
* Load dependencies from manifests. Fallback to current DEPENDENCIES

* Fix typing

* Ignore typing correctly

* Split out dependency processing to a new method

* Fix tests

* Only pull from manifest if dependencies is non empty

* Inline temporary function

* Fix light tests [skip ci]

* Fix tests/common

* Fix some mqtt tests [skip ci]

* Fix tests and component manifests which have only one platform

* Fix rflink tests

* Fix more tests and manifests

* Readability over shorthand format

* Fix demo/notify tests

* Load dependencies from manifests. Fallback to current DEPENDENCIES

* Load requirements from manifests. Fallback to current REQUIREMENTS

* Fix typing

* Ignore typing correctly

* Split out dependency processing to a new method

* Only pull from manifest if dependencies is non empty

* Inline temporary function

* Fix tests and component manifests which have only one platform

* Fix rflink tests

* Readability over shorthand format

* Clean up requirements

* Use integration to resolve deps/reqs

* Lint

* Lint

* revert a change

* Revert a test change

* Fix types

* Fix types

* Add back cache for load component

* Fix test_component_not_found

* Move light.test and device_tracker.test into test package instead with manifest to fix tests

* Fix broken device_tracker tests

* Add docstrings to __init__

* Fix all of the light tests that I broke earlier

* Embed the test.switch platform to fix other tests

* Embed and fix the test.imagimage_processing platform

* Fix tests for nx584

* Add dependencies from platform file's DEPENDENCIES

* Try to setup component when entity_platform is setting up

Fix tests in helpers folder

* Rewrite test_setup

* Simplify

* Lint

* Disable demo component if running in test

Temp workaround to unblock CI tests

* Skip demo tests

* Fix config entry test

* Fix repeat test

* Clarify doc

* One extra guard

* Fix import

* Lint

* Workaround google tts
2019-04-11 01:26:36 -07:00
Paulus Schoutsen e48ef7f441
Fix broken platform components (#22943)
* Fix broken platform components

* Lint
2019-04-09 15:42:44 -07:00
Paulus Schoutsen cfe4cf30ad
Add manifests (#22699)
* Add manifests

* Update auto name

* Update codeowners

* Add requirements from platforms

* Minor cleanup

* Incorporate changes from awarecan PR
2019-04-03 21:14:45 -07:00
Paulus Schoutsen 4b1de61110
Use relative imports inside integrations (#22235)
* Use relative imports inside integrations

* Lint

* Fix automation tests

* Fix scene imports
2019-03-20 22:56:46 -07:00
emontnemery b25e951dcc Update additional platforms to use new MQTT message callback (#22030)
* Move additional platforms to new MQTT callback

* Fix automation.mqtt
2019-03-14 10:58:32 -07:00
Paulus Schoutsen 8213016eaf
Allow targeting areas in service calls (#21472)
* Allow targeting areas in service calls

* Lint + Type

* Address comments
2019-03-04 09:51:12 -08:00
Paulus Schoutsen 52f337ef00
Allow chaining contexts (#21028)
* Allow chaining contexts

* Add stubbed out migration
2019-03-01 10:08:38 -08:00
Fabian Affolter 127c55e0c1
Update file header (#21023)
* Update file header

* Update file header

* Update file header

* Update file header

* Update file header

* Fix lint issues
2019-02-13 21:21:14 +01:00
emontnemery ec5da05804 Add character encoding to MQTT automation. (#20292) 2019-01-24 22:43:56 -08:00
Anders Melchiorsen 362ac725bf Remove double logging of automation action (#20264) 2019-01-21 00:10:12 +01:00
Adam Mills 336b6adc88 Split time_pattern triggers from time trigger (#19825)
* Split interval triggers from time trigger

* Default smaller interval units to zero

* Rename interval to schedule

* Rename schedule to time_pattern
2019-01-15 09:33:34 -08:00
Malte Franken 4bbfc04f5e Geo Location -> Geolocation (comments and default group name) (#19865)
* fixed geolocation naming in comments

* fixed geolocation naming in default group name

* fixed link to documentation (after https://github.com/home-assistant/home-assistant.io/pull/8086)
2019-01-08 11:24:57 +01:00
Paulus Schoutsen 9d9e11372b
Make automations log errors (#18965) 2018-12-13 12:21:16 +01:00
Paulus Schoutsen 8ea0a8d40b
RFC: Deprecate auto target all for services and introduce entity_id: * (#19006)
* Deprecate auto target all

* Match on word 'all'
2018-12-13 10:07:59 +01:00
Jason Hunter b900005d1e New Events and Context Fixes (#18765)
* Add new events for automation trigger and script run, fix context for image processing, add tests to ensure same context

* remove custom logbook entry for automation and add new automation event to logbook

* code review updates
2018-12-04 09:45:17 +01:00
Adam Mills 5c3a4e3d10 Restore states through a JSON store instead of recorder (#17270)
* Restore states through a JSON store

* Accept entity_id directly in restore state helper

* Keep states stored between runs for a limited time

* Remove warning
2018-11-28 13:16:43 +01:00
Paulus Schoutsen 2e9132873a Webhook names (#18206)
* Add new automation_info param to async_trigger

* Add domain and name to webhook registration and add WS command
2018-11-05 09:23:58 +01:00
Malte Franken 75e42acfe7 Geo location trigger added (#16967)
* zone trigger supports entity id pattern

* fixed lint error

* fixed test code

* initial version of new geo_location trigger

* revert to original

* simplified code and added tests

* refactored geo_location trigger to be based on a source defined by the entity

* amended test cases

* small refactorings
2018-10-22 20:01:01 +02:00
Rohan Kapoor bd450ee9ff Migrate CONF_WEBHOOK_ID to homeassistant.const (#17460)
* Migrate CONF_WEBHOOK_ID to homeassistant.const

* Switch over all instances of webhook_id to the const

* Switch last instance of webhook_id to the const

* automation: conf constants for conf

* webhook: conf constants for conf
2018-10-15 11:18:21 +02:00
Paulus Schoutsen 68472b8241
Add a webhook automation trigger (#17246) 2018-10-08 20:16:37 +02:00
Paulus Schoutsen fbc1c41673 Logbook context (#16937)
* Convert logbook to use attr

* Add context to events

* Enhance logbook

* Lint

* Fix logbook entry

* Don't use intermediary classes for logbook entries
2018-10-01 16:12:25 +02:00
cdce8p 38e371c5d9 Async syntax 1, alarm_control_panel & automation & binary_sensor (#17015) 2018-10-01 08:49:19 +02:00
cdce8p f879ac0993 Remove service helper (6) (#16920)
* Update automation

* Update group

* Async_create_task
2018-09-27 23:14:09 +02:00
cdce8p fa98a27df7 Remove service helper (2) (#16863)
* alarm_control_panel

* automation

* camera

* climate

* counter

* fan

* Add legacy notes

* Fix tests
2018-09-26 09:49:55 +02:00
Paulus Schoutsen 746f4ac158 Add context to scripts and automations (#16415)
* Add context to script helper

* Update script component

* Add context to automations

* Lint
2018-09-04 21:16:24 +02:00
Ville Skyttä dbd0763f83 Grammar and spelling fixes (#16065) 2018-08-19 22:29:08 +02:00
Ville Skyttä b7c336a687 Pylint cleanups (#15626)
* Pylint 2 no-else-return fixes

* Remove unneeded abstract-class-not-used pylint disable
2018-07-23 10:16:05 +02:00
Ville Skyttä bf17ed0917 More pylint 2 fixes (#15516)
* Pylint 2 useless-import-alias fixes

* Pylint 2 chained-comparison fixes

* Pylint 2 consider-using-get fixes

* Pylint 2 len-as-condition fixes
2018-07-18 11:54:27 +02:00
Anders Melchiorsen fcbc399809 Disallow automation.trigger without entity_id (#14724) 2018-06-01 10:27:12 -04:00
Paulus Schoutsen 83d300fd11 Custom component loading cleanup (#14211)
* Clean up custom component loading

* Fix some tests

* Fix some stuff

* Make imports work again

* Fix tests

* Remove debug print

* Lint
2018-05-01 20:57:30 +02:00
Paulus Schoutsen 183e0543b4
Clean up entity component (#11691)
* Clean up entity component

* Lint

* List -> Tuple

* Add Entity.async_remove back

* Unflake setting up group test
2018-01-22 22:54:41 -08:00
Adam Mills 6918993c75 Fix state for trigger with forced updates (#11595) 2018-01-11 22:06:09 -08:00
Anders Melchiorsen 8267a21bfe Lazy loading of service descriptions (#11479)
* Lazy loading of service descriptions

* Fix tests

* Load YAML in executor

* Return a copy of available services to allow mutations

* Remove lint

* Add zha/services.yaml

* Only cache descriptions for known services

* Remove lint

* Remove description loading during service registration

* Remove description parameter from async_register

* Test async_get_all_descriptions

* Remove lint

* Fix typos from multi-edit

* Remove unused arguments

* Remove unused import os

* Remove unused import os, part 2

* Remove unneeded coroutine decorator

* Only use executor for loading files

* Cleanups suggested in review

* Increase test coverage

* Fix races in existing tests
2018-01-07 14:54:16 -08:00
Pascal Vizeli ea6ca9252c
Bugfix trigger state with multible entities (#10857)
* Bugfix trigger state with multible entities

* Fix numeric state

* fix lint

* fix dict

* fix unsub

* fix logic

* fix name

* fix new logic

* add test for state

* add numeric state test for unsub

* add test for multible entities

* Update numeric_state.py

* Update numeric_state.py

* Update state.py

* Fix logic for triple match

* Add clear to numeric state

* clear for state trigger
2017-11-30 21:03:52 +01:00
Fabian Affolter cc293db5ab
Update services.yaml files (#10229)
* Add period to the description

* Update abbreviation
2017-10-30 21:39:12 +01:00
Anders Melchiorsen 61ccbb59ce Fire numeric_state action when first state change matches criteria (#10125)
* Fire numeric_state action when first state change matches criteria

* Remove lint

* Update numeric_state.py
2017-10-25 16:01:09 +02:00
Pascal Vizeli 205f24c070 Trigger also with orderdict 2017-10-23 09:01:59 +02:00
Adam Mills 4e7cc110d9 Fix no data event triggers (#10049)
* Test including extra data on a no data trigger

* Match any dicts for default schema for event data

* Fix indentation

* Only check schema if one was configured
2017-10-22 20:20:38 -04:00
Paulus Schoutsen a97e7bb22d Simplify track_same_state (#9795) 2017-10-10 21:16:19 +02:00
Adam Mills 4342d7aa17 Event trigger nested conditions (#9732)
* Test to supported nested event triggers

* Update event trigger to allow nested data tests
2017-10-07 13:13:32 -07:00
Pascal Vizeli ed699896cb Core track same state for a period / Allow on platforms (#9273)
* Core track state period / Allow on platforms

* Add tests

* fix lint

* fix tests

* add new tracker to automation state

* update schema

* fix bug

* revert validate string

* Fix bug

* Set arguments to async_check_funct

* add logic into numeric_state

* fix numeric_state

* Add tests

* fix retrigger state

* cleanup

* Add delay function to template binary_sensor

* Fix tests & lint

* add more tests

* fix lint

* Address comments

* fix test & lint
2017-09-05 02:01:01 +02:00
Paulus Schoutsen 9575cbde09 Consolidate config panels (#8857)
* Remove automation panel registration

* Move Z-Wave config API to config.zwave

* Remove no longer needed test

* Lint

* Update frontend
2017-08-06 12:05:34 -07:00
Anders Melchiorsen b83ff739bc Remove deprecated automation keywords (#8510)
* Remove deprecated automation keywords

* Remove retired test case

* Remove retired keyword
2017-07-17 22:24:05 +02:00
Paulus Schoutsen d29bdddaa7 Add bind_hass to components (#8502)
* Add bind_hass to components

* Add bind_hass to group
2017-07-16 10:14:46 -07:00
Paulus Schoutsen 5779d64e98 Fix some issues for PyLint 1.7.2 (#8356)
* Fix some issues for PyLint 1.7.2

* More fixes

* Revert position change for cover
2017-07-05 20:02:16 -07:00
Pascal Vizeli 814834512a Group service / dynamic handling (#7971)
* Add Service to group

* Finish service

* Add service functions

* fix lint

* Address paulus comments

* fix lint & cleanup

* fix lint

* fix lint

* fix lint p3

* add test for check group

* add more tests

* fix lint

* Update service.yaml

* Fix order for tests

* Fix comment

* Fix test

* Fix tests

* Fix name in tests

* Fix view

* Fix default value

* Fix lint

* Fix key error

* add name

* migrate component entity

* fix tests

* fix import

* migrate device tracker

* fix lint

* fix bug

* fix logic

* fix lint

* fix tests

* fix generator

* fix group

* fix other tests.

* Not need to load group on first stage anymore.

* fix service

* add more group depency

* fix tests

* Revert "fix tests"

This reverts commit 35a922b3a8.

* Real fix

* fix test p2

* fix test p3

* fix test p4

* fix test p5

* fix test p6

* fix lint

* fix test p7

* Rename attribute

* fix group test

* fix bug

* fix flagy tests

* fix service.yaml

* fix lint
2017-06-16 00:52:28 +02:00
Adam Mills cf42303afb Rename time trigger 'after' to 'at' (#7846) 2017-06-01 22:40:27 -07:00
Paulus Schoutsen f43db3c615 Replace executor with async_add_job (#7658)
* Remove executor

* Lint

* Lint

* Fix tests
2017-05-26 08:28:07 -07:00
Paulus Schoutsen 171086229a Guard against new and removed state change events (#7687) 2017-05-21 07:41:33 -07:00
Anders Melchiorsen 81f0826550 Ignore attribute changes in automation trigger from/to (#7651)
* Ignore attribute changes in automation trigger from/to

* Quote names in deprecation warnings

This makes it somewhat easier to read if the suggestion happens to be
named "to".

* Add test with same state, new attribute value
2017-05-20 15:18:59 -04:00
Paulus Schoutsen e773133bcf Fix automation failing to setup if no automations specified (#7647) 2017-05-17 21:57:50 -07:00
Paulus Schoutsen d5ca6a5aed Force automation ids to always be a string (#7612) 2017-05-15 23:15:06 -07:00
Adam Mills e2e58e6acc Automation State Change For timer attribute fix (#7584) 2017-05-15 00:34:30 -07:00
Paulus Schoutsen 5d820ec188 Add support for automation config panel (#7509)
* Add support for automation config

* Build fromtend

* Lint
2017-05-09 18:44:00 -07:00
Adam Mills 40d27cde0e Refactor sun component for correctness (#7295)
* Refactor sun component for correctness

* Convert datetimes to dates for astral

* Fix tests for updated code

* Fix times now that calcs are fixed

* Move sun functions to helpers

* Fix flake on new file

* Additional tweaks from review

* Update requirements
2017-05-09 00:03:34 -07:00
Paulus Schoutsen 9440ff881f Remove listening to homeassistant_start with event automation (#7474) 2017-05-06 23:52:39 -07:00
Fabian Affolter 4d52b0ecd5 Update docstrings (#7405)
* Update docstrings

* Fix lint issues

* Update docstrings
2017-05-02 22:47:20 +02:00
Fabian Affolter 3ee4d1060f Update docstrings (#7361)
* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update tomato.py

* Update isy994.py

* Lint + fix tests

* Lint
2017-04-29 22:04:49 -07:00
Adam Mills 37f959eb02 Add debug logging to automation initial state (#7068) 2017-04-16 15:45:40 -07:00
Paulus Schoutsen 29f385ea76 Fix automations listening to HOMEASSISTANT_START (#6936)
* Fire EVENT_HOMEASSISTANT_START automations off right away while starting

* Actually have core state be set to 'starting' during boot

* Fix correct start implementation

* Test and deprecate event automation platform on start

* Fix doc strings

* Remove shutting down exception

* More strict when to mark an instance as finished

* Add automation platform to listen for start/shutdown

* When we stop we should wait till it's all done

* Fix testing

* Fix async bugs in tests

* Only set UVLOOP when hass starts from CLI

* This hangs normal asyncio event loop

* Clean up Z-Wave node entity test
2017-04-05 23:23:02 -07:00
Paulus Schoutsen 23645da74c Automation: initial state > restore state (#6911)
* Automation: initial state > restore state

* Clean up code

* Ensure MQTT defaults are used.

* Ensure failed platforms always return None

* Automation: write state to state machine after start
2017-04-03 23:11:39 -07:00
Pascal Vizeli f4e9466394 Bugfix automation fire on bootstrap (#6770)
* Bugfix automation fire on bootstrap

* Add test & fix bug

* fix lint
2017-03-24 15:52:14 -07: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
Paulus Schoutsen 2650c73a89 Split bootstrap into bs + setup (#6416)
* Split bootstrap into bs + setup

* Lint
2017-03-05 10:41:54 +01: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 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
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
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
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
Pascal Vizeli a6d995e394 Bugfix wait in automation (#4984) 2016-12-18 12:57:31 -08:00
Pascal Vizeli 0bf9e6d4bb Bugfix error on automation reload (#4823) 2016-12-08 23:24:03 -08:00
Paulus Schoutsen b2a15e17d3 MQTT Automation: parse payload as JSON (#4703) 2016-12-04 09:53:05 -08:00
Jon Caruana 2a6c0cfc17 LiteJet: Unit tests and new trigger options held_more_than and held_less_than. (#4473)
* LiteJet: Unit tests and new trigger options held_more_than and held_less_than.
* Unit tests for the LiteJet component and associated platforms. Coverage is almost 100% -- just misses one line.
* The automation LiteJet trigger returns an empty "removal" function to ensure the automation base is happy with it. The pylitejet library doesn't actually support a real removal.
* The automation LiteJet trigger can detect hold time and act appropriately to support things like short tap or long hold.

* LiteJet: Fix indent in unit test source code.

* LiteJet: Fix test_include_switches_* unit tests on Python 3.5

* LiteJet: Remove wait for state existence from unit tests. Recent fixes to discovery make this no longer necessary.
2016-11-24 09:52:15 -08:00
Paulus Schoutsen d2bbc6ef70 Upgrade linter (#4461) 2016-11-18 21:47:59 -08:00
Paulus Schoutsen a343c20404 Async gather wait (#4247)
* Fix config validation for input_*, script

* Allow scheduling coroutines

* Validate entity ids when entity ids set by platform

* Async: gather -> wait

* Script/Group: use async_add_job instead of create_task
2016-11-06 09:26:40 -08:00
Paulus Schoutsen ee5f228309 Make services yield (#4187)
* Make services yield

* Disable pylint abstract-method check

* add input_select

* add input_slider

* change to async vers.

* fix lint

* yield on add_entities as other components does
2016-11-03 18:32:14 -07:00
Jon Caruana ba13951fff Add LiteJet (a lighting control system) component (#4125)
* Initial submission of LiteJet integration.

* Add LiteJet switch pressed automation trigger. (State changes are too slow to catch a press-release.)
Add LiteJet scene, replacing commented out code that treated these as lights.
Include LiteJet numbers in the device state so that it is easy to lookup entity -> number.

* Fix missing global.

* Allow light's brightness to be set explicitly.

* Support optional 'ignore' key to ignore prefixes of loads, switches, and scenes that weren't configured for use in the LiteJet system.

* Fix lint errors and warnings.

* Cleanup header comments.
Default to not creating LiteJet switches as these are generally not useful.

* Lint fixes.

* Fixes from pull request feedback.

* Use hass.data instead of globals for data storage.

* Fix lint warnings.
2016-11-01 20:44:25 -07:00
Fabian Affolter be272ac64a Disable too-many-* (#4107)
* Disable too-many-* and too-few-public-methods

* Remove globally disabled pylint warnings
2016-10-30 22:18:53 +01:00
Pascal Vizeli 09db875ace Fix async bug in automation (#4078) 2016-10-27 18:26:55 +02:00
Pascal Vizeli d5368f6f78 Async bootstrap / component init (#3991)
* Async bootstrap

* Adress comments

* Fix tests

* More fixes

* Tests fixes
2016-10-27 00:16:23 -07:00
Adam Mills 7d32e5eeeb Logbook filtering of automations by entity_id (#3927)
* Logbook filtering of automations by entity_id

* Trigger action function parameters required
2016-10-18 18:11:35 -07:00
Pascal Vizeli 0b8b9ecb94 Async EntitiesComponent (#3820)
* first version

* First draft component entities

* Change add_entities to callback from coroutine

* Fix bug add async_prepare_reload

* Group draft v1

* group async

* bugfix

* bugfix v2

* fix lint

* fix extract_entity_ids

* fix other things

* move get_component out of executor

* bugfix

* Address minor changes

* lint

* bugfix - should work now

* make group init async only

* change update handling to old stuff

* fix group handling, remove generator from init

* fix lint

* protect loop for spaming with updates

* fix lint

* update test_group

* fix

* update group handling

* fix __init__ async trouble

* move device_tracker to new layout

* lint

* fix group unittest

* Test with coroutine

* fix bug

* now it works 💯

* ups

* first part of suggestion

* add_entities to coroutine

* change group

* convert add async_add_entity to coroutine

* fix unit tests

* fix lint

* fix lint part 2

* fix wrong import delete

* change async_update_tracked_entity_ids to coroutine

* fix

* revert last change

* fix unittest entity id

* fix unittest

* fix unittest

* fix unittest entity_component

* fix group

* fix group_test

* try part 2 to fix test_group

* fix all entity_component

* rename _process_config

* Change Group to init with factory

* fix lint

* fix lint

* fix callback

* Tweak entity component and group

* More fixes

* Final fixes

* No longer needed blocks

* Address @bbangert comments

* Add test for group.stop

* More callbacks for automation
2016-10-16 09:35:46 -07:00
Daniel Høyer Iversen b8beae9c6c Merge pull request #3651 from home-assistant/automation
Customize initial state of automation
2016-10-05 09:48:55 +02:00
Daniel 46f3337b07 Customize initial state of automation 2016-10-05 09:20:51 +02:00
Daniel Høyer Iversen d2d393feb5 Add automations and scripts to group.all_automations and group.all_scripts (#3664)
* Add automations to group.all_automations

* Add scripts to group.all_scripts
2016-10-04 21:20:48 -07:00
Paulus Schoutsen 5085cdb0f7 Add async_safe annotation (#3688)
* Add async_safe annotation

* More async_run_job

* coroutine -> async_save

* Lint

* Rename async_safe -> callback

* Add tests to core for different job types

* Add one more test with different type of callbacks

* Fix typing signature for callback methods

* Fix callback service executed method

* Fix method signatures for callback
2016-10-04 20:44:32 -07:00
Paulus Schoutsen d58548dd1c Address asyncio comments (#3663)
* Template platforms: create_task instead of yield from

* Automation: less yielding, more create_tasking

* Helpers.script: less yielding, more create_tasking

* Deflake logbook test

* Deflake automation reload config test

* MQTT: Use async_add_job and threaded_listener_factory

* Deflake other logbook test

* lint

* Add test for automation trigger service

* MQTT client can be called from within async
2016-10-03 22:39:27 -07:00
Paulus Schoutsen 8f3e12c9b8 Make Automation.reload_service_handler async 2016-10-01 15:42:17 -07:00
Paulus Schoutsen 56fdc2a625 Automation: call prepare_setup_platform in executor 2016-10-01 14:11:16 -07:00
Paulus Schoutsen e18825ba20 Automation: only call executor once when processing config 2016-10-01 14:11:16 -07:00
Paulus Schoutsen 7ab7edd81c Make automation async 2016-10-01 14:11:16 -07:00
Paulus Schoutsen b650b2b0db Spread async love (#3575)
* Convert Entity.update_ha_state to be async

* Make Service.call async

* Update entity.py

* Add Entity.async_update

* Make automation zone trigger async

* Fix linting

* Reduce flakiness in hass.block_till_done

* Make automation.numeric_state async

* Make mqtt.subscribe async

* Make automation.mqtt async

* Make automation.time async

* Make automation.sun async

* Add async_track_point_in_utc_time

* Make helpers.track_sunrise/set async

* Add async_track_state_change

* Make automation.state async

* Clean up helpers/entity.py tests

* Lint

* Lint

* Core.is_state and Core.is_state_attr are async friendly

* Lint

* Lint
2016-09-30 12:57:24 -07:00
Paulus Schoutsen 00e298206e Optimize template 2 (#3521)
* Enforce compiling templates

* Refactor templates

* Add template validator to Logbook service

* Some more fixes

* Lint

* Allow easy skipping of rfxtrx tests

* Fix template bug in AND & OR conditions

* add entities extractor

Conflicts:
	tests/helpers/test_template.py

* fix unittest

* Convert template to be async

* Fix Farcy

* Lint fix

* Limit template updates to related entities

* Make template automation async
2016-09-27 21:29:55 -07:00
Paulus Schoutsen 0c0feda834 Pre-compile templates (#3515)
* Pre-compile templates

* Compile templates in numeric_state condition
2016-09-25 13:33:01 -07:00
Micha LaQua d31f6bc3f0 Allow hiding automation entities from UIs (#3442)
* Allow hiding automation entities from UIs

* Flake8 fixes: Allow hiding automation entities from UIs

* Automation: Rework hide entity feature

 * Refactor keyword 'hidden' to 'hide_entity' to avoid ambiguity
 * Migrate hide_entity subsetting to Voluptuous
2016-09-19 23:39:07 -07:00
Paulus Schoutsen aca375c312 Asyncio event helpers (#3415)
* Automation - Event: Use coroutine

* Convert event helpers to coroutine

* Fix linting

* Add hass.async_add_job

* Automation - Event to use async_add_job
2016-09-17 18:28:01 -07:00
Fabian Affolter fb0232429e Use constants and update ordering (#3268)
🐬
2016-09-08 18:32:32 -06:00
Paulus Schoutsen 35b388edce Reload groups (#3203)
* Allow reloading groups without restart

* Test to make sure automation listeners are removed.

* Remove unused imports for group tests

* Simplify group config validation

* Add prepare_reload function to entity component

* Migrate group to use entity_component.prepare_reload

* Migrate automation to use entity_component.prepare_reload

* Clean up group.get_entity_ids

* Use cv.boolean for group config validation
2016-09-07 06:59:16 -07:00
Paulus Schoutsen e9813b219e Allow reloading automation without restarting HA (#3002) 2016-09-04 17:15:52 +02:00
Paulus Schoutsen c792dd4126 Fix linting 2016-09-01 09:12:42 +01:00
Paulus Schoutsen 3fa1963345 Convert automation to entities with services 2016-08-25 23:36:48 -07:00
Paulus Schoutsen d9ecc4af64 EventBus: return function to unlisten 2016-08-25 23:25:35 -07:00
happyleavesaoc 8df91e6a17 numeric state: validate multiple entities (#2066)
* validate multiple entities

* point to current entity
2016-05-14 12:29:57 -07:00
Paulus Schoutsen 8257e3f384 Fix automation deprecation warning 2016-05-07 22:31:22 -07:00
Paulus Schoutsen 79653a672d Script cleanup (#1963) 2016-05-02 22:05:09 -07:00
Paulus Schoutsen 6354399d55 Initial script condition support (#1910) 2016-04-28 12:03:57 +02:00
Paulus Schoutsen 612a017bc6 Automation: Allow embedding script definition 2016-04-21 22:36:14 -04:00
Paulus Schoutsen f76d545a08 Add script logic into helper. 2016-04-21 21:06:05 -04:00
Paulus Schoutsen 4e568f8b99 Automation: Add trigger context and expose to action 2016-04-21 13:59:42 -07:00
Paulus Schoutsen 68d92c3196 Use standardised datetime format 2016-04-16 01:46:50 -07:00
Paulus Schoutsen 948aa6838d Remove stale print 2016-04-10 18:22:25 -07:00
Jan Harkes 0ef0d4bac7 Config validation for automation MQTT trigger 2016-04-06 22:51:39 -04:00
Paulus Schoutsen 8ef542927f Add automation config validation
* Add automation config validation

* Remove unnecessary dict validator

* Downgrade voluptuous to 0.8.9

* Fix linting

* Address issues
2016-04-04 12:18:58 -07:00
pavoni e5c8dd03e1 Catch exception common during startup. 2016-03-14 10:10:38 +00:00
Paulus Schoutsen 956f6056f9 Remove support for old deprecated automation config 2016-03-13 00:00:05 -08:00
Paulus Schoutsen ddc139b853 Merge pull request #1510 from persandstrom/automation_templating
Use templates in service calls
2016-03-11 21:49:47 -08:00
Per Sandström 81e5a852f0 Use templates in service calls 2016-03-10 21:36:05 +01:00
Fabian Affolter fb7bd1bfe1 Fix PEP257 issues 2016-03-07 20:20:07 +01:00
Fabian Affolter 6ac9210919 Modify docstrings to match PEP257 2016-03-07 18:50:30 +01:00
Fabian Affolter 582394bc3b Modify import of template and PEP257 2016-02-23 21:19:22 +01:00
Stefan Jonasson e4485dcf3d Updated structure, added more tests 2016-02-22 09:40:27 +01:00
Stefan Jonasson f3c95adaca Fixed now => utcnow
Fixed added time patch to unittest
2016-02-20 22:15:49 +01:00
Stefan Jonasson ff6e071dff added the for param to the conditions as well 2016-02-20 12:52:42 +01:00
pavoni a75833cf2b Remove debug. 2016-02-19 16:41:05 +00:00
pavoni 85bf9a49ea Remove traces. 2016-02-19 15:39:44 +00:00
pavoni 9e48b88154 Add `for` delay to state automation. 2016-02-19 15:28:17 +00:00
Paulus Schoutsen e80309c03c Fix imports (using isort) 2016-02-18 21:27:50 -08:00
magnusknutas 6add5e387b Remove unused import 2016-01-26 21:41:12 +01:00
magnusknutas 2c3a6e7905 Remove not needed log warning 2016-01-26 21:30:00 +01:00
magnusknutas d4b444823c Tests for time and a fix for wrong access of _LOGGER 2016-01-26 21:11:30 +01:00
magnusknutas 33b0f4d05d Fixes bug in time trigger and adds test for ex. /two 2016-01-26 20:43:29 +01:00
magnusknutas 1f6f2de9c6 Sorry, I was wrong they are needed 2016-01-26 19:37:53 +01:00
magnusknutas 9a79ecf2d3 Remove warnings no longer needed (I think :D) 2016-01-26 19:25:41 +01:00
magnusknutas 6ae57b5aaf Some warnings if input is wrong for periodic tasks 2016-01-26 17:35:12 +01:00
magnusknutas e8e2814313 Warnings for not divisible settings 2016-01-26 17:30:55 +01:00
magnusknutas ec5d88b98e hourly periodic task 2016-01-26 17:06:50 +01:00
magnusknutas 13fbefcdf8 Running periodic tasks 2016-01-26 10:28:31 +01:00
Ryan Kraus 81dd1515ae Moved sunrise/sunset tracking to helpers
The automation component contained some very handy and generic
functions for tracking sunset and sunrise. This was moved to
helpers/event.py.
2016-01-24 15:07:09 -05:00
Ryan Kraus a65d0f0549 Reverting Automation decorator in favor of a new approach. 2016-01-24 14:44:48 -05:00
Ryan Kraus fbd68b6f89 Created automation decorator prototype
Created an initial iteration of an Automation decorator.
2016-01-23 19:39:59 -05:00
Paulus Schoutsen 3b7b12bbd5 Make Flake8 happy 2016-01-12 21:53:27 -08:00
Paulus Schoutsen 825c91f0c3 Add calling service functionality to Alexa 2016-01-08 18:54:28 -08:00
Philip Lundrigan c9ff0ab7eb Fix for sun if condition 2016-01-03 01:03:53 -07:00
Paulus Schoutsen add24915a3 ps - clean up sun automation tests 2015-12-26 17:48:20 -08:00
Philip Lundrigan 2606e4d641 Simplify if statement 2015-12-24 00:38:49 -07:00
Philip Lundrigan 8c010c8df4 Add ability to use sun as condition in automation 2015-12-21 16:09:27 -07:00
Philip Lundrigan a0ff8819a9 Make numeric_state error message more descriptive 2015-12-17 17:37:39 -07:00
Philip Lundrigan 56b38e64ae Change method of listening to state changes 2015-12-16 23:53:10 -07:00
Philip Lundrigan 4c33eba378 Prevent triggering twice 2015-12-16 15:24:09 -07:00
Philip Lundrigan ab8ff42cdd Create template automation 2015-12-16 15:24:09 -07:00
Philip Lundrigan 9fa8b27d65 Change from `value` to `state` 2015-12-15 10:12:43 -07:00
Philip Lundrigan 455a9c83a6 Simplify logic 2015-12-15 08:57:30 -07:00
Philip Lundrigan a517784c9e Condense in_range template logic 2015-12-14 15:07:35 -07:00
Philip Lundrigan 91a945f4c7 Slight style change 2015-12-14 15:01:38 -07:00
Philip Lundrigan 53239387e0 Add support for template 2015-12-14 14:47:24 -07:00
Paulus Schoutsen a3981be501 Merge pull request #681 from pavoni/add_solar_elevation
Add automations based on Solar Elevation
2015-11-29 14:14:26 -08:00
Paulus Schoutsen a301d869d7 PyLint 1.5 fixes 2015-11-29 13:49:05 -08:00
pavoni 73e3ce5044 Fix bug 2015-11-29 12:18:54 +00:00
pavoni f4c3fbe8fd Add attribuet config to numeric state platform to allow trigger based in attributes rather than states. 2015-11-29 11:56:47 +00:00
Paulus Schoutsen d4f0f0ffd3 Update automation url in warning 2015-11-22 15:10:24 -08:00
Fabian Affolter 97f9f8aa49 Update link to docs (Jekyll 3 update) 2015-11-09 13:12:18 +01:00
Fabian Affolter 185ba000dd Add link to docs 2015-10-13 21:09:11 +02:00
Fabian Affolter 771118caaf Add link to docs 2015-10-13 21:08:51 +02:00
Fabian Affolter 17d9df0da5 Add link to docs 2015-10-13 21:08:34 +02:00
Fabian Affolter e067398134 Add link to docs 2015-10-13 21:08:18 +02:00
Fabian Affolter cb69ac30ec Add link to docs 2015-10-13 21:07:53 +02:00
Fabian Affolter 241ff45c5e Add link to docs 2015-10-13 21:07:40 +02:00
Fabian Affolter c5c2f0c5f3 Add link to docs 2015-10-13 21:07:24 +02:00
Paulus Schoutsen b6d26597c0 Automation - state platfor: Flag if user makes config error 2015-10-11 18:30:25 -07:00
Paulus Schoutsen 9bdfa89b7c More robust geofence checking 2015-10-02 08:16:53 -07:00
Paulus Schoutsen 1dc9bfdf73 Update config zones 2015-09-29 23:08:37 -07:00
Paulus Schoutsen 2eb36c18bd Add geofencing to automation 2015-09-29 00:18:52 -07:00
Paulus Schoutsen 85489010bc Merge pull request #404 from stefan-jonasson/automation_confg_list
Automation confg lists
2015-09-19 20:53:26 -07:00
Paulus Schoutsen 8cd1c42e80 Merge pull request #407 from balloob/testing-upgrade
Fix CI
2015-09-19 12:55:09 -07:00
Paulus Schoutsen ec1d5e617e Fix CI 2015-09-19 12:29:23 -07:00
Stefan Jonasson 40651ef2bc Fixed old config value conversion
Added a new unit test for the config list mode
2015-09-19 21:13:09 +02:00