Commit Graph

10423 Commits (c059dfdb676d4ef736c52421cb236919d525f6e8)

Author SHA1 Message Date
Eugenio Panadero a221b10694 Update xiaomi vacuum tests and include in coverage (#8845)
* Fix tests for Demo vacuum platform (and increase coverage)

* increase coverage of xiaomi vacuum tests and include in coverage

Also little fixes

* remove print statement
2017-08-05 21:45:59 +02:00
Greg Laabs 6e1785173f History query and schema optimizations for huge performance boost (#8748)
* Add DEBUG-level log for db row to native object conversion

This is now the bottleneck (by a large margin) for big history queries, so I'm leaving this log feature in to help diagnose users with a slow history page

* Rewrite of the "first synthetic datapoint" query for multiple entities

The old method was written in a manner that prevented an index from being used in the inner-most GROUP BY statement, causing massive performance issues especially when querying for a large time period.

The new query does have one material change that will cause it to return different results than before: instead of using max(state_id) to get the latest entry, we now get the max(last_updated). This is more appropriate (primary key should not be assumed to be in order of event firing) and allows an index to be used on the inner-most query. I added another JOIN layer to account for cases where there are two entries on the exact same `last_created` for a given entity. In this case we do use `state_id` as a tiebreaker.

For performance reasons the domain filters were also moved to the outermost query, as it's way more efficient to do it there than on the innermost query as before (due to indexing with GROUP BY problems)

The result is a query that only needs to do a filesort on the final result set, which will only be as many rows as there are entities.

* Remove the ORDER BY entity_id when fetching states, and add logging

Having this ORDER BY in the query prevents it from using an index due to the range filter, so it has been removed.

We already do a `groupby` in the `states_to_json` method which accomplishes exactly what the ORDER BY in the query was trying to do anyway, so this change causes no functional difference.

Also added DEBUG-level logging to allow diagnosing a user's slow history page.

* Add DEBUG-level logging for the synthetic-first-datapoint query

For diagnosing a user's slow history page

* Missed a couple instances of `created` that should be `last_updated`

* Remove `entity_id` sorting from state_changes; match significant_update

This is the same change as 09b3498f41 , but applied to the `state_changes_during_period` method which I missed before. This should give the same performance boost to the history sensor component!

* Bugfix in History query used for History Sensor

The date filter was using a different column for the upper and lower bounds. It would work, but it would be slow!

* Update Recorder purge script to use more appropriate columns

Two reasons: 1. the `created` column's meaning is fairly arbitrary and does not represent when an event or state change actually ocurred. It seems more correct to purge based on the event date than the time the database row was written.
2. The new columns are indexed, which will speed up this purge script by orders of magnitude

* Updating db model to match new query optimizations

A few things here: 1. New schema version with a new index and several removed indexes
2. A new method in the migration script to drop old indexes
3. Added an INFO-level log message when a new index will be added, as this can take quite some time on a Raspberry Pi
2017-08-04 23:16:53 -07:00
Fabian Affolter 52cff83267 Upgrade aiohttp to 2.2.5 (#8828) 2017-08-04 23:14:05 -07:00
Paulus Schoutsen e49b970665 Block dependencies that depend on enum34 (#8698)
* Block dependencies that depend on enum34

* Remove uninstalling enum34

* Update validation script

* Add constraints to tox.ini

* Upgrade yeelight to version that uses enum-compat

* Disable sensor.skybeacon

* Lint
2017-08-04 23:06:10 -07:00
Paulus Schoutsen a0530d8b9c Update frontend 2 2017-08-04 23:02:07 -07:00
Paulus Schoutsen 99d4021f47 Update frontend 2017-08-04 22:58:19 -07:00
Charles Blonde 7f0d0607f1 Fix Dyson sensors if devices are configured without standby monitoring. Fixes #8569 (#8826)
Upgrade libpurecoolink libraries without unused enum34 dependency
2017-08-04 14:27:23 -07:00
Hellowlol cf298c2435 Make HA discover sabnzbd and add it to the Configurator (#8634)
* Init discover sab.

* Fix hound errors

Nobody likes being hound at :(

* sabnzbd discovery says if ssl is active.

* Fixups after codereview.
2017-08-04 23:24:55 +02:00
Boyi C 77cdc833f0 Update yweather.py (#8820)
Fix missing weather unit support.
Move some weather code to their correct classes.
2017-08-04 17:22:38 +02: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
Julian Kahnert 5b4e30cde3 geizhals sensor component (#8458)
* initial create of the geizhals component

* only .coveragerc, geizhals.py, and requirements_all.txt included
2017-08-04 12:11:33 +02:00
Paulus Schoutsen d4dfb4d80c Polymer 2 (#8815)
* Update build for Polymer 2

* Update webcomponents polyfills/helpers

* Load ES5 class adapter when not in dev mode

* Update frontend
2017-08-03 23:46:57 -07:00
Andrey c895f1f1db When Sonos gets a tts source - dont't show an image (#8777) 2017-08-03 17:39:11 +03:00
Haim Gelfenbeyn 944af9cd7d InfluxDB component improvements (#8633)
* Allow reporting some state attributes as tags to InfluxDB

Some state attributes should really be tags in InfluxDB. E.g.
it is helpful to be able to group by friendly_name, or add a custom
attribute like "location" and group by that. Graphs in Grafana are much
easier to read when friendly names are used, and not node ids.

This commit adds an optional setting to InfluxDB config:
'tags_attributes'. Any attribute on this list will be reported as tag
and not as field to InfluxDB.

* Allow overriding InfluxDB measurement for each reported item separately

Bundling all items with the same "unit of measurement" together does not
always makes sense. For example, both "relatively humidity" and "battery
level" are reported as "%", but I'd rather see them as separate
measurements in InfluxDB. This commit allows for 'influxdb_measurement'
attribute. When set on node, it will take precedence over the global
'override_measurement' and component-specific 'unit_of_measurement'.

* Minor updates to InfluxDB component improvements, as suggested by
@MartinHjelmare.

* Moved per-component config from 'customize' into 'influxdb'
configuration section. The following three sub-sections were added:
'component_config', 'component_config_domain' and
'component_config_glob'. The sole supported per-component attribute
at this point is 'override_measurement'.

* Lint

* Fixed mocked entity_ids in InfluxDB tests to be in domain.entity_id
format, to satisfy EntityValues requirements.

* Added tests for new InfluxDB configuration parameters

* Fixes to some docstrings
2017-08-03 16:26:01 +02:00
John Mihalic f3e16ca304 Catch divide by zero errors when a sleep type is 0 (#8809)
Add an optional extended description…
2017-08-03 15:58:40 +02:00
Fabian Affolter 6de38cb941 Upgrade aiohttp to 2.2.4 (#8805) 2017-08-03 11:37:02 +02:00
Pascal Vizeli 8e51e66c9b Update numpy 1.13.1 (#8806)
* Update opencv.py

* Update requirements_all.txt
2017-08-03 11:36:50 +02:00
Matthew Treinish 57dfe378a1 Add mochad light component (#8476)
* Add mochad light component

This commit adds a new component to control x10 dimmers/lights with
mochad.

* Create comm_type and address constants

The comm_type and address conf constants are shared between all mochad
devices because they are required information used for configuring a
device. This commit moves the definition into const.py so they're
consistent between all component types.
2017-08-03 10:51:01 +02:00
Fabian Affolter d8cded637c
Revert "Upgrade aiohttp to 2.2.4"
This reverts commit 7c92f7e1ad.
2017-08-03 10:11:32 +02:00
Fabian Affolter 7c92f7e1ad
Upgrade aiohttp to 2.2.4 2017-08-03 10:08:09 +02:00
Abílio Costa ccf0559059 mqtt switch: add voluptuous for availability topic (#8797) 2017-08-03 07:18:18 +02:00
Paulus Schoutsen 2d38e70268 Merge branch 'polymer-build' into dev 2017-08-02 21:34:20 -07:00
Paulus Schoutsen 9dae1ca5c2 Update frontend 2017-08-02 21:34:04 -07:00
Luuk 6ac8caa857 Fix referencing unset variable in tado climate component (causes update to fail when tado zone is in manual mode) (#8723)
Add an optional extended description…
2017-08-02 15:07:03 +02:00
Fabian Affolter 39131d06ba Improvements (configuration and validation) (#8785) 2017-08-02 14:51:09 +02:00
Fabian Affolter 8a626e1572 Upgrade sphinx-autodoc-typehints to 1.2.1 (#8783)
Add an optional extended description…
2017-08-02 14:15:00 +02:00
Fabian Affolter bc376f7045 Upgrade pyasn1 to 0.3.1 and pyasn1-modules to 0.0.10 (#8787) 2017-08-02 14:14:01 +02:00
Paulus Schoutsen cad1de790e Build frontend with polymer-build 2017-08-02 01:46:08 -07:00
Sebastian Muszynski 32b7f4d16f Fixes UnboundLocalError: local variable 'setting' referenced before assignment (#8782) 2017-08-02 09:14:28 +02:00
Steve Rhoades 1adb5040e7 Feature alexa launch request (#8730)
* Add support for LaunchRequest alexa intent

* Support LaunchRequest for multiple skills

* formatting

* adding tests to cover launch request

* formatting
2017-08-01 22:53:36 -07:00
Lukas Barth 47dad547eb Add 'forecast' ability to yr weather sensor (#8650)
* Add forecast option to YR sensor

* Fix some style issues

* Fix linting
2017-08-01 22:42:51 -07:00
thrawnarn 86c06ad76e New component: bluesound (#7192)
* New component: bluesound

* New component: bluesound

* Removed response.release()
Fixed update_sync_status bug
Changed should_poll to True

* Fix lint error

* Changes to init

* Fixed blank line

* updated requirements

* bump to xmltodict 0.11.0
2017-08-01 22:41:51 -07:00
pezinek 7dbcf63543 flux_led: support for property "available" (#8764)
* flux_led: support for property "available"

* Implemented changes from code review

* Implemented changes from code review

* Implemented changes from code review
2017-08-01 21:26:27 -07:00
Thomas Friedel 6ff340492b use updated osram lightify 1.0.6 component, including bugfix allowing more than 27 devices (#8774) 2017-08-01 20:36:31 +02:00
Fabian Affolter 50cd6c9a9c Catch exception (fixes #8724) (#8731) 2017-08-01 19:30:26 +02:00
Dan Sarginson 365f21b209 Honeywell fixes and improvements (#8756)
* Honeywell fixes and improvements

Give the Honeywell device a state ('On', 'Off', etc) that
can be displayed to user and understood by other components.
Previously this was always 'Unknown'. Update also raises a
state_changed event when a new temperature is polled.

These two together fix an issue (#8688) where Honeywell
climate data couldn't be logged in InfluxDB.

* Roll back some changes

These were not necessary to achieve the result I wanted.

* Renamed RoundThermostat's 'device' member for greater clarity

Now called 'client'

* Improve and simplify discovering thermostat mode

Per code review, this is a rather neater way to discover the thermostat mode

* Update tests for compatibility with new component

The tests previously relied upon the update() method being
called in the constructor. This is no longer the case.

* Address formatting review comment

Parens not necessary

* This system mode is not certain to apply to domestic hot water

Moved the mode lookup to only happen on update of radiator devices,
since hot water devices seem to be treated differently and I can't test.
2017-08-01 16:18:14 +02:00
Tsvi Mostovicz 075422e7ad Add support for file attachments in pushbullet (#8763)
* Add support for file attachments in pishbullet

* Check filepath is allowed
2017-08-01 14:55:46 +02:00
Steven Looman 342ec8ec99 mpd improvements (#8655)
* Don't require the MPD device to online during HASS startup

* Hide private variables

* Keep tox/flake8 happy

* Fix typo

* Force direct update

* Implement MpdDevice.available

* Fix typo
2017-07-31 23:18:26 -07:00
Matt Colyer 2b59b917c4 Allow sonos to select playlists as a source (#8258)
* Allow sonos to select playlists as a source

Most of this was taken from
https://github.com/home-assistant/home-assistant/issues/5598#issuecomment-278229895
however I made a few small improvements so that it works for other
services than Spotify and it should properly switch to playing the queue
if you had another song playing previously.

/cc @PatBoud

* Attempt to fix style issues

* More indent changes

* Fix misplaced period

* Move playlist replacement to function

* Privatize replace_queue_with_playlist and explain

* Remove unneeded decorator

* Fix doc formatting
2017-07-31 23:16:05 -07:00
viswa-swami e40388e7ad Enable/Disable Motion detection for Foscam Cameras (#8582)
* Added support to enable/disable motion detection for foscam cameras. This support was added in 0.48.1 as a generic service for cameras. Motion detection can be enabled/disabled for foscam cameras with this code-set.

* Fixed the violation identified by hound-bot

* Fixed the comment posted by HoundCI-Bot regarding using imperative mood statement for pydocstyle

* Fixed the error that travis-ci bot found.

* As per comment from @balloob, Instead of directly using the URL to talk to foscam, used a 3rd party foscam library to communicate with it. This library already has support to enable/disable motion detection and also APIs to change the motion detection schedule etc. Need to add more support in the pyfoscam 3rd party library for checking if motion was detected or even if sound was detected. Once that is done, we can add that into HASS as well.

* Lint

* Removed the requests library import which is not used anymore

* Updating requirements_all.txt based on the code-base of home assistant that i have. Generated using the gen_requirements_all.py script

* Updating requirements_all.txt and requirements_test_all.txt generated by gen_requirements_all.py after latest pull from origin/dev

* Updated requirements_all.txt with script

* Updated the foscam camera code to fix lint errors

* Fixed houndci violation
2017-07-31 23:14:34 -07:00
William Scanlon cb292a0b18 Wink discovery (#8739)
* Support for Wink discovery

* Switched try/except for if/else
2017-07-31 20:54:07 -07:00
Martin Hjelmare 33663f9502 Clean up remote component (#8728)
* Clean up remote component

* Don't have device be required in send_command service and method.
* Don't have entity_id be required in the base service schema.
* Don't always add activity in the data dict for a service call.
* Update harmony remote platform according to new service schema.
* Remove not needed properties and attributes from the Kira remote
  platform.
* Add send_command method to demo platform.
* Add tests and remove duplicate tests.

* Break out required argument as positional argument
2017-07-31 20:52:39 -07:00
emlt e57d6f679a Change units from KW to W (#8761)
* Change units from KW to W

Change power unit from KW to W to be consistent with other energy sensors.

* Change units from kW to W
2017-07-31 20:41:45 -07:00
mjj4791 775185896a buienradar dates tz-aware (#8767) 2017-07-31 20:37:33 -07:00
Paulus Schoutsen e6331aafb2 Merge remote-tracking branch 'origin/master' into dev 2017-07-31 18:30:40 -07:00
Paulus Schoutsen fbb4c43353 Merge pull request #8757 from home-assistant/release-0-50-2
0.50.2
2017-07-31 18:28:14 -07:00
gwhiteCL 455ac9724a added invert_state optional parameter (#8695)
* added invert_state optional parameter

* removed superfluous parens

* moved state inversion to the is_closed method

* added relay_invert feature

* fixed syntax to comply with houndci-bot rules

* changed state_invert to invert_state and relay_invert to invert_relay
2017-07-31 20:24:21 -04:00
Alan Fischer e6be560e00 Add toggle to remotes (#8483)
* Add toggle to remotes

* Only include activity if specified, and add service description
2017-07-31 19:46:12 +02:00
Adam Mills 59891fa838 Fix Z-Wave barrier discovery for new API (#8706) 2017-07-31 09:15:10 -07:00
Adam Mills 475ab68853 Correctly discover GE Fan Controllers (#8682) 2017-07-31 09:15:10 -07:00