Commit graph

178 commits

Author SHA1 Message Date
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
Adam Mills bf7aecce90 Use dynamic ports for test instances (#6232) 2017-03-02 00:07:50 -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
Paulus Schoutsen 61909e873f Feature/reorg recorder (#6237)
* Re-organize recorder

* Fix history

* Fix history stats

* Fix restore state

* Lint

* Fix session reconfigure

* Move imports around

* Do not start recording till HASS started

* Lint

* Fix logbook

* Fix race condition recorder init

* Better reporting on errors
2017-02-26 14:38:06 -08:00
Paulus Schoutsen 86d4d10176 Ensure we properly close HASS instances. (#6234) 2017-02-26 14:05:18 -08:00
Pascal Vizeli 81ca978413 Move mqtt from eventbus to dispatcher / add unsub for dispatcher (#6206)
* Move mqtt from eventbus to dispatcher / add unsub for dispatcher

* Fix lint

* Fix test

* Fix lint v2

* fix dispatcher_send
2017-02-24 17:11:50 -08:00
Johann Kellerman aee8758fc1 Restore input_select and test helper proposal (#6148)
* Restore input_select and test helper proposal

* DB still active
2017-02-22 00:15:48 -08:00
Johann Kellerman fdc373f27e Restore_state helper to restore entity states from the DB on startup (#4614)
* Restore states

* feedback

* Remove component move into recorder

* space

* helper

* Address my own comments

* Improve test coverage

* Add test for light restore state
2017-02-20 23:40:27 -08:00
Paulus Schoutsen 25408941de Mqtt fixes (#6116)
* Fix MQTT stop

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

* Fix MQTT connect
2017-02-19 22:43:10 -08:00
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
Paulus Schoutsen 75e41a21c9 Clean up mock_coro (#6037) 2017-02-15 23:19:34 -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
Paulus Schoutsen 44311193ef Add config component and hassbian example panel (#5868)
* Add hassbian panel

* Rename to generic config panel

* Allow loading hassbian as test

* Add tests

* Update frontend

* Lint

* Lint
2017-02-11 17:29:05 -08:00
Paulus Schoutsen c54517de90 Convert config.components to a set (#5824) 2017-02-09 20:21:57 +02:00
Pascal Vizeli 2cbed9cd96 Move signal handling out of core to bootstrap (#5815)
* Move signal handling out of core to bootstrap

* Fix tests
2017-02-08 21:58:45 -08:00
Fabian Affolter c7fd28c10f MQTT discovery (#5724)
* Change implementation

* Re-write

* Remove unused consts

* Update discovery.py

* Add tests

* fix other tests

* Fix check_config script test

* Lint

* Lint
2017-02-07 09:13:24 -08:00
andrey-git f774538e66 Check config before restarting (#5609)
* Check config before restarting.

* Make check_config on restart async

* don't check if notification service exists

* Use .communicate()

* Reduce the number of notifications. Add tests.
2017-02-07 01:19:08 -08:00
Adam Mills 8217a42960 Don't start test thread as daemon and wait until patching is done (#5494) 2017-01-23 07:03:55 +02:00
Martin Hjelmare 9db1aa7629 Add discovery notify support and mysensors notify (#5219)
* Add mysensors notify platform

* Make add_devices optional in platform callback function.
* Use new argument structure for all existing mysensors platforms.
* Add notify platform.
* Update mysensors gateway.

* Refactor notify setup

* Enable discovery of notify platforms.
* Update and add tests for notify component and some platforms.
* Continue setup of notify platforms if a platform fails setup.
* Remove notify tests that check platform config. These tests are not
  needed when config validation is used.
* Add config validation to APNS notify platform.
* Use discovery to set up mysensors notify platform.

* Add discovery_info to get_service and update tests

* Add discovery_info as keyword argument to the get_service function
  signature and update all notify platforms.
* Update existing notify tests to check config validation using test
  helper.
* Add removed tests back in that checked config in apns, command_line
  and file platforms, but use config validation test helper to verify
  config.
* Add a test for notify file to increase coverage.
* Fix some PEP issues.

* Fix comments and use more constants

* Move apns notify service under notify domain
2017-01-15 03:53:14 +01:00
Paulus Schoutsen 914a868fbd Add websocket API (#4582)
* Add websocket API

* Add identifiers to interactions

* Allow unsubscribing event listeners

* Add support for fetching data

* Clean up handling code websockets api

* Lint

* Add Home Assistant version to auth messages

* Py.test be less verbose in tox
2016-11-26 18:23:28 -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 eacdce9ed9 Track tasks only during shutdown and tests (#4428)
* Track tasks only when needed

* Tweak async_block_till_done
2016-11-24 14:49:29 -08:00
Fabian Affolter e6c4113c5b Fix lint issues for 0.33 (#4451)
* Fix PEP257 issues

* Fix ident

* Fix lint issues

* Update docstrings

* Fix indent

* Fix indent

* Fix lint issues

* Fix lint issue

* Again lint
2016-11-18 23:05:03 +01:00
Pascal Vizeli 71da21dcc8 Change pending task sheduler to time based cleanup (#4324)
* Change pending task sheduler to time based cleanup

* update unittest
2016-11-09 08:41:17 -08:00
Paulus Schoutsen 62785c2431 More async tests (#4223)
* Annotate test callbacks to be async

* Convert device_sun_light_trigger to be async
2016-11-05 16:36:20 -07: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
Paulus Schoutsen 4e820ea30a Move mocks to async_start (#4182) 2016-11-02 19:16:59 -07:00
Pascal Vizeli 26490109ac Change event loop on windows (#4075)
* Change event loop on windows

* fix

* split PR

* remove set event loop

* Add paulus suggestion

* fix missing import

* revert stuff from PR Splitting

* fix event loop on test
2016-11-02 21:53:52 +01: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
Paulus Schoutsen 9ea1101aba Fix bootstrap circular imports (#4108)
* Fix bootstrap circular imports

* fix test

* Lint
2016-10-29 12:54:47 -07:00
Paulus Schoutsen 5a2b4a5376 Core Async improvements (#4087)
* Clean up HomeAssistant.start

* Add missing pieces to remote HA constructor

* Make HomeAssistant constructor async safe

* Code cleanup

* Init websession lazy
2016-10-29 08:57:59 -07: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
Paulus Schoutsen 519d9f2fd0 async HTTP component (#3914)
* Migrate WSGI to asyncio

* Rename wsgi -> http

* Python 3.4 compat

* Move linting to Python 3.4

* lint

* Lint

* Fix Python 3.4 mock_open + binary data

* Surpress logging aiohttp.access

* Spelling

* Sending files is a coroutine

* More callback annotations and naming fixes

* Fix ios
2016-10-23 23:48:01 -07:00
Paulus Schoutsen 4c8d1d9d2f Clean up some async stuff (#3915)
* Clean up some async stuff

* Adjust comments

* Pass hass instance to eventbus
2016-10-17 19:38:41 -07:00
Johann Kellerman 7b40a641ec Continue on invalid platforms and new setup_component unit tests (#3736) 2016-10-08 11:27:35 -07:00
Paulus Schoutsen fe317b806f Close event loop to avoid error on exiting HASS (#3762) 2016-10-08 18:56:36 +02:00
Paulus Schoutsen 4f0064b00e Fix broken tests (#3704)
* Fix broken tests

* Lint
2016-10-04 22:19:12 -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 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
Ben Bangert 256062fd99 Fix test shutdown to ensure loop/threads are clean. (#3447)
* Fix test shutdown to ensure loop/threads are clean.

We now ensure the loop is closed, it has completed, and the
executer has completed. This ensure all threads are freed
up with any test calling hass.stop().

* Fix lint issue with run_loop
2016-09-18 20:35:58 -07:00
Paulus Schoutsen 4076ccf639 Use setup_component in tests (#3414)
* Alarm Control Panel Manual - use setup_component

* Update automation - zone tests

* Update climate - demo tests

* Update climate - generic thermostat tests

* Update cover - command line tests

* Update cover - demo tests

* Update device tracker tests

* Update device tracker - owntracks tests

* Update fan - demo tests

* Update garage door - demo tests

* Update light tests

* Update lock - demo tests

* Update media player - demo tests

* Update notify - command line tests

* Update notify - demo tests

* Update notify - file tests

* Update notify - group tests

* Update sensor - mfi tests

* Update sensor - moldindicator tests

* Update sensor - mqtt room tests

* Update switch - command line

* Update switch - flux

* Update switch tests

* Update scene tests

* Fix wrong default port for mfi switch
2016-09-17 10:29:58 -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
Paulus Schoutsen 87e332c777 Merge pull request #2980 from home-assistant/automation-entities
Create entities for automation
2016-09-01 09:50:39 +01: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
Paulus Schoutsen 62ba0fa7a2 Do not install pip packages in tests 2016-08-25 23:23:14 -07: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
Paulus Schoutsen 0b7b0e54ba Move unit system to util (#2763) 2016-08-08 20:42:25 -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
Paulus Schoutsen 8ee4503d7c Exclude tests in dependencies in test dir from pytest (#2618) 2016-07-25 08:26:07 -07: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
Paulus Schoutsen 15e329a588 Tons of fixes - WIP 2016-05-21 15:01:33 -07:00
Paulus Schoutsen 2e79e9d5bb Correct celcius to celsius (#1860) 2016-04-19 20:30:44 -07:00
Jan Harkes 9e0e61fec9 Trying to fix failing sun component tests. (#1741)
Make sure we set a timezone to make UTC calculations predictable
and don't override the location of the test_home_assistant config.
2016-04-07 18:32:21 -07:00
Jan Harkes 58ea589f99 Fixes for mqtt config validation tests. 2016-04-06 22:51:38 -04:00
Jan Harkes 8cca2bb344 Config validation for MQTT 2016-04-06 22:51:38 -04:00
Paulus Schoutsen f6d584af09 Allow platforms to specify PLATFORM_SCHEMA 2016-04-02 20:10:57 -07:00
Paulus Schoutsen 8ceab5d4ba Add extra tests 2016-03-29 22:50:38 -07:00
Paulus Schoutsen 25269cdb6b Add tests for bootstrap config validation 2016-03-29 00:17:53 -07:00
Fabian Affolter f22a40c3e8 Fix PEP257 issues 2016-03-09 11:15:04 +01:00
Fabian Affolter 9838697d2b Fix PEP257 issues 2016-03-09 10:25:50 +01:00
Paulus Schoutsen 1bfea626ff Handle circular setup dependency 2016-02-19 23:20:14 -08:00
Paulus Schoutsen dd2aec0a08 Restructure tests to ensure unique ports 2016-02-14 12:54:16 -08:00
Fabian Affolter 00afaac54c Update for file header, docstrings, and PEP8/PEP257 2016-02-13 14:19:11 +01:00
Paulus Schoutsen a5db23afa4 Mock util.location by default 2016-02-04 22:26:02 -08:00
Paulus Schoutsen 90e17fc77f Add tests for entity component 2016-01-31 01:01:23 -08:00
Paulus Schoutsen 716376081d Add tests for MQTT alarm 2015-10-13 23:08:12 -07:00
Paulus Schoutsen d35f5b9f97 Tests for MQTT sensor/switch 2015-10-02 23:57:26 -07:00
Paulus Schoutsen cfc23b0091 Speed up tests 2015-09-12 22:56:49 -07:00
Paulus Schoutsen 4ccedca3e5 Fix tests for device tracker 2015-09-12 09:15:28 -07:00
Paulus Schoutsen 58afbecd05 Speed up tests 2015-09-01 00:18:26 -07:00
Paulus Schoutsen 1b89a502c4 Extract core into own submodule 2015-08-16 20:44:46 -07:00
Paulus Schoutsen 60abaa585c Add test for bootstrap 2015-08-11 08:20:13 -07:00
Paulus Schoutsen 291cc62381 Add automation mqtt tests 2015-08-10 23:11:46 -07:00
Paulus Schoutsen 76f63ee262 Clean up test code 2015-08-03 17:57:12 +02:00
Paulus Schoutsen 0c56fde5a9 Reorg tests folder 2015-07-26 10:17:01 +02:00
Renamed from tests/helpers.py (Browse further)