Commit Graph

157 Commits (da05dfe70859f5bf7c6aa6c820bc6a37dc14ca7c)

Author SHA1 Message Date
Diogo Gomes c851dfa2c7 Restores switch state, case the switch is optimistic (#14151)
* Add restore_state to optimistic switch

* no need to schedule update

* test added

* lint

* new async syntax

* lint
2018-05-02 17:29:07 -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
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
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
Maximilian Früh 001515bdc4 Add "headers" config parameter to rest switch (#12706)
* Add "headers" config parameter to rest switch

* Minor fix: line length
2018-02-28 14:00:51 -08:00
Otto Winter b1c0cabe6c Fix MQTT retained message not being re-dispatched (#12004)
* Fix MQTT retained message not being re-dispatched

* Fix tests

* Use paho-mqtt for retained messages

* Improve code style

* Store list of subscribers

* Fix lint error

* Adhere to Home Assistant's logging standard

"Try to avoid brackets and additional quotes around the output to make it easier for users to parse the log."
 - https://home-assistant.io/developers/development_guidelines/

* Add reconnect tests

* Fix lint error

* Introduce Subscription

Tests still need to be updated

* Use namedtuple for MQTT messages

... And fix issues

Accessing the config manually at runtime isn't ideal

* Fix MQTT __init__.py tests

* Updated usage of Mocks
* Moved tests that were testing subscriptions out of the MQTTComponent test, because of how mock.patch was used
* Adjusted the remaining tests for the MQTT clients new behavior - e.g. self.progress was removed
* Updated the async_fire_mqtt_message helper

*  Update MQTT tests

* Re-introduce the MQTT subscriptions through the dispatcher for tests - quite ugly though...  🚧
* Update fixtures to use our new MQTT mock 🎨

* 📝 Update base code according to comments

* 🔨 Adjust MQTT test base

* 🔨 Update other MQTT tests

* 🍎 Fix carriage return in source files

Apparently test_mqtt_json.py and test_mqtt_template.py were written on Windows. In order to not mess up the diff, I'll just redo the carriage return.

* 🎨 Remove unused import

* 📝 Remove fire_mqtt_client_message

* 🐛 Fix using python 3.6 method

What's very interesting is that 3.4 didn't fail on travis...

* 🐛 Fix using assert directly
2018-02-11 09:17:58 -08:00
Otto Winter 2ae0c5653e Fix source code using Windows newline (#12248)
* 🚜 Fix usage of carriage return

* 🤝 Rebase and repeat

* 🚜 Fix file permissions
2018-02-09 08:11:47 +01:00
tadly 98b47cecbd Upgrade wakeonlan to 1.0.0 (#12190) 2018-02-05 16:04:31 -08:00
Gerben Meijer 6ae3fa40cf Set flux default stop time to dusk (#12062)
This is more in line with how one would expect light temperature
transitions to take place, but still allows for a user defined
stop_time.
2018-01-31 12:00:47 +01:00
Sean Dague 73fa76d792 Add missing mock call for test_minimal_config (#11858)
In local testing py36 always fails on test_minimal_config on a wait
call that never completes. One difference between this test and others
in the class is the lack of a mock on `call`. With this added, the
test passes locally 100%.
2018-01-23 14:02:00 +01:00
Dan Nixon 2cfbd0dc1d Add missing availability schema to MQTT alarm panel (#11829)
* Add missing availability schema to MQTT alarm panel

* Add tests for default MQTT availability payloads
2018-01-20 17:11:04 +01:00
Alex Osadchyy 2ba9d825a0 Reconnect before mochad switch send command (#11296)
* Connection to mochad occasionally stalls on RPi and CM19A. Reconnect one switch send command.

* Formatting and exception hanling fixes

* Moved import inside the method. Logging outside the try-catch.

* Tailing whitespaces.

* MockDependency on pymochad in unit tests to resolve exceptions

* patch pymochad MochadException in unit tests to resolve exceptions

* patch pymochad MochadException in unit tests to resolve exceptions

* cleaned unused import

* lint issue fixed

* pylint issue fixed
2018-01-08 08:32:24 +01:00
Paulus Schoutsen ff9688bb7a
Fix vultr tests (#11477) 2018-01-05 16:34:03 -08:00
Dan Nixon f0bf7b0def More support for availability reporting on MQTT components (#11336)
* Abstract MQTT availability from individual components

- Moved availability topic and payloads to MQTT base schema.
- Updated components that already report availability:
  - Switch
  - Binary sensor
  - Cover

* Add availability reporting to additional MQTT components

- Light
- JSON light
- Template light
- Lock
- Fan
- HVAC
- Sensor
- Vacuum
- Alarm control panel

* Annotate MQTT platform coroutines
2018-01-01 18:32:29 -08:00
Andrey 4420f11d9d
Fix import in tests (#10525) 2017-11-11 22:24:43 +02:00
Paulus Schoutsen 2e5b1e76ef Fix slow WOL switch test (#10455) 2017-11-08 12:38:17 +01:00
Adam Cooper 72ce9ec321 Add platform and sensors for Vultr VPS (#9928)
* Initial commit of Vultr components

Have a working Vultr hub and binary sensor which pulls down the
following attributes of your VPS:
 - Date created
 - Subscription id (server id)
 - Cost per month (in US$)
 - Operating System installed
 - IPv4 address
 - label (human readable name)
 - region
 - number of vcpus
 - which storage package chosen
 - IPV6 address (if applicable)
 - RAM amount

Working next on sensor and then testing / coverage.

* Added Vultr sensor for pending charges and current bandwidth. Refactored binary_sensor and hub too

* Corrected is_on bases

* Added basic tests for Vultr binary & platform

* Updated require files

* Changing test fixture to highlight different cases

* Written basic test for sensor.vultr

* Resolved linting errors and broken test

* Increase test coverage and corrected docs

* Resolved hound issues

* Revert back negative binary test

* Another hound resolve

* Refactoring and adding is switch, moving over to vultr branch

* Made Vultr components more resiliant to invalid configs

* Added negetive test for vultr binary sensor

* Added better testing of vultr sensor

* Resolved vultr platform test affecting subsequent vultr tests

* Moving VULTR components to single use design

* Added in sensor name config

* Added missing sensors var

* Resolved init data setting of sensors, added in name conf to switch

* Made the Vultr component more resiliant to startup failure with better alerting

* Various Vultr component changes

- Refactored sensor, binary_sensor, and switch to reference one subscription
- Renamed CURRENT_BANDWIDTH_GB monitored condition to CURRENT_BANDWIDTH_USED
- Improved test coverage

* Resolved local tox linting issue

* Added more testing for Vultr switch

* Improved test coverage for Vultr components

* Made PR comment changes to vultr binary sensor

* Made PR comment changes to Vultr sensor

* resolved PR comments for Vultr Switch

* Resolved vultr sensor name and improved tests

* Improved Vultr switch testing (default name formatting)

* Removed vultr hub failure checking
2017-11-05 14:10:14 +01:00
cgtobi 8739991676 Add unit test for wake on lan component. (#10262)
* Add unit test for wake on lan component.

* Remove unneccessary imports and print calls.

* Clean up lint complaints.
2017-11-01 11:15:24 +01:00
Aaron Bach 646c03eea1 Add entity_picture_template options to Template Cover, Template Light, Template Sensor, and Template Switch (#9854)
* Re-adding cover

* Re-adding light

* Re-adding sensor

* Re-adding switch

* Re-added tests

* Fixing missing imports in rebased test

* Fixing broken tests

* Owner-requested changes

* Owner-requested changes

* Fixed exception
2017-10-30 09:28:37 -07:00
Pascal Vizeli c1b197419d Fix async probs (#9924)
* Update entity.py

* Update entity_component.py

* Update entity_component.py

* Update __init__.py

* Update entity_component.py

* Update entity_component.py

* Update entity.py

* cleanup entity

* Update entity_component.py

* Update entity_component.py

* Fix names & comments / fix tests

* Revert deadlock protection

* Add tests for entity

* Add test fix name

* Update other code

* Fix lint

* Remove restore state from template entities

* Lint
2017-10-19 10:56:25 +02:00
Johan Bloemberg 515d1bdbd3 Add test cases and fix for device_defaults fire_event option. (#9567)
* Add test cases and fix for device_defaults fire_event option.

* Also for light.

* Change docstring mood.
2017-09-24 15:47:59 -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
Lukas Barth 89d6784fa0 Fix copy&paste mistake (#9378) 2017-09-13 17:00:46 +02:00
Anders Melchiorsen 160c7fc685 Add HTTP Basic auth to RESTful Switch (#9162)
* Add HTTP Basic auth to RESTful Switch

* Remove redundant hass passing

* Initialize to current state

The state used to be None until the first periodic poll.

This commit refactors async_update so it can be used during setup as well,
allowing the state to start out with the correct value.

* Refactor turn_on/turn_off device communication

* Remove lint

* Fix Travis errors
2017-09-09 10:20:48 -07:00
Abílio Costa 0889e38cb1 flux: fix for when stop_time is after midnight (#8932)
* flux: fix for when stop_time is after midnight

* flux: fix imports

* flux: add missing check when now is after midnight

* flux: one more try; should fix all use cases now

* flux switch: fix lint

* flux switch: add new tests

* flux switch: fix tests lint

* flux switch: fix tests docstrings
2017-09-02 18:02:11 +02:00
timstanley1985 3342db33e4 MQTT Switch - Add configurable availability payload (#8934)
* Add configurable availabilty payload

* Fix

* Fix

* Lint fixes

* Fix tests

* Fix tests

* Move from const.py to mqtt switch

* New test

* Fix flake*
2017-08-15 23:04:57 -07:00
Abílio Costa 9d5c61b2f0 MQTT Switch: add availability_topic for online/offline status (#8593)
* mqtt switch: add availability_topic for online/offline status

* fix method doc strings

* MQTT Switch: add test
2017-07-27 08:24:15 +02:00
Dougal Matthews d8abef9210 Add RGB support to switch.flux (#8417) 2017-07-13 19:53:19 -07:00
Johan Bloemberg fe6a4b8ae5 Correct spelling of aliases, deprecate old config options. (#8348)
* correct spelling of aliases

* add deprecation

* Fix style.
2017-07-06 15:59:54 +02:00
Pascal Vizeli 2438c6b7c2 Fix attribute entity (#8066)
* Bugfix entity attribute setter

* Fix tests

* Fix tests part 2

* Change filter only None

* Fix tests part 3

* Update entity.py

* Fix tests
2017-06-17 10:03:49 -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
Fabian Affolter 843f8ce9ee Allow put as method (#8004) 2017-06-12 22:27:25 -07:00
PhracturedBlue 11dcbd4449 Add 'icon_template' to switch templates (similar to sensor template) (#7862)
* Add 'icon_template' to switch templates (similar to sensor template)

* Add test for template switch 'icon_template'
2017-06-05 11:27:48 +02:00
Johan Bloemberg d472d81538 Align switch group handling with light. (#7577) 2017-06-02 00:05:34 -07:00
Andrey 927024714b Zwave: Apply refresh_node workaround on 1st instance only (#7579)
* Apply refresh_node workaround on 1st instance only

* Add another test
2017-05-21 17:33:42 +03:00
Paulus Schoutsen 352cca1037 Remove more test requirements (#7574)
* No longer require pyunify during tests

* No longer require cast during tests

* No longer required dependency for tests

* No longer require pymochad for tests

* Astral is a core dependency

* Avoid having to install datadog dependency during tests

* CMUS test doesn't test anything

* Frontier Silicon doesn't test anything

* No longer require mutagen

* Update requirements_test_all.txt

* Remove stale comment
2017-05-13 21:25:54 -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 714b516176 aiohttp 2 (#6835)
* Upgrade aiohttp2

* Fix resource caching

* Fix helpers.aiohttp_client

* Lint

* Use static path for api error_log

* Fix ClientErrors import

* Remove not needed DisconnectError

* Remove releasing responses code

* Add timeout if stream starts non responding

* More async_aiohttp_proxy_stream cleanup

* Fix references to ClientError

* Fix fingerprinting

* Fix aiohttp stream tests

* Rename aiohttp_proxy_stream

* Remove impossible darksky test

* Fix sleepiq requests escaping mocker

* Lint

* Remove deprecated parameter

* Break up aiohttp_proxy_stream in 2 methods

* Lint

* Upgrade to aiohttp 2.0.4

* Convert connector close to a callback

* Fix static fingerprinted links
2017-03-30 00:50:53 -07:00
Adam Mills 866bf887d3 ZWave switch tests (#6722) 2017-03-20 13:17:42 -04:00
Greg Dowling acf75b5253 Revise power and energy units and property names. (#6212)
* Revise power and energy units and property names.

* Add change for new wemo parameter.
2017-03-19 22:02:11 +01:00
John Arild Berentsen 5aaa1f8404 Add test for Z-wave switch (#6619)
* Add test for Z-wave switch

* Changes for new tests
2017-03-16 11:05:51 +01:00
Paulus Schoutsen 2650c73a89 Split bootstrap into bs + setup (#6416)
* Split bootstrap into bs + setup

* Lint
2017-03-05 10:41:54 +01:00
Pascal Vizeli 55dc483c91 Template switch change flow / add restore (#6356)
* Template switch change flow / add restore

* fix tests

* fix binary_sensor template
2017-03-02 14:09:53 +01:00
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 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 c54517de90 Convert config.components to a set (#5824) 2017-02-09 20:21:57 +02:00
Johan Bloemberg bbda2a72f4 Rflink 433Mhz gateway platform and components (#4547)
* Initial sketches of rflink component.

* Add requirement.

* Properly load configuration.

* Bump rflink for graceful parse errors and protocol callback.

* Cleanup, documentation and linting.

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

* Add brightness/dim support for newkaku protocol.

* Use separate class for dimmables.

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

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

* Fix bug in ignoring devices.

* Fix initial state assumption.

* Improve reliability on invalid conditions.

* Allow configuration of group for new devices.

* Sensor icons.

* Fix parsing negative numbers.

* Correct icon.

* Allow sending commands serial.

* Pluralize.

* Allow adding sensors from config.

* Fix ignoring devices and bugs in previous commit.

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

* Lookup unit from value_key.

* Remove debug.

* Start implementing event protocol in place of packet protocol.

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

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

* Fix style.

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

* Use non-broken and production tested rflink module.

* Update requirements.

* Bump for logging.

* Improve readability.

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

* Improve docs.

* Make icon support generic.

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

* Implement configuration schema, overall refactor of magic values.

* Fix bug in config/test wait_for_ack.

* Small refactors.

* Move command logic into separate class.

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

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

* Do not use event bus for all entity types.

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

* Resolve lint errors, remove some old code.

* Known devices no longer need to be registered separately.

* Log bus events.

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

* Use full entity id for events.

* Move event sending to entity.

* Log incoming events.

* Make firing events optional inline with rfxtrx.

* Add foundation for signal repetition.

* Add signal repetition config and tests.

* Make plain switchable type explicitly configurable.

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

* Prevent default configuration leaking accross entities.

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

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

* Make repetitions more responsive.

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

* Use rflink that allows send_command_ack to be safely cancelled.

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

* Implement reconnection logic.

* Improve reconnection logic.

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

* Update requirements.

* Fix linting.

* Fix spelling.

* Don't lie.

* Fix lint.

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

* Returned support for dimmable and on/off entity.

* Duplicate code to fix linting issues with inheritance.

* Allow overriding unit of measurement from config.
2017-01-31 08:11:52 -08:00
Daniel Høyer Iversen a465a45588 Fix for assumed state in command_line (#5578)
* Bug fix for assumed state in command_line

* command line

* command line

* command line

* command line test
2017-01-26 21:41:30 -08:00
Paulus Schoutsen aa1e4c564c Fix tests closing properly (#5203) 2017-01-07 01:47:25 +01:00
Johann Kellerman f0b1874d2d Fix up docstring for tests (#5090) 2016-12-28 20:04:59 +02:00
Pascal Vizeli e4b6395250 Migrate REST switch to async (#4517)
* Migrate REST switch to async

* Update rest.py

* Address comments from paulus
2016-12-13 08:55:13 -08:00
Fabian Affolter 51e20c92f9 WIP Fix pylint and PEP257 issues (tests) (#4120)
* Fix pylint and PEP257 issues

* More PEP257 fixes
2016-12-01 21:45:19 -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
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
Paulus Schoutsen 0f59bb208c Migrate callbacks to use schedule_update_ha_state (#4426)
* Migrate callbacks to use schedule_update_ha_state

* Migrate MQTT sensor callback to async

* Migrate wemo to not update inside schedule_update_ha_state

* Make MQTT switch async

* Fix nx584 test

* Migrate tellstick callback

* Migrate vera callback

* Alarm control panel - manual: use async callbacks

* Run the switch rest tests that work
2016-11-17 07:34:46 -08:00
Nathan Henrie 2109b7a1b9 Use entity_id for backend, friendly name for frontend (#4343)
* Use entity_id for backend, friendly name for frontend

Closes https://github.com/home-assistant/home-assistant/issues/3434

Command line switches had the option to set a `friendly_name` reportedly
for use in the front end. However, if set, it was also being used as the
`entity_id`.

This did not seem like obvious behavior to me. This PR changes the
behavior so the entity_id is the object_id, which must already be
unique, and is an obvious place to have a very predictable slug (even if
long or unsightly), and the friendly name (if set) is used for the
display.

Example:

```yaml
switch:
  platform: command_line
  switches:
    rf_kitchen_light_one:
      command_on: switch_command on kitchen
      command_off: switch_command off kitchen
      command_state: query_command kitchen
      value_template: '{{ value == "online" }}'
      friendly_name: "Beautiful bright kitchen light!"
```

If you were using in an automation or from dev tools, would use:
`switch.rf_kitchen_light_one`, but your front end would still show `Beautiful
bright kitchen light!`

* Add new arg to test_assumed_state_should_be_true_if_command_state_is_false

* Import ENTITY_ID _FORMAT from existing, rename device_name to object_id

* Rename `device_name` to `object_id`

* Test that `entity_id` and `name` are set as expected
2016-11-12 22:46:23 -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
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
Paulus Schoutsen a1e910f1cf Disable rest switch tests 2016-10-31 08:22:49 -07:00
Jared Beckham a89e635bf3 Added tests for REST switches (#4016)
* Added tests for REST switches

* Remove REST switch from test coverage exclusions
2016-10-31 13:14:23 +01: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
Matthew Treinish 0ff500ca25 Add mochad component (#3970)
This commit adds a new component for communicating with mochad[1] a
socket interface for the CM15A and CM19A USB X10 controllers. This
commit leverages the pymochad library to interface with a mochad socket
either on a local or remote machine. Mochad is added as as a generic
platform because it supports multiple different classes of device,
however in this patch only the switch device implemented as a starting
point. Future patches will include other devices types. (although
that's dependent on someone gaining access to those)

[1] https://sourceforge.net/projects/mochad/
2016-10-24 21:49:49 -07:00
Rob Capellini 4891ca1610 Removing calls to mock.assert_called_once_with (#3896)
If a mock's assert_called_once_with method is misspelled (e.g. asert_called_once_with) then the test will appear as passing.  Therefore, this commit removes all instances of assert_called_once_with calls and replaces them with two assertions:

        self.assertEqual(mock.call_count, 1)
        self.assertEqual(mock.call_args, mock.call(call_args))
2016-10-16 16:13:27 -07:00
Johann Kellerman 7b40a641ec Continue on invalid platforms and new setup_component unit tests (#3736) 2016-10-08 11:27:35 -07:00
Jeff Wilson d55ed7a3a2 Flux switch improvements (#3615)
* Make flux always adjust brightness of light (even when not in XY mode)

* Remove kelvin mode from flux switch

The light/turn_on service only works with mired values, kelvin values
are out of range per the schema.

* Use already defined min/max values for light/turn_on schema

* Clamp temp value to light/turn_on allowed values
2016-10-01 22:57:15 -07:00
Paulus Schoutsen 3e24a35c1e Skip RFXtrx tests unless RFXTRX=RUN (#3625)
* Skip RFXtrx tests unless RFXTRX=RUN

* Remove my previous hacks to slightly speed up rfxtrx

* Exclude RFXTRX tests from coverage

* Remove unused import in rfxtrx tstt

* Add close connection back to RFXtrx tests

* Typo
2016-10-01 13:57:10 -07:00
Paulus Schoutsen 4b8bc90d16 Limit worker pool to 10 threads (#3560)
* Limit worker pool to 10 threads

* Comment evdev in requirements

* Allow skipping RFXtrx tests locally

* Fix worker pool size tests

* lol whut
2016-09-28 00:05:38 -07:00
Pascal Vizeli bbfd86dec3 Use setup_component in tests v1 (#3507)
* update unittests like #3414

* setup_component - splunk

* setup_component - statsd

* fix statsd & splunk unittest config values

* component_setup - device_sun_light_trigger

* setup_component - introduction

* component_setup - persistent_notification

* setup_component - logentries, mqtt eventstream

* fix unittest logentries
2016-09-25 23:15:21 +02: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
Fabian Affolter 3c615e2319 Use voluptuous for mFi switch (#3168)
* Migrate to voluptuous

* Take change configuration into account
2016-09-03 20:32:35 -06:00
Fabian Affolter 40c71b5d96 Use voluptuous for Command line platforms (#2968)
* Migrate to voluptuous

* Fix pylint issues

* Remove FIXME

* Split setup test

* Test with bootstrap

* Remove lon and lat

* Fix pylint issues
2016-09-02 08:09:09 -06:00
Greg Dowling eac67fd971 Add voluptuous to template switch (#2940)
* Add voluptuous to template switch / revise tests.
2016-08-23 00:05:45 +02:00
Teagan Glenn 915b9cb3eb Fix pydoc strings 2016-08-08 20:19:56 -06:00
Daniel Høyer Iversen 23472cb44d Handle numeric device id for rfxtrx devices (#2740) 2016-08-07 17:15:39 -07:00
HBDK a73c2e57a8 Added mired and kelvin mode to flux (#2665)
* Added mired and kelvin mode to flux

* changed as requested

* Renamed varible

* attempt to add test for new method in flux.py

* removed line to fix lint error
2016-07-31 16:55:48 -07:00
Paulus Schoutsen f1632496f0 Allow circular dependency with discovery (#2616) 2016-07-25 22:49:10 -07:00
Daniel 98550b5465 rfxtrx light tests 2016-07-17 11:14:29 +02:00
Daniel 034f1b9499 rfxtrx switch tests 2016-07-17 10:27:27 +02:00
Daniel Høyer Iversen 09a4336bc5 Fix bug in rfxtrx for int device id (#2497) 2016-07-12 01:45:22 -07:00
Jacob Tomlinson ca7415e935 Added rfxtrx rollershutter (#2030)
* Added rfxtrx rollershutter

* Updated mock command with real one

* Corrected test string
2016-06-02 00:39:58 -07:00
Nolan Gilley 24d2eaa6ca flux platform as a switch (#2097)
* flux platform as a switch

* use track_time_change. broken :(

* use track_utc_time_change instead of track_time_change

* add some basic tests

* use brightness from RGB_to_xy

* config_schema validation

* back to platform schema. what was i doing?

* more broken tests :(

* 644

* fix some time bugs

* add working tests. config validation still not right

* bug fixes and more test cases.
2016-06-01 23:38:19 -07:00
Daniel 2ca1f7542f Refactor rfxtrx code 2016-04-24 13:42:59 +02:00
Daniel 55b51cb3fa Update rfxtrx tests to handle new config 2016-04-23 20:13:24 +02:00
Daniel Høyer Iversen cac555fc69 Rfxtrx config validating (#1747)
* config validation

* Config validation of rfxtrx switch

* Config validation of rfxtrx light

* Config validation of rfxtrx

* Config validation of rfxtrx
2016-04-08 20:55:31 -07:00
Jan Harkes deecec5e4e Config validation for MQTT switch platform. 2016-04-06 22:51:39 -04:00
William Scanlon a64726e321 Added assumed state to command_line switch 2016-03-17 10:41:26 -04:00
Daniel d6344d6492 Fixed close connection issue with rfxtrx device and update rfxtrx lib 2016-03-14 08:33:59 +01:00
Paulus Schoutsen 025713ee41 Type checks for MQTT config 2016-03-10 21:42:17 -08:00
Fabian Affolter 9838697d2b Fix PEP257 issues 2016-03-09 10:25:50 +01:00
Paulus Schoutsen 1159360281 Skip rfxtrx tests because of speed reasons 2016-03-05 09:28:47 -08:00
Daniel 2fd0b28c53 Added tests for RFxtrx device, updated rfxtrx to ver 0.5, fixed bug in setting brightness for rfxtrx light 2016-03-02 20:36:41 +01:00
Paulus Schoutsen be55ee059e Make names command line platform consistent 2016-02-27 15:56:35 -08:00
Paulus Schoutsen 443b39bccd MQTT Switch to expose assumed_state if optimistic 2016-02-20 17:17:30 -08:00
Paulus Schoutsen 09ab3e95c0 Tests should all use test HA 2016-02-14 15:08:23 -08:00
Fabian Affolter 00afaac54c Update for file header, docstrings, and PEP8/PEP257 2016-02-13 14:19:11 +01:00
Dan Smith b17df44402 Add tests for mFi switches 2016-02-09 03:03:26 +00:00
pavoni 2622cf2e53 Use available, remove state, improve true,false tests. 2016-02-05 11:18:50 +00:00
pavoni 5521096c02 Add actions. 2016-02-03 14:29:25 +00:00