Commit Graph

429 Commits (91ab86c17c7901b803f5509f5a5aad99147cc2f7)

Author SHA1 Message Date
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Paulus Schoutsen da05dfe708 Add Black 2019-07-31 12:23:23 -07:00
Ville Skyttä b230562c76 Mypy config cleanups (#25475)
* Move file specific config to inline comments

* Disallow untyped defs by default everywhere
2019-07-25 08:08:20 +02:00
Ville Skyttä d64f1e767c Type check all helpers (#25373)
* Type check all helpers, add inline exclusions for work in progress

* Remove unused Script._template_cache

* Add some missing type hints

* Remove unneeded type: ignore

* Type hint fixes

* Mypy assistance tweaks

* Don't look for None in deprecated config "at most once" check

* Avoid None name slugify attempt when generating entity id

* Avoid None state store attempt on entity remove
2019-07-21 09:59:02 -07:00
Ville Skyttä 56e4a2aea6 Fix util.ruamel_yaml type errors (#25338) 2019-07-20 14:35:22 -07:00
Ville Skyttä 56841da2d3 Upgrade mypy to 0.720, turn on unreachability warnings (#25157)
* Upgrade mypy to 0.720

* Turn on mypy unreachability warnings, address raised issues
2019-07-16 15:11:38 -07:00
Ville Skyttä e8a5306c23 Upgrade mypy to 0.711, drop no longer needed workarounds (#24998)
https://mypy-lang.blogspot.com/2019/06/mypy-0711-released.html
2019-07-07 03:58:33 +02:00
Anders Melchiorsen a439e087e1 Fix time expression parsing (#24696) 2019-06-22 13:39:33 +02:00
Ville Skyttä a6eef22fbc
Upgrade mypy to 0.710 (#24666)
* Upgrade mypy to 0.710

* Address mypy 0.710 errors
2019-06-22 10:19:36 +03:00
Pascal Vizeli c9453bab19 Prefere binary with wheels (#24669) 2019-06-21 08:47:56 -07:00
Paulus Schoutsen 276ab191b5 Do not use the cache dir for PIP installs (#24233) 2019-06-01 10:04:12 +02:00
Pascal Vizeli d9852bc75d Support Hass.io wheels / docker env (#24175)
* Support Hass.io wheels / docker env

* address comments

* fix lint
2019-05-29 15:30:09 -07:00
Paulus Schoutsen 179fb0f3b5
Use importlib metadata to check installed packages (#24114)
* Use importlib metadata

* Fix script

* Remove unused import

* Update requirements"
2019-05-26 11:58:42 -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
Paulus Schoutsen 9e96397e6a
Require core config detection to be triggerd manually (#24019)
* Detect core config

* Remove elevation

* Lint

* Lint

* Fix type
2019-05-22 17:24:46 -07:00
Ties de Kock 4004867eda Split up yaml loaders into multiple files (#23774)
* Start moving parts of yaml utils to own module

Move parts of yaml loader out of the single large file and start
to create the structure of the yaml loaders in Ansible [0].

[0]: https://github.com/ansible/ansible/tree/devel/lib/ansible/parsing/yaml

* Finish yaml migration, update tests and mocks

  * Move code around to finish the migration
  * Update the mocks so that `open` is patched in
    `homeassistant.util.yaml.loader` instead of
    `homeassistant.util.yaml`.
  * Updated mypy ignores
  * Updated external API of `homeasistant.util.yaml`, see below:

Checked what part of the api of `homeassistant.util.yaml` was actually
called from outside the tests and added an `__ALL__` that contains only
these elements.

Updated the tests so that references to internal parts of the API (e.g.
the yaml module imported into `homeassistant.util.yaml.loader`) are
referenced directly from `homeassistant.util.yaml.loader`.

In `tests/test_yaml.py` the import `yaml` refers to
`homeassistant.util.yaml` and `yaml_loader` refers to `~.loader`.

Future work that remains for the next iteration is to create a custom
SafeConstructor and refers to that instead of monkey patching `yaml` with
custom loaders.

* Update mocks in yaml dumper, check_config
2019-05-09 09:07:56 -07:00
Paulus Schoutsen cc13713abd
No longer rely on requests (#23685)
* No longer rely on requests

* Lint

* Missed a few parts

* Fix types

* Fix more types

* Update __main__.py

* Fix tests

* Lint

* Fix script
2019-05-08 11:15:04 -07:00
Ville Skyttä f434e24252
Upgrade mypy (#23586)
* Upgrade mypy to 0.701

* Enable strict equality checks

* Strict equality error fixes

* StateMachine.is_state docstring fix
2019-05-02 21:18:20 +03:00
Erik Montnemery 84f778d23c Improve logging of exceptions in async_create_task (#22689)
* Improve logging of exceptions in async_create_task

* Move wrapping+logging to util.logging

* Minor refactor, fix typing

* Add test

* Remove useless @wraps, fix confusing parameter name

* Review comment
2019-04-29 09:53:22 -07:00
choss c314220167 Ignore secrets.yaml when using include_dir_named (#22929)
* ignore secrets.yaml in include_dir_named include

* updating test for include_dir_named secrets ignore
2019-04-13 21:24:06 -07:00
MatthewFlamm ed93c3b2c1 Fix pressure in dark sky and openweathermap and add pressure utility (#21210) 2019-03-24 18:37:31 +01:00
Robbie Trencheny 773c567563
Switch from using Google Maps API for elevation to Open Elevation API (#22306)
## Description:

Switches elevation helper to use [Open Elevation](https://open-elevation.com/) instead of Google Maps API which now requires a API key. It's a drop in replacement for Google Maps too!

**Related issue (if applicable):** fixes #19860

## Checklist:
  - [x] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
  - [x] There is no commented out code in this PR.
2019-03-22 16:01:43 -07:00
Quentin Stafford-Fraser 88be786e82 Make !include_dir_list use alphanumeric order (#21902)
* Make YAML includes such as !include_dir_list incorporate files in alphabetical order

* Test for !include_dir_list sorting
2019-03-20 23:10:08 -07:00
Paulus Schoutsen a9672b0d52 Load as many components in parallel as possible (#20806)
* Load as many components in parallel as possible

* Lint
2019-02-07 22:56:40 +01:00
Pascal Vizeli 29b64d56be Fix cloud webhook body (#20739)
* Bugfix cloud webhooks text response

* address comments

* Fix lint
2019-02-04 10:58:38 -08:00
starkillerOG f353d51ab1 Add check to validate gamut (#20518)
* color.util - Add check to validate gamut

* fix indents

* fix typo

* Add check to validate gamut

* Add tests for gamut checker

* fix test

* fix pylint issues

* fix hue light gamut tests

* add check to validate gamut

* move None check

* Move None check

* Include prompt to update bridge/bulb on error

* fix wrong commit

* fix error message

* Update light.py
2019-01-28 17:52:00 -08:00
Andrew Sayre 5c208da82e Added recursive detection of functools.partial. (#20284) 2019-01-20 22:27:32 -08:00
emontnemery 368682647d Log exceptions thrown by MQTT message callbacks (#19977)
* Log exceptions thrown by MQTT message callbacks

* Fix tests

* Correct method for skipping wrapper in traceback

* Lint

* Simplify traceback print

* Add test

* Move wrapper to common helper function

* Typing

* Lint
2019-01-16 13:50:21 -08:00
Fabian Affolter 25f6302813 Switch to ipapi.co (fixes #19846) (#19886)
* Switch to ipapi.co (fixes #19846)

* Fix name

* Update name
2019-01-15 16:18:57 -08:00
starkillerOG 11602c1da0 Improve Philips Hue color conversion 2 (#20118)
* Add gamut capability to color util

* Include gamut in hue_test

* Improve Philips Hue color conversion

* correct import for new location hue.light

* include file changes between PR's

* update aiohue version

* update aiohue version

* update aiohue version

* fix hue_test

Now Idea why it failed compared to the previous time

* Include gamut in hue_test

* fix hue_test

* Try to test hue gamut conversion

supply a color that is well outside the color gamut of the light, and see if the response is correctly converted to within the reach of the light.

* switch from gamut A to gamut B for the tests.

* remove white space in blanck line

* Fix gamut hue test

* Add Gamut tests for the util.color

* fix hue gamut test

* fix hue gamut test

* Improve Philips Hue color conversion
2019-01-15 11:30:50 -08:00
Pascal Vizeli 2bf36bb1db
Use unicode slugify (#19192)
* Update __init__.py

* Update setup.py

* Update requirements_all.txt

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* remove `-`

* fix packages

* Update package_constraints.txt

* Update __init__.py

* Update package_constraints.txt

* Update requirements_all.txt

* Update setup.py

* Fix tests

* Fix line issue

* fix all test

* fix type

* Fix lint
2018-12-17 07:51:13 +01:00
Ville Skyttä 7d3a962f73
Upgrade mypy to 0.650 (#19150)
* Upgrade to 0.650

* Remove no longer needed type: ignore
2018-12-09 21:22:08 +02: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 7848381f43
Allow managing cloud webhook (#18672)
* Add cloud webhook support

* Simplify payload

* Add cloud http api tests

* Fix tests

* Lint

* Handle cloud webhooks

* Fix things

* Fix name

* Rename it to cloudhook

* Final rename

* Final final rename?

* Fix docstring

* More tests

* Lint

* Add types

* Fix things
2018-11-26 14:10:18 +01:00
Bram Kragten 37327f6cbd Add save command to lovelace (#18655)
* Add save command to lovelace

* Default for save should by json

* typing
2018-11-23 22:56:58 +01:00
Bram Kragten b8c06ad019 Fix including from sub dir (#18378)
The include path is now always relative to the root of the config dir.
2018-11-11 17:15:58 +01:00
Bram Kragten abf147ed57 Check if os has chown (#18229) 2018-11-05 21:41:19 +01:00
Bram Kragten b763c0f902 Extract ruamel.yaml to util with secrets, lovelace ws decorators (#17958)
* Extract ruamel.yaml to util, ws decorators, secrets

* lint

* Extend SafeConstructor

Somehow my last commit is gone after rebase...

* lint

* Woof...

* Woof woof...

* Cleanup type hints

* Update homeassistant/scripts/check_config.py

* lint

* typing
2018-10-31 13:49:54 +01:00
Nicko van Someren 50f0eac7f3 Fixed issue #16903 re exception with multiple simultanious writes (#17636)
Reworked tests/components/emulated_hue/test_init.py to not be
dependent on the specific internal implementation of util/jsonn.py
2018-10-23 10:54:03 +02:00
uchagani cffb704311 Enable BMW component to be unit system aware (#17197)
* Enable BMW component to be unit system aware

* lint fixes

* use constants for config entries

* remove configuration from component and rely only on HA config of unit_system

* remove unused import

* update code to reflect feedback

* lint fixes

* remove unnecessary comments

* rework return statement to satisfy pylint

* more lint fixes

* add tests for volume utils

* lint fixes

* more lint fixes

* remove unnecessary comments
2018-10-11 10:55:22 +02:00
Ville Skyttä 707b7c202d Narrow scope of various pylint inline disables (#15364)
* Narrow scope of various pylint inline disables

* Whitespace tweaks
2018-10-10 12:17:11 +02:00
Otto Winter 26cf5acd5b Make async_track_time_change smarter (#17199)
* Make async_track_time_change smarter

* Move to util/dt

* Remove unnecessary check

* Lint

* Remove tzinfo check

* Remove check

* Add comment about async_track_point_in_utc_time

* Fix typing check

* Lint
2018-10-09 10:14:18 +02:00
Nicko van Someren b0b3620b2b Added working support for private storage (#16903)
* Fixed file corruption bugs in private storage code.

* Restoring fixed test case.

* Implemented test suite for utils/json.py

* Added new unit test cases for util/json.py

* Dixed formatting nags

* Fixed more nags from the Hound

* Added doc strings to some very short functions

* Fixing lint's complains about my choice of parts of speach. Sigh.

* Moved atomic save operations down into util/json.py so that all benefit.

Added extra clean-up code to ensure that temporary files are removed in
case of errors.
Updated emulated_hue unit tests to avoid errors.

* Apparently 'e' is not allows as a variable name for an exception...
2018-10-02 10:16:43 +02:00
Paulus Schoutsen 1decba0052
Proactor policy fix (#17066)
* Proactor policy fix

* Backport Proactor policy for <py37
2018-10-02 09:55:37 +02:00
Jason Hu 1667481342 Use Protractor loop in Windows (#17061)
* Use Protractor loop in Windows

* Add import sys
2018-10-02 09:21:02 +02:00
Paulus Schoutsen f5632a5da5
Add webhook + IFTTT example (#16817)
* Add webhook + IFTTT example

* Abort if not externally accessible

* Abort on local url

* Add description to create entry

* Make body optional

* Allow ifttt setup without config

* Add tests

* Lint

* Fix Lint + Tests

* Fix typing
2018-09-30 14:45:48 +02:00
Paulus Schoutsen 631ecf578e Lint 2018-09-26 23:48:55 +02:00
Paulus Schoutsen d0ddc28f96
Revert file mode write_json (#16897) 2018-09-26 17:58:44 +02:00
Nicko van Someren e5861241c7 Added support for private storage. (#16878)
* Addded support for private storage.

Include 'private' flag parameters to the Store class and save_json function.
Updated various authentication and onboarding classes to use private stores.
Fixed unit test for emulated_hue which used a mock patch on save_json().

* Fixed Hound formatting issues not detected by local linting.
2018-09-26 10:24:32 +02:00
Matthias Urlichs 0121e3cb04 Remove usage of "run_until_complete" (#16617)
* De-run_forever()-ization

* Use asyncio.run (or our own implementation on Python <3.7)
* hass.start is only used by tests
* setup_and_run_hass() is now async
* Add "main" async hass.run method
* move SIGINT handling to helpers/signal.py
  * add flag to .run to disable hass's signal handlers
* Teach async_start and async_stop to not step on each other
  (more than necessary)

* shorten over-long lines

* restore missing "import asyncio"

* move run_asyncio to homeassistant.util.async_

* LOGGER: warn => warning

* Add "force" flag to async_stop

only useful for testing

* Add 'attrs==18.2.0' to requirements_all.txt

Required for keeping requirements_test_all.txt in sync, where it is in
turn required to prevent auto-downgrading "attrs" during "pip install"

* Fixes for mypy

* Fix "mock_signal" fixture

* Revert mistaken edit

* Flake8 fixes

* mypy fixes

* pylint fix

* Revert adding attrs== to requirements_test*.txt

solved by using "pip -c"

* Rename "run" to "async_run", as per calling conventions
2018-09-19 15:40:02 +02:00
Ville Skyttä ee696643cd Isort preparations (#16555)
* Don't treat typing as an "in-between" module for import order

That was a < 3.5 era thing.

* Tighten scope of some pylint unused-import disables

To avoid isort moving a top level one around, undesirably broadening its
scope.
2018-09-11 11:21:48 +02:00
Paulus Schoutsen 09dc4d663d
Improve package loadable (#16237)
* Add caching to package loadable

* Fix tests

* Improve package loadable

* Lint

* Typing
2018-08-28 12:52:18 +02:00
Paulus Schoutsen a14980716d
Package loadable: compare case insensitive (#16234) 2018-08-28 10:53:12 +02:00
Paulus Schoutsen 2e6cb2235c Check correctly if package is loadable (#16121) 2018-08-22 12:17:14 +02:00
Ville Skyttä 3800f00564 Disable assuming Optional type for values with None default (#16029)
https://www.python.org/dev/peps/pep-0484/#union-types
"Type checkers should move towards requiring the optional type to be
made explicit."
2018-08-17 20:22:49 +02:00
Paulus Schoutsen 6540d2e073
Switch to intermediate Mozilla cert profile (#15957)
* Allow choosing intermediate SSL profile

* Fix tests
2018-08-14 08:20:17 +02:00
Jason Hu 1e5596b594 Remove self type hints (#15732)
* Remove self type hints

* Lint
2018-07-30 12:44:31 +01:00
Ville Skyttä eee9b50b70 Upgrade pylint to 2.0.1 (#15683)
* Upgrade pylint to 2.0.1

* Pylint 2 bad-whitespace fix

* Pylint 2 possibly-unused-variable fixes

* Pylint 2 try-except-raise fixes

* Disable pylint fixme for todoist for now

https://github.com/PyCQA/pylint/pull/2320

* Disable pylint 2 useless-return for now

https://github.com/PyCQA/pylint/issues/2300

* Disable pylint 2 invalid-name for type variables for now

https://github.com/PyCQA/pylint/issues/1290

* Disable pylint 2 not-an-iterable for now

https://github.com/PyCQA/pylint/issues/2311

* Pylint 2 unsubscriptable-object workarounds

* Disable intentional pylint 2 assignment-from-nones

* Disable pylint 2 unsupported-membership-test apparent false positives

* Disable pylint 2 assignment-from-no-return apparent false positives

* Disable pylint 2 comparison-with-callable false positives

https://github.com/PyCQA/pylint/issues/2306
2018-07-26 08:55:42 +02:00
Ville Skyttä 1c42caba76 Pylint 2 useless-return fixes (#15677) 2018-07-25 19:35:57 +02:00
Andrey 140a874917 Add typing to homeassistant/*.py and homeassistant/util/ (#15569)
* Add typing to homeassistant/*.py and homeassistant/util/

* Fix wrong merge

* Restore iterable in OrderedSet

* Fix tests
2018-07-23 10:24:39 +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ä 2f7b79764a More pylint 2 fixes (#15565)
## Description:

More fixes flagged by pylint 2 that don't hurt to have before the actual pylint 2 upgrade (which I'll submit soon).

## Checklist:
  - [ ] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
2018-07-20 11:45:20 +03:00
Paulus Schoutsen 4650366f07
Don't be so strict client-side (#15546) 2018-07-18 23:00:26 +02:00
Andrey 24d2261060 Add check_untyped_defs (#15510)
* Add check_untyped_defs

* Change to regular if-else
2018-07-18 00:28:44 +02:00
Paulus Schoutsen ad4cba70a0
Extract SSL context creation to helper (#15483)
* Extract SSL context creation to helper

* Lint
2018-07-16 10:32:07 +02:00
Andrey e60f9ca392
More typing (#15449)
## Description:

More typing improvements.

Switch to using `mypy.ini` for flexibility

Add `warn_return_any` check except in `homeassistant.util.yaml` that does typing hacks. Fix some type annotations as resulting from this check and ignore others were fixing is hard.

## Checklist:
  - [x] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
2018-07-13 20:14:45 +03:00
Andrey c2fe0d0120
Make typing checks more strict (#14429)
## Description:

Make typing checks more strict: add `--strict-optional` flag that forbids implicit None return type. This flag will become default in the next version of mypy (0.600)

Add `homeassistant/util/` to checked dirs.

## Checklist:
  - [x] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
2018-07-13 13:24:51 +03:00
Ville Skyttä b92350fb55 Lint cleanup (#15103)
* Remove unneeded inline pylint disables

* Remove unneeded noqa's

* Use symbol names instead of message ids in inline pylint disables
2018-06-25 13:05:07 -04:00
Paulus Schoutsen ae51dc08bf
Add storage helper and migrate config entries (#15045)
* Add storage helper

* Migrate config entries to use the storage helper

* Make sure tests do not do I/O

* Lint

* Add versions to stored data

* Add more instance variables

* Make migrator load config if nothing to migrate

* Address comments
2018-06-25 12:53:49 -04:00
Paulus Schoutsen 0b114f0755
Do not mount deps folder when running in virtual env (#14993)
* Do not mount deps folder when inside virtual env

* Add tests

* Fix package test
2018-06-16 10:48:41 -04:00
Ville Skyttä 4bd7a7eee3 Remove inline pylint disables for messages disabled in pylintrc (#14978) 2018-06-16 00:15:46 +02:00
Otto Winter a4bf421044 Convert more files to async/await syntax (#14142)
* Move more files to async/await syntax

* Attempt Work around pylint bug

Using lazytox :P
2018-04-28 19:26:20 -04:00
Anders Melchiorsen 9c1bc18def Fix too green color conversion (#13828)
* Prepare test

* Fix too green color conversion

* Fix remaining tests
2018-04-11 20:58:57 -04:00
Albert Lee 5801d78017 Implement thermostat support for Alexa (#13340)
* Implement thermostat support for Alexa

* util.temperature: Support interval conversions

* Use climate.ATTR_OPERATION_MODE for Alexa thermostat mode

* Switch coroutines to async/await

* Log all Alexa error events
2018-03-29 23:49:08 -07:00
Adam Mills 89c7c80e42 Use hue/sat as internal light color interface (#11288)
* Accept and report both xy and RGB color for lights

* Fix demo light supported_features

* Add new XY color util functions

* Always make color changes available as xy and RGB

* Always expose color as RGB and XY

* Consolidate color supported_features

* Test fixes

* Additional test fix

* Use hue/sat as the hass core color interface

* Tests updates

* Assume MQTT RGB devices need full RGB brightness

* Convert new platforms

* More migration

* Use float for HS API

* Fix backwards conversion for KNX lights

* Adjust limitless min saturation for new scale
2018-03-18 15:00:29 -07:00
Otto Winter 3442b6741d
Fix WUnderground duplicate entity ids (#13285)
* Fix WUnderground duplicate entity ids

* Entity Namespace
2018-03-17 13:14:53 +01:00
Paulus Schoutsen 5a9013cda5
Refactor Hue: phue -> aiohue (#13043)
* phue -> aiohue

* Clean up

* Fix config

* Address comments

* Typo

* Fix rebase error

* Mark light as unavailable when bridge is disconnected

* Tests

* Make Throttle work with double delay and async

* Rework update logic

* Don't resolve host to IP

* Clarify comment

* No longer do unnecessary updates

* Add more doc

* Another comment update

* Wrap up tests

* Lint

* Fix tests

* PyLint does not like mix 'n match async and coroutine

* Lint

* Update aiohue to 1.2

* Lint

* Fix await MagicMock
2018-03-16 20:27:05 -07:00
Pascal Vizeli 0ef4340099 Fix freegeoip (#13193) 2018-03-13 20:50:08 -07:00
Otto Winter 890197e407
asyncio.ensure_future Python 3.5 (#13141) 2018-03-12 19:42:08 +01:00
Matthias Urlichs f5cc40024d Rename homeassistant.util.async to .async_ (#13088)
"async" is (going to be) a reserved word.
2018-03-11 10:01:12 -07:00
Johann Kellerman f164a5a65f
Better errors for unknown secrets (#13072) 2018-03-11 12:51:03 +02:00
Paulus Schoutsen 36361d623d
Make Throttle async aware (#13027)
* Make Throttle async aware

* Lint
2018-03-09 19:38:51 -08:00
Paulus Schoutsen 38af04c6ce
Reinstate our old virtual env check in favor of pip (#12932) 2018-03-05 15:51:37 -08:00
Adam Mills b434ffba2d Support serving of backend translations (#12453)
* Add view to support backend translation fetching

* Load backend translations from component json

* Translations for season sensor

* Scripts to merge and unpack Lokalise translations

* Fix copy paste error

* Serve post-lokalise translations to frontend

* Linting

* Auto-deploy translations with Travis

* Commit post-lokalise translation files

* Split logic into more helper functions

* Fall back to English for missing keys

* Move local translation copies to `.translations`

* Linting

* Initial tests

* Remove unnecessary file check

* Convert translation helper to async/await

* Convert translation helper tests to async/await

* Use set subtraction to find missing_components

* load_translation_files use component->file mapping

* Remove duplicated resources fetching

Get to take advantage of the slick Python 3.5 dict merging here.

* Switch to live project ID
2018-02-28 19:31:38 -08:00
Paulus Schoutsen efd155dd3c
Intent: Set light color (#12633)
* Make color_name_to_rgb raise

* Add Light Set Color intent

* Move some methods around

* Cleanup

* Prevent 1 more func call

* Make a generic Set intent for light

* Lint

* lint
2018-02-27 18:02:21 -08:00
Adam Mills c1a6131aa8
Update core HSV color scaling to standard scales: (#12649)
Hue is scaled 0-360
Sat is scaled 0-100
Val is scaled 0-100
2018-02-26 22:20:24 -05:00
Julius Mittenzwei 16cb7388ee Removing asyncio.coroutine syntax from HASS core (#12509)
* changed asyncio.coroutine syntax to new async def/await

* removed py34 from tox environment

* reverted some changes within entity.py

* -

* reverted changes within bootstrap.py

* reverted changes within discovery.py

* switched decorators

* Reverted change within aiohttp_client.py

* reverted change within logging.py

* switched decorators

* Await lock properly

* removed asyncio.coroutine from test
2018-02-25 03:38:46 -08:00
Frederik Bolding 60148f3e83 Converted shopping list to use json util and added default override for json util (#12478)
* Converted shopping list to use json util, Added default override for json util

* Reverted accidental revert

* Fixed pylint issue
2018-02-18 13:11:24 -08:00
Otto Winter 678f284015 Upgrade pylint to 1.8.2 (#12274)
* Upgrade pylint to 1.8.1

* Fix no-else-return

* Fix bad-whitespace

* Fix too-many-nested-blocks

* Fix raising-format-tuple

See https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/1.8.rst

* Fix len-as-condition

* Fix logging-not-lazy

Not sure about that TEMP_CELSIUS though, but internally it's probably just like if you concatenated any other (variable) string

* Fix stop-iteration-return

* Fix useless-super-delegation

* Fix trailing-comma-tuple

Both of these seem to simply be bugs:
 * Nest: The value of self._humidity never seems to be used anywhere
 * Dovado: The called API method seems to expect a "normal" number

* Fix redefined-argument-from-local

* Fix consider-using-enumerate

* Fix wrong-import-order

* Fix arguments-differ

* Fix missed no-else-return

* Fix no-member and related

* Fix signatures-differ

* Revert "Upgrade pylint to 1.8.1"

This reverts commit af78aa00f125a7d34add97b9d50c14db48412211.

* Fix arguments-differ

* except for device_tracker

* Cleanup

* Fix test using positional argument

* Fix line too long

I forgot to run flake8 - shame on me... 🙃

* Fix bad-option-value for 1.6.5

* Fix arguments-differ for device_tracker

* Upgrade pylint to 1.8.2

* 👕 Fix missed no-member
2018-02-11 09:20:28 -08:00
Ville Skyttä cab6c694c5 Flake8 bugbear fixes (#12072)
* Don't use mutable argument defaults (bugbear B006)

* Use callable(x) instead of hasattr(x, '__call__') (bugbear B004)

* Remove/mark unused loop control variables (bugbear B007)

* Fix stripping protocol from kodi host name (bugbear B005)

* Fix plant daily history add default date (bugbear B008)
2018-01-30 14:44:05 -08:00
Paulus Schoutsen e51427b284 Entity registry (#11979)
* Entity#unique_id defaults to None

* Initial commit entity registry

* Clean up unique_id property

* Lint

* Add tests to entity component

* Lint

* Restore some unique ids

* Spelling

* Remove use of IP address for unique ID

* Add tests

* Add tests

* Fix tests

* Add some docs

* Add one more test

* Fix new test…
2018-01-30 10:39:39 +01:00
Ville Skyttä 384f63dd1d Typing fixes (#12015)
* .gitignore: Add .mypy_cache

* Typing fixes
2018-01-29 00:24:08 -08:00
Ville Skyttä 55ee8959ba Spelling fixes (#11940) 2018-01-27 11:58:27 -08:00
Andrea Campi e627544479 Always consume the no_throttle keyword argument. (#11126)
The current code relies on the assumption that the first invocation will never specify no_throttle=True.
However that puts us in a pickle when writing unit tests: if we had a fictitious:

  def setup_platform():
    update()

  @Throttle(MIN_TIME_BETWEEN_SCANS)
  def update():
    pass

Then given multiple tests, the second and some of subsequent tests would be throttled (depending on timing).
But we also can't change that code to call `update(no_throttle=True)' because that's not currently accepted.

This diff shouldn't change the visibile behavior of any component, but allows this extra flexibility.
2017-12-13 20:01:59 -08:00
Per Osbäck 2daea92379 make RGB values consistent as int. fixes #10766 (#10782)
* make RGB consitant as int. fixes #10766

* fix rounding and only change for hex convertion
2017-11-27 11:31:35 +01:00
Andrey d5cba0b716 Allow unicode when dumping yaml (#10607) 2017-11-15 18:24:08 -08:00
Erik Eriksson 4e8723f345 Extracted json saving and loading (#10216) 2017-11-01 09:08:28 +01:00
Pascal Vizeli 8c266f9266 Alexa SmartHome API extend (#10251)
* Implement adjustment

* Add color support

* fix lint

* Fix lint & use only RGB

* fix HSB + Test

* Add tests & fix bugs

* add rgb test

* add setColorTemperature

* Add color light support + tests

* Fix color temp

* use kelvin for converting

* use correct calculation
2017-10-31 20:28:17 -07:00
Paulus Schoutsen 79b029a680 Do not auto-install credstash (#9844) 2017-10-12 23:57:45 -07:00
happyleavesaoc b83059c828 move icon battery function from util to helpers (#9708) 2017-10-05 20:55:19 -07:00
Paulus Schoutsen 75f902f57e RFC: Create a secrets file and enable HTTP password by default (#9685)
* Create a secret and enable password by default

* Comment out api password secret

* Lint/fix tests
2017-10-05 09:10:29 -07:00
Adam Mills c4810da82f Unit tests to improve core coverage (#9659)
* Code coverage of logging util

* Improve async util coverage

* Add test coverage for restore_state

* get_random_string test
2017-10-02 20:25:04 -07:00
Paulus Schoutsen 1baf0da627 Clean up OwnTracks (#9569)
* Clean up OwnTracks

* Address comments
2017-09-25 09:05:09 -07:00
Michael Prokop 08b0629eca Fix a bunch of typos (#9545)
s/Addres /Address /
s/Chnage/Change/
s/Converion/Conversion/
s/Supressing/Suppressing/
s/agains /against /
s/allready/already/
s/analagous/analogous/
s/aquired/acquired/
s/arbitray/arbitrary/
s/argment/argument/
s/aroung/around/
s/attibute/attribute/
s/auxillary/auxiliary/
s/befor /before /
s/commmand/command/
s/conatin/contain/
s/conection/connection/
s/coresponding/corresponding/
s/entites/entities/
s/enviroment/environment/
s/everyhing/everything/
s/expected expected/expected/
s/explicity/explicitly/
s/formated/formatted/
s/incomming/incoming/
s/informations/information/
s/inital/initial/
s/inteface/interface/
s/interupt/interrupt/
s/mimick/mimic/
s/mulitple/multiple/
s/multible/multiple/
s/occured/occurred/
s/occuring/occurring/
s/overrided/overridden/
s/overriden/overridden/
s/platfrom/platform/
s/positon/position/
s/progess/progress/
s/recieved/received/
s/reciever/receiver/
s/recieving/receiving/
s/reponse/response/
s/representaion/representation/
s/resgister/register/
s/retrive/retrieve/
s/reuqests/requests/
s/segements/segments/
s/seperated/separated/
s/sheduled/scheduled/
s/succesfully/successfully/
s/suppport/support/
s/targetting/targeting/
s/thats/that's/
s/the the/the/
s/unkown/unknown/
s/verison/version/
s/while loggin out/while logging out/
2017-09-23 17:15:46 +02:00
Paulus Schoutsen 5696e38dd6 Warn instead of raise on duplicate YAML key (#8834)
* Warn instead of raise on duplicate key

* Update test_yaml.py

* Lint

* Change to error
2017-08-06 10:47:19 -07:00
Paulus Schoutsen ac9c1235bb Allow get local ip to work without internet (#8855) 2017-08-06 09:15:17 -07:00
Eugenio Panadero 96f8c37dcd Xiaomi vacuum as platform of new `vacuum` component derived from ToggleEntity, and services (#8623)
* Xiaomi vacuum as component with switch, sensors and services

- Conversion from switch platform to async component.
- Add services proposed in #8416 to the new component, with shorter names.
- Add sensors for the vacuum robot as a selectable list from `battery`, `state`, `error`, `fanspeed`, `clean_time` and `clean_area` (the state attributes of the switch). The sensors don't poll, but listen to a signal to update the state, the switch fires this signal when updating.
- Assign default icons to sensors and the switch (`mdi:google-circles-group` looks like the robot!)

* path change in requirements_all (from switch platform to component)

* copy pasting is a bad habit

* services to the components services.yaml, modify .coveragerc

* review: use with multiple hosts, fix calls to async_add_devices, fix ranges for services

* `icon_for_battery_level` util method

* Xiaomi vacuum as platform of new component vacuum

- Created new component `vacuum` from a ToggleEntity.
- Add services `turn_on`, `turn_off`, `cleaning_play_pause`, `stop`, `return_to_base`, `locate`, `set_fanspeed` and `send_command`.
- Remove the main switch for the xiaomi vacuum (the toggable main entity is the switch).
- Add `support flags` for the common services
- Assign default icons to sensors and the switch (`mdi:google-circles-group` looks like the robot!)
- Move services descriptions to a yaml file for the new component.
- Update requirements_all.
- Update coveragerc.

* fix coveragerc

* fix battery icon helper to use more icons

* remove sensors, create properties and support flags for custom UI

* cleaning

* updated state_attrs for filtering in UI, renamed platform to simply `xiaomi`

* fix platform rename

* change fanspeed and expose `fanspeed_list` to use speed steps

* minor fixes

- Rename service `start_pause`
- Add 'Error' attribute only if `got_error`.
- Minor changes

* rename state attrs

* rename state attrs

* review changes: cut fan__speed, style changes, remove logging, and more

* add ATTR_COMMAND = 'command' to const

* pop entity_id from service data

* remove property accessor for vacuum object

* lint fix

* fix extra attrs names

* module level functions for calling the services

* params as optional keyword for `send_command`

* params as optional keyword for `send_command`, remove debug logs

* explicit parameters for `set_fan_speed` and `send_command`

* Demo platform for the vacuum component

* vacuum tests for the Demo platform

* some fixes

* don't omit vacuum

* vacuum tests for the Xiaomi platform

* fix test

* fix

* fix xiaomi test

* fix coveragerc

* test send command

* fix coveragerc

* fix string formatting

* The coverage is to low. It need 93% or more
2017-08-04 15:27:10 +02:00
Corey Pauley ecc1429453 Added support for default value when environment variable is missing (#8484)
* Added support for a default value when an environment variable is missing

* Shouldn't have used docstring
2017-07-24 09:00:01 -07:00
Justin Dray 98568b5eb7 Add support for using credstash as a secret store (#8494) 2017-07-24 08:59:10 -07:00
Martin Hjelmare 543e8bb62e Fix check for running inside venv (#8481)
* Import and use the function from pip instead of defining it
  ourselves.
* Fix tests.
2017-07-15 07:25:02 -07:00
Martin Hjelmare ba019c799a Make deps directory persistent over upgrades (#7801)
* Use pip install --user if venv not active

* Set PYTHONUSERBASE to deps directory, when installing with --user
  option.
* Reset --prefix option to workaround incompatability when installing
  with --user option. This requires pip version 8.0.0 or greater.
* Require pip version 8.0.3.
* Do not delete deps directory on home assistant upgrade.
* Fix local lib mount and check package exist.

* Update and add tests

* Fix upgrade from before version 0.46

* Extract function to get user site

* Add function(s) to package util to get user site.
* Use async subprocess for one of the functions to get user site.
* Add function to package util to check if virtual environment is
  active.
* Add and update tests.

* Update version for last removal of deps dir

* Address comments

* Rewrite package util tests with pytest

* Rewrite all existing unittest class based tests for package util as
  test functions, and capitalize pytest fixtures.
* Add test for installing with target inside venv.
2017-07-13 19:26:21 -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
Anders Melchiorsen 9e16be3173 LIFX: clean up internal color conversions (#7964)
* Add color_util.color_hsv_to_RGB

* Use helper functions for LIFX conversions

The LIFX API uses 16 bits for saturation/brightness while HA uses 8 bits.
Using helper functions makes the conversion a bit nicer and less prone
to off-by-one issues.

The colorsys library uses 0.0-1.0 but we can avoid that by using the HA
color_util converters instead.
2017-06-11 21:19:58 +02:00
Fabian Affolter 0863d50210 Fix typos (#7957)
Add an optional extended description…
2017-06-08 15:53:12 +02:00
Fabian Affolter a4f1f6e724 Update docstrings (#7374)
* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
2017-05-02 09:18:47 -07:00
Paulus Schoutsen da2521a299 Fix YAML dump (#7388)
* Fix YAML dump

* Add test
2017-05-01 20:09:49 -07: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
Anders Melchiorsen 64a7be66b1 Remove global limit on white light temperature (#7206)
* Remove global limit on white light temperature

Here are the supported temperatures of some popular bulbs:

 Philips Hue: 2000K-6500K (the current 500-154 mired range)
 LIFX Color 1000: 2500K-9000K
 IKEA TRÅDFRI: 2200K, 2700K, 4000K

Obviously, Home Assistant cannot enforce a global limit and work properly
with all of these bulbs. So just remove the limit and leave it up to each
platform to work it out.

This commit updates the existing users and adds a clamp to Hue (where the
limit appears to have originated). It does not attempt to update other
platforms that might need extra handling of the larger range that is now
possible.

* Add min_mireds/max_mireds state attributes to lights

* Support min_mireds/max_mireds with LIFX lights
2017-04-29 15:04:20 -07:00
Anders Melchiorsen d1121478ab Reduce color_xy_brightness_to_hsv to color_xy_to_hs (#7320)
This makes more sense because the input and output brightness is the same.

We currently convert through RGB which does contain a brightness so we supply
an arbitrary value as input and discard the output.
2017-04-27 00:59:49 -07:00
Pierre Ståhl f5dd25c87f Capture and log pip install error output (#7200)
Add an optional extended description…
2017-04-21 14:15:05 +02:00
Fabian Affolter 8ba41563c9 Disable invalid-sequence-index (#7177) 2017-04-19 14:09:00 +02:00
Patrik 75242e67a7 IKEA Tradfri Gateway: added support for RGB (#7115)
* After rebase and all fixes

* Added color_rgb_to_hex to util.color

* Added test_color_rgb_to_hex

* Changed reference to color_rgb_to_hex

* Bumped to pytradfri 0.5, having support for retry

* Bumped to pytradfri 0.5, having support for retry

* Bumped to pytradfri 0.5, having support for retry

* Bumped to pytradfri 0.5, having support for retry

* Rolled back to 0.4

* Rolled back to 0.4
2017-04-16 11:35:52 -07:00
micw 3c35d5ea58 Fix/slugify with german umlaut ss (#7029)
* more tests for slugify

* Fix german umlauts in slugify

* Update __init__.py
2017-04-11 19:51:07 -07:00
Beat ee8701b560 Fix configuration setup (#6853)
When the user exceeds the request limit for google APIs, the response status stays at 200 but the response body is different:
```
{
   "error_message" : "You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_",
   "results" : [],
   "status" : "OVER_QUERY_LIMIT"
}
```
This prevents HA from creating the initial configuration
2017-03-30 15:26:11 +02: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
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
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
Paulus Schoutsen b969fea900 Z-Wave config panel fix (#6113) 2017-02-19 22:25:03 -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
Andrzej 34c7bac9b4 Update package.py (#5783) 2017-02-06 22:16:17 +01:00
Paulus Schoutsen 7511a5842d Fix load_yaml default value (#5383) 2017-01-16 22:08:47 -08:00
Johann Kellerman b67cce7215 Add correct line numbers for yaml include directives (#5303) 2017-01-13 21:13:17 -08:00
Pascal Vizeli 0ecd185f0d Bugfix close async log handler (#5086) 2016-12-29 17:27:58 +01:00
Pascal Vizeli 334b3b8636 Bugfix async log handle re-close bug (#5034)
* Bugfix async log handle re-close bug

* Check on running thread on async_close

* Fix now on right place
2016-12-22 16:08:01 +01:00
Paulus Schoutsen 01e6bd2c92 Gracefully exit with async logger (#4965)
* Gracefully exit with async logger

* Lint
2016-12-18 00:14:59 -08:00
Pascal Vizeli 50c8224365 Bugfix async log handler (#4954)
* Bugfix async log handler

* fix boostrap test

* Use hass.data for store handler and cleanup on async_stop

* Update bootstrap.py
2016-12-17 12:21:52 -08:00
Pascal Vizeli 6d6abab358 Async logging file handler (#4901)
* Async logging file handler

* add time rotation handle

* new layout

* address paulus comments

* fix lint
2016-12-16 15:51:06 -08:00
Charles Spirakis ad4ec49f9c Update color names to follow w3.org list. (#4374)
The color names -> rgb dictionary now follows the
color names listed in the w3.org site for css3,
section 4.3. Extended color keywords:

https://www.w3.org/TR/2010/PR-css3-color-20101028/#svg-color
2016-11-28 22:59:46 -08:00
Johan Bloemberg 601193b1d2 Expose isort preferences for tools. (#4481)
* Expose isort preferences for tools.

* Adhere to pylints sorted imports requirement.

* More documentation, set typing in between stdlib and 3rd party.
2016-11-27 14:33:30 -08:00
Paulus Schoutsen 32ffd006fa Reorganize HTTP component (#4575)
* Move HTTP to own folder

* Break HTTP into middlewares

* Lint

* Split tests per middleware

* Clean up HTTP tests

* Make HomeAssistantViews more stateless

* Lint

* Make HTTP setup async
2016-11-25 13:04:06 -08:00
Paulus Schoutsen 2c7e895105 Entity and climate: do not convert temperature unnecessary (#4522)
* Climate: more consistent units

* Prevent unnecessary conversion in entity component

* int -> round

* Disable Google tests because they connect to the internet

* Remove default conversion rounding F->C

* Add rounding of temp to weather comp

* Fix equality

* Maintain precision when converting temp in entity

* Revert "Disable Google tests because they connect to the internet"

This reverts commit b60485dc19.
2016-11-22 17:38:04 -08:00
Paulus Schoutsen d2bbc6ef70 Upgrade linter (#4461) 2016-11-18 21:47:59 -08:00
Pascal Vizeli c56f99baaf Async migration device_tracker (#4406)
* Async migration device_tracker

* change location stuff to async

* address paulus comments

* fix lint & add async discovery listener

* address paulus comments v2

* fix tests

* fix test_mqtt

* fix test_init

* fix gps_acc

* fix lint

* change async_update_stale to callback
2016-11-18 23:35:08 +01:00
Magnus Ihse Bursie b0e3d5a576 Better handling of accented characters in slugify (#4399) (#4423)
* Better handling of accented characters in slugify (#4399)

* Update __init__.py
2016-11-16 15:05:10 -08:00
Pascal Vizeli ece58ce78f Remove ThreadPool with async executor (#4154)
* Remove ThreadPool with async executor

* Fix zigbee

* update unittest

* fix remote api

* add pending task to remote

* fix lint

* remove unused import

* remove old stuff for lazy tests

* fix bug and add a exception handler to executor

* change executor handling

* change to wait from gather

* fix unittest
2016-11-05 09:27:55 -07:00
Fabian Affolter c128919b5f Remove globally disabled pylint warnings (#4204) 2016-11-03 18:40:43 -07:00
Johann Kellerman e487a09190 Remove None value before writing known_devices (#4098)
* Remove None

* Replace null
2016-11-01 21:51:31 -07:00
Paulus Schoutsen 7f699b4261 Lazy initialise the worker pool (#4110)
* Lazy initialise the worker pool

* Minimize pool initialization in core tests

* Fix tests on Python 3.4

* Remove passing in thread count to mock HASS

* Tests: Allow pool by default for threaded, disable for async

* Remove JobPriority for thread pool

* Fix wrong block_till_done

* EmulatedHue: Remove unused test code

* Zigbee: do not touch hass.pool

* Init loop in add_job

* Fix core test

* Fix random sensor test
2016-10-31 08:47:29 -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 d5368f6f78 Async bootstrap / component init (#3991)
* Async bootstrap

* Adress comments

* Fix tests

* More fixes

* Tests fixes
2016-10-27 00:16:23 -07:00
Per Sandström 0dfcf40d37 [WIP] Config validation error line numbers (#3976)
Config validation error line numbers
2016-10-25 20:13:32 +02:00
Johann Kellerman 5df8477536 Catch UnicodeDecodeError Error (#4007)
* Catch UnicodeDecodeError Error 

Error for #3933

* Forgot (exc)

* catch...

* Tests by @lwis

* Docstring

* Create open
2016-10-23 18:55:06 -07:00
Lewis Juggins 13ab2be5f6 Exclude dirs/files prefixed with . (#3986) 2016-10-23 16:47:06 +02:00
Lewis Juggins 10feac11d9 Support recursive config inclusions (#3783) 2016-10-12 12:05:41 +02:00
Pascal Vizeli f1e5d32ef5 Async exception handling (#3731)
* remove unused exception

* add logging

* disable pylint broad-except

* add exception handler

* fix lint

* update log output

* change log message in async with exc_info

* Add exc_info to asyncio exception handler
2016-10-07 17:20:39 -07:00
Paulus Schoutsen abb8bcb6d9 Protect waiting for event loop from within event loop (#3658)
* Protect waiting for event loop from within event loop

* Faster fetching of loop attribute for ident check
2016-10-02 15:07:23 -07:00
Paulus Schoutsen be68fe0d85 Move worker pool monitoring to be time based instead of add_job based. (#3439)
* Move worker pool monitoring to be time based instead of add_job based.

* Stub out worker pool monitor during tests

* Add test for monitor worker pool.

* Improve naming

* Test stop_monitor coroutine

* Add async_create_timer test

* Finish rename create_timer
2016-09-19 23:39:49 -07:00
Paulus Schoutsen 609d7ebea5 Migrate core from threads to async awesomeness (#3248)
* Add event loop to the core

* Add block_till_done to HA core object

* Fix some tests

* Linting core

* Fix statemachine tests

* Core test fixes

* fix block_till_done to wait for loop and queue to empty

* fix test_core for passing, and correct start/stop/block_till_done

* Fix remote tests

* Fix tests: block_till_done

* Fix linting

* Fix more tests

* Fix final linting

* Fix remote test

* remove unnecessary import

* reduce sleep to avoid slowing down the tests excessively

* fix remaining tests to wait for non-threadsafe operations

* Add async_ doc strings for event loop / coroutine info

* Fix command line test to block for the right timeout

* Fix py3.4.2 loop var access

* Fix SERVICE_CALL_LIMIT being in effect for other tests

* Fix lint errors

* Fix lint error with proper placement

* Fix slave start to not start a timer

* Add asyncio compatible listeners.

* Increase min Python version to 3.4.2

* Move async backports to util

* Add backported async tests

* Fix linting

* Simplify Python version check

* Fix lint

* Remove unneeded try/except and queue listener appproriately.

* Fix tuple vs. list unorderable error on version compare.

* Fix version tests
2016-09-12 19:16:14 -07:00
Johann Kellerman e8ad76c816 Improve yaml fault tolerance and handle check_config border cases (#3159) 2016-09-08 22:20:38 +02:00
Johann Kellerman 55d305359e Device tracker component & platform validation. No more home_range. (#2908)
* Device tracker component & platform validation. No more home_range.

* Mock, bluetooth

* Renamed _CONFIG_SCHEMA. Raise warning for #1606

* test duplicates

* Fix assert

* Coverage

* Typing

* T fixes
2016-08-30 10:22:52 -06:00
Johann Kellerman 17631cd728 Check config script: various fixes (#2967)
🐬
2016-08-24 23:18:32 -06:00
Johann Kellerman 14b034f452 Check config script (#2657)
* Add check_config, yaml linting script

* WIP: Start reusing some bootstrap methods for validation

* Start outputs

* Secrets, files and failed config

* requirements_all

* Fixes

* formatting

* Fix unit test after formatting
2016-08-22 21:42:05 -07:00
Teagan M. Glenn af22aeeba8 Apparently, doesn't load the root config secret 2016-08-20 22:07:21 -06:00
Teagan Glenn 8d1a9d86ea Yaml secret fallback to parent folders (#2878)
* Move secret cache out of loader so it can be referenced by other folders
* Unit test to verify secrets from another folder work & see if it overrides parent secret
* Clear secret cache after load
2016-08-20 21:39:56 +02:00
Martin Hjelmare 9afb1d8c0d Fix unit log message (#2823)
* Fix log message for deprecated temp key

* Use string formatting and pass constant variables as arguments in log
	message to show correct name of config keys.

* Fix import order
2016-08-15 22:12:43 -07:00
Paulus Schoutsen 0b7b0e54ba Move unit system to util (#2763) 2016-08-08 20:42:25 -07:00
Fabian Heredia Montiel 0377338a81 Improvement typing (#2735)
* Fix: Circular dependencies of internal files

* Change: dt.date for Date and dt.datetime for DateTime

* Use NewType if available

* FIX: Wrong version test

* Remove: Date and DateTime types due to error

* Change to HomeAssistantType

* General Improvement of Typing

* Improve typing config_validation

* Improve typing script

* General Typing Improvements

* Improve NewType check

* Improve typing db_migrator

* Improve util/__init__ typing

* Improve helpers/location typing

* Regroup imports and remove pylint: disable=ungrouped-imports

* General typing improvements
2016-08-07 16:26:35 -07:00
Teagan M. Glenn 26526ca57a Add unit system support
Add unit symbol constants

Initial unit system object

Import more constants

Pydoc for unit system file

Import constants for configuration validation

Unit system validation method

Typing for constants

Inches are valid lengths too

Typings

Change base class to dict - needed for remote api call serialization

Validation

Use dictionary keys

Defined unit systems

Update location util to use metric instead of us fahrenheit

Update constant imports

Import defined unit systems

Update configuration to use unit system

Update schema to use unit system

Update constants

Add imports to core for unit system and distance

Type for config

Default unit system

Convert distance from HASS instance

Update temperature conversion to use unit system

Update temperature conversion

Set unit system based on configuration

Set info unit system

Return unit system dictionary with config dictionary

Auto discover unit system

Update location test for use metric

Update forecast unit system

Update mold indicator unit system

Update thermostat unit system

Update thermostat demo test

Unit tests around unit system

Update test common hass configuration

Update configuration unit tests

There should always be a unit system!

Update core unit tests

Constants typing

Linting issues

Remove unused import

Update fitbit sensor to use application unit system

Update google travel time to use application unit system

Update configuration example

Update dht sensor

Update DHT temperature conversion to use the utility function

Update swagger config

Update my sensors metric flag

Update hvac component temperature conversion

HVAC conversion for temperature

Pull unit from sensor type map

Pull unit from sensor type map

Update the temper sensor unit

Update yWeather sensor unit

Update hvac demo unit test

Set unit test config unit system to metric

Use hass unit system length for default in proximity

Use the name of the system instead of temperature

Use constants from const

Unused import

Forecasted temperature

Fix calculation in case furthest distance is greater than 1000000 units

Remove unneeded constants

Set default length to km or miles

Use constants

Linting doesn't like importing just for typing

Fix reference

Test is expecting meters - set config to meters

Use constant

Use constant

PyDoc for unit test

Should be not in

Rename to units

Change unit system to be an object - not a dictionary

Return tuple in conversion

Move convert to temperature util

Temperature conversion is now in unit system

Update imports

Rename to units

Units is now an object

Use temperature util conversion

Unit system is now an object

Validate and convert unit system config

Return the scalar value in template distance

Test is expecting meters

Update unit tests around unit system

Distance util returns tuple

Fix location info test

Set units

Update unit tests

Convert distance

DOH

Pull out the scalar from the vector

Linting

I really hate python linting

Linting again

BLARG

Unit test documentation

Unit test around is metric flag

Break ternary statement into if/else blocks

Don't use dictionary - use members

is metric flag

Rename constants

Use is metric flag

Move constants to CONST file

Move to const file

Raise error if unit is not expected

Typing

No need to return unit since only performing conversion if it can work

Use constants

Line wrapping

Raise error if invalid value

Remove subscripts from conversion as they are no longer returned as tuples

No longer tuples

No longer tuples

Check for numeric type

Fix string format to use correct variable

Typing

Assert errors raised

Remove subscript

Only convert temperature if we know the unit

If no unit of measurement set - default to HASS config

Convert only if we know the unit

Remove subscription

Fix not in clause

Linting fixes

Wants a boolean

Clearer if-block

Check if the key is in the config first

Missed a couple expecting tuples

Backwards compatibility

No like-y ternary!

Error handling around state setting

Pretty unit system configuration validation

More tuple crap

Use is metric flag

Error handling around min/max temp

Explode if no unit

Pull unit from config

Celsius has a decimal

Unused import

Check if it's a temperature before we try to convert it to a temperature

Linting says too many statements - combine lat/long in a fairly reasonable manner

Backwards compatibility unit test

Better doc
2016-08-04 22:02:19 -07:00
Robbie Trencheny 63ba5044b3 Kill celcius with fire, replacing it with celsius, finally finishing what #1860 started (#2679) 2016-07-31 12:18:40 -07:00
Teagan Glenn 122581da7f Proximity unit of measure (#2659)
* Allow multiple proximities

* Distance conversion

* Add unit of measurement and conversion to proximity

* Shorten attribute name

* Fix get unit of measurement

* Fix the km <-> m conversion

* Add type check and errors

* first path unit test around distance utility

* Fix numeric type check

* Fix conversion type-os

* Actually set the exception thrown flag

* Test for exact conversion

* More descriptive variable names

* Update method invocation to match change in method name

* Missed a couple variables

* Line continuation

* Fix linting too many return issue

* Break out proximity setup for list of proximity and for single proximity device

* Pass hass to setup function

* Check if setup succeeded for each proximity component

* Change variable name

* Break out branches in convert to avoid too many branches linting error

* Remove disable lint line

* Variables for default properties

* Combine logic

* Test loading multiple proximities for 100% code coverage on proximity component

* Unit test to reach 100%
Fail to configure proximities missing devices

* Fail first before processing

* Combine return statements

* lstrip = bad Teagan

* Utilize string formating instead of concatenation

* Fix variable reference

* Typeo

* Clean up conversion to reduce complexity

* Update unit tests to match code changes on distance util

* Test non numeric value

* Private methods, value type has already been checked.
2016-07-31 10:20:56 -07:00
Fabian Heredia Montiel ae97218582 Improvement typing core (#2624)
* Add package typing

* Add util/location typing

* FIX: lint wrong order of imports

* Fix sometyping and add helpers/entity typing

* Mypy import trick

* Add asteroid to test requiremts to fix pylint issue

* Fix deprecated function isSet for is_set

* Add loader.py typing

* Improve typing bootstrap
2016-07-27 20:33:49 -07:00
Paulus Schoutsen f1632496f0 Allow circular dependency with discovery (#2616) 2016-07-25 22:49:10 -07:00
Fabian Heredia Montiel d4f78e8552 Type Hints - Core/Utils/Helpers Part 1 (#2592)
* Fix deprecated(moved) import

* Add util/dt typing

* Green on mypy util/dt

* Fix some errors

* First part of yping util/yaml

* Add more typing to util/yaml
2016-07-23 11:07:08 -07:00
Johann Kellerman a60a342864 Logbook: Query databse as_utc(). dt: Use pytz's localize (#2521) 2016-07-13 18:45:55 -07:00
Paulus Schoutsen 31b8e49ad2 Fix PyLint 1.6 issues (#2471) 2016-07-07 18:54:16 -07:00
Johann Kellerman 85e3dfe6a6 Exclude secrets.yaml in yaml !include_directories (#2450) 2016-07-06 22:17:02 -07:00
Paulus Schoutsen bacc14d845 Merge pull request #2421 from armills/zwave-color-bulbs
Move Aeotec bulb color logic to Zwave workaround
2016-07-02 11:11:44 -07:00
Adam Mills 6477122b23 Move Aeotec bulb color logic to Zwave workaround
Default behavior for warm/cold white channels is to assume the white
channel is mixed with the rgb. This is a sane default and should support
the Fibaro RGBW LED controller.
2016-07-02 12:08:01 -04:00
Fabian Affolter 3870d2e0cd Docstring updates (#2404)
* Fix docstring

* Fix typo

* Update docstrings

* Update docstrings
2016-07-01 21:39:30 +02:00
Paulus Schoutsen 6714392e9c Move elevation to core config and clean up HTTP mocking in tests (#2378)
* Stick version numbers

* Move elevation to core config

* Migrate forecast test to requests-mock

* Migrate YR tests to requests-mock

* Add requests_mock to requirements_test.txt

* Move conf code from bootstrap to config

* More config fixes

* Fix some more issues

* Add test for set config and failing auto detect
2016-06-27 09:02:45 -07:00
Johann Kellerman 7b02dc434a Secrets support for configuration files (#2312)
* ! secret based on yaml.py

* Private Secrets Dict, removed cmdline, fixed log level

* Secrets limited to yaml only

* Add keyring & debug tests
2016-06-25 00:10:03 -07:00
mikebarris 5223d20668 Removed webcolors dependency in favor of dictionary lookup. (#2215)
* Removed webcolors dependency in favor of dictionary lookup.

* Fixed code style errors.

* Moved color dictionary to module per suggestion.

* Removed try/except per suggestion.
2016-06-08 22:25:32 -07:00
Fabian Affolter 4b0df51b40 Vendorize vincenty requirement (#2176) 2016-05-29 11:55:16 -07:00
Nolan Gilley 191fc8f8d4 Change color_RGB_to_xy formula & return brightness (#2095)
* Use RGB to XY calculations from Philips Hue developer site

* uppercase X,Y,Z

* rename cx,cy to x,y

* return brightness in color_RGB_to_xy

* remove try/catch

* update existing platforms using color_RGB_to_xy

* improve wemo w/ jaharkes suggestion

* allow brightness override of rgb_to_xy
2016-05-21 10:19:27 -07:00
happyleavesaoc 15f89fc636 add some include_dir options (#2074)
* add some include_dir options

* validate, and extend instead of add

* add yaml include tests
2016-05-17 15:47:44 -07:00
Robbie Trencheny a431277de1 Accept human readable color names to change light colors (#2075)
* Add support for providing color_name which accepts a CSS3 valid, human readable string such as red or blue

* Forgot the schema validation!

* ugh farcy

* use html5_parse_legacy_color for more input options

* Add webcolors==1.5 to setup.py

* Block pylint no-member errors on tuple

* add color_name_to_rgb test

* whoops

* revert changes to individual platforms

* If color_name is set, pop it off params and set rgb_color with it

* Forgot to reset wink.py

* Import the legacy function as color_name_to_rgb directly

* reset test_color.py

* Improve light services.yaml
2016-05-17 00:06:55 -07:00
Daniel Høyer Iversen 630b7377bd Refactor get_age in util/dt (#2067) 2016-05-14 12:05:46 -07:00
mnestor 954b56475e YAML: add !include_named_dir and ! include_list_dir (#2054)
* add include_dir constructor for yaml parsing

* changed to allow for flat and name based directory including

* fixed ci errors

* changed flat to list
2016-05-13 21:16:04 -07:00
Robbie Trencheny 16933abce9 Remove humanize and use a relative time thing that @balloob found on Github 2016-05-10 00:04:53 -07:00
Paulus Schoutsen e40908d67c Improve config validation error message 2016-05-07 22:31:22 -07:00
Paulus Schoutsen 6901e5ea5e Random fixes (#1996)
* OwnTracks handle malformed data better

Fixes #1991 .

* Remove dependency for util.dt
2016-05-07 10:16:14 -07:00
Charles Spirakis b86a1ece01 Allow conversion from date strings to "unix" timestamp. (#1985)
"unix" timestamp is number of seconds since Jan 1, 1970 UTC.
This allows scripts that use templates to generate time
deltas in seconds if desired from state attributes such
as last_updated.

Some examples:

timestamp now is
{{ as_timestamp(now) }}

timstamp of last change is
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}

seconds since last change is
{{ as_timestamp(now) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
2016-05-06 18:33:46 -07:00
Fabian Affolter 72cf7fd9c2 Add timeout to request for location elevation (#1978) 2016-05-06 18:10:13 -07:00
Brent 34193de158 Update yaml parser for handling environment variables (#1967) 2016-05-03 18:41:14 -07:00
Paulus Schoutsen 2e79e9d5bb Correct celcius to celsius (#1860) 2016-04-19 20:30:44 -07:00
Brad Johnson 09693bf16c Upgrading to python-wink 0.7.4 and improving RGB color support in HA (#1832) 2016-04-17 19:07:21 -07:00
Paulus Schoutsen 68d92c3196 Use standardised datetime format 2016-04-16 01:46:50 -07:00
Jan Harkes 73859f59f0 Make yaml config parser errors look less like bugs. (#1776)
Instead of nested tracebacks, show a simpler error message.

    Config directory: /home/user/.homeassistant
    ERROR:homeassistant.util.yaml:duplicate key: "script"
      in "/home/user/.homeassistant/configuration.yaml", line 95, column 0
      in "/home/user/.homeassistant/configuration.yaml", line 108, column 0
2016-04-09 15:25:01 -07:00
Jan Harkes d6abdc0d4e Add line numbers when we find duplicate keys. (#1750) 2016-04-08 20:53:27 -07:00
Fabian Affolter 2e44166854 Change to freegeoip.io and add a second service as fall-back 2016-04-06 10:25:40 -07:00