Commit graph

232 commits

Author SHA1 Message Date
Ville Skyttä
3adac699c7 Note snake_case state attribute name convention in entity docs ()
https://github.com/home-assistant/home-assistant/pull/26675#discussion_r331763063
2019-10-07 08:16:26 -07:00
Robbert Müller
7a156059e9 Switch on/off all lights, and wait for the result ()
* Switch on/off all lights, and wait for the result

Reuses the parallel_updates semaphore.
This is a small crutch which serializes platforms which already do tis
for updates. Platforms which can parallelize everything, this makes it
go faster

* Fix broken unittest

With manual validation, with help from @frenck, we found out that the
assertions are wrong and the test should be failing.

The sequence requested is
OFF
ON

without cancelation, this code should result in:
off,off,off,on,on,on

testable, by adding a `await hass.async_block_till_done()` between the
off and on call.

with cancelation. there should be less off call's so
off,on,on,on

* Adding tests for async_request_call

* Process review feedback

* Switch gather with wait

* 👕 running black
2019-10-06 08:23:12 -07:00
Ville Skyttä
f259ff17d5
Type hint additions ()
* Type hint additions

* Remove optional from sidebar_icon comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Remove optional from sidebar_title comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Fix issues after rebase and mypy 0.730
2019-09-29 20:07:49 +03:00
Franck Nijhof
b52cfd3409 Add comment for clarity to helper.entity.enabled() ()
* Fixes entity enabled expression

* Ensure True is returned when there is no registry_entity

* Add comment for clarity to helper.entity.enabled()
2019-09-24 14:21:00 -07:00
Franck Nijhof
6f9ccb5434 Add and corrects typehints in Entity helper & core class ()
* Add and corrects typehints in Entity class

* Adjust state type based on comments
2019-09-24 14:20:04 -07:00
Franck Nijhof
2f0eb07624 Migrate legacy typehints in core to PEP-526 ()
* Migrate legacy typehints in core to PEP-526

* Fix one type
2019-09-03 20:36:04 -07:00
SukramJ
cf3bb300e6 Fix for 0.98: Don't update disabled entities (Homematic IP Cloud) ()
* Homematic IP Cloud Fix: Don't update disabled entities

* Added enabled to entity.py

* Update test for enabled

* Update entity.py
2019-08-28 13:38:20 -07:00
Franck Nijhof
decf13b948 Use literal string interpolation in core (f-strings) () 2019-08-23 09:53:33 -07:00
Paulus Schoutsen
f704a8e90e Reload config entry when entity enabled in entity registry, remove entity if disabled. ()
* Reload config entry when disabled_by updated in entity registry

* Add types

* Remove entities that get disabled

* Remove unnecessary domain checks.

* Attach handler in async_setup

* Remove unused var

* Type

* Fix test

* Fix tests
2019-08-22 19:32:43 -05:00
Paulus Schoutsen
aa56b4dd30
Log warning if disabled entities receive updates. ()
* Log warning if disabled entities receive updates.

* Fix test

* Always set entity ID on disabled entities
2019-08-22 14:12:24 -07:00
Paulus Schoutsen
6c292846be
Allow entities to indicate they should be disabled by default () 2019-08-16 16:17:16 -07:00
Ville Skyttä
aa508b5106 Complete some incomplete type hints in helpers () 2019-08-15 08:53:25 -07:00
Paulus Schoutsen
4de97abc3a Black 2019-07-31 12:25:30 -07:00
Ville Skyttä
d64f1e767c Type check all helpers ()
* 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
David F. Mulcahey
0653f57fb4 change and condition to or condition () 2019-07-21 09:57:40 -07:00
Paulus Schoutsen
06af6f19a3
Entity to handle updates via events ()
* Entity to handle updates via events

* Fix a bug

* Update entity.py
2019-06-26 09:22:51 -07:00
Penny Wood
7a9c9031af I think this is a potential bug () 2019-04-17 09:52:08 -07:00
emontnemery
fc81826763 Introduce Entity.async_write_ha_state() to not miss state transition ()
* Copy state in schedule_update_ha_state

* Lint

* Fix broken test

* Review comment, improve docstring

* Preserve order of state updates

* Rewrite

* Break up async_update_ha_state

* Update binary_sensor.py

* Review comments

* Update docstring

* hass -> ha

* Update entity.py

* Update entity.py
2019-03-09 09:52:22 -08:00
Daniel Høyer Iversen
519315f9c8 pylint 2.3.0 ()
* pylint 2.3.0

* remove const

*  disable=syntax-error
2019-02-27 16:10:40 -05:00
Paulus Schoutsen
987b5cd905
Person component: add storage and WS commands ()
* Forbid duplicate IDs

* Allow loading persons from storage

* Convert to PersonManager

* Add storage support and WS commands to Person component

* Convert list command to differentiate types

* Allow loading person component without defining persons

* Fix cleanups after update/delete

* Address comments

* Start tracking when HA started
2019-02-09 10:41:40 -08:00
Adam Mills
5c3a4e3d10 Restore states through a JSON store instead of recorder ()
* 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
77bf10e37c
Fix unloading an entry can leave states around ()
* Add test that tests unloading on remove

* Add more test things

* Untangle entity remove code from entity platform

* Don't add default implementation of async_will_remove

* Keep entity weakref alive
2018-10-25 19:57:36 +02:00
Paulus Schoutsen
e903f7ffda Manual updates () 2018-10-09 16:54:38 +02:00
cdce8p
3b5e5cbcd6 Async syntax 5, light & lock & remote & scene & telegram & helpers () 2018-10-01 08:56:50 +02:00
Ville Skyttä
ee696643cd Isort preparations ()
* 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
Robert Svensson
97173f495c Device registry store config entry ()
* Allow device registry to optionally store config entries

* Connections and identifiers are now sets with tupels

* Make config entries mandatory

* Fix duplicate keys in test

* Rename device to device_info

* Entity platform should only create device entries if config_entry_id exists

* Fix Soundtouch tests

* Revert soundtouch to use self.device

* Fix baloobs comments

* Correct type in test
2018-08-25 10:59:28 +02:00
Ville Skyttä
dd9d53c83e Update pydocstyle to 2.1.1 and flake8-docstrings to 1.3.0 ()
* Update pydocstyle to 2.1.1 and flake8-docstrings to 1.3.0

* Pydocstyle D401 fixes
2018-08-24 10:28:43 +02:00
Robert Svensson
0009be595c Device Registry ()
* First draft

* Generate device id

* No obscure registry

* Dont store config_entry_id in device

* Storage

* Small mistake on rebase

* Do storage more like entity registry

* Improve device identification

* Add tests

* Remove deconz device support from PR

* Fix hound comments, voff!

* Fix comments and clean up

* Fix proper indentation

* Fix pydoc issues

* Fix mochad component to not use self.device

* Fix mochad light platform to not use self.device

* Fix TankUtilitySensor to not use self.device

* Fix Soundtouch to not use self.device

* Fix Plex to not use self.device

* Fix Emby to not use self.device

* Fix Heatmiser to not use self.device

* Fix Wemo lights to not use self.device

* Fix Lifx to not use self.device

* Fix Radiotherm to not use self.device

* Fix Juicenet to not use self.device

* Fix Qwikswitch to not use self.device

* Fix Xiaomi miio to not use self.device

* Fix Nest to not use self.device

* Fix Tellduslive to not use self.device

* Fix Knx to not use self.device

* Clean up a small mistake in soundtouch

* Fix comment from Ballob

* Fix bad indentation

* Fix indentatin

* Lint

* Remove unused variable

* Lint
2018-08-22 10:46:37 +02:00
Paulus Schoutsen
1be61df9c0
Add recent context ()
* Add recent context

* Add async_set_context to components not using new services
2018-08-20 17:39:53 +02:00
Paulus Schoutsen
c7f4bdafc0 Context ()
* Add context

* Add context to switch/light services

* Test set_state API

* Lint

* Fix tests

* Do not include context yet in comparison

* Do not pass in loop

* Fix Z-Wave tests

* Add websocket test without user
2018-07-28 17:53:37 -07:00
Paulus Schoutsen
d9cf8fcfe8
Allow changing entity ID ()
* Allow changing entity ID

* Add support to websocket command

* Address comments

* Error handling
2018-07-24 14:12:53 +02:00
Ville Skyttä
2f7b79764a More pylint 2 fixes ()
## 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
Ville Skyttä
b92350fb55 Lint cleanup ()
* 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
90a51160c4
Don't run unnecessary methods in executor pool ()
* Don't run unnecessary methods in executor pool

* Lint

* Lint 2
2018-06-07 15:31:21 -04:00
Otto Winter
3442b6741d
Fix WUnderground duplicate entity ids ()
* Fix WUnderground duplicate entity ids

* Entity Namespace
2018-03-17 13:14:53 +01:00
Matthias Urlichs
f5cc40024d Rename homeassistant.util.async to .async_ ()
"async" is (going to be) a reserved word.
2018-03-11 10:01:12 -07:00
Anders Melchiorsen
e2e10b91a7 Grammar fix 'an unique' () 2018-03-03 19:23:55 +01:00
Julius Mittenzwei
16cb7388ee Removing asyncio.coroutine syntax from HASS core ()
* 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
Paulus Schoutsen
6d431c3fc3
Allow renaming entities in entity registry ()
* Allow renaming entities in entity registry

* Lint
2018-02-24 10:53:59 -08:00
Otto Winter
678f284015 Upgrade pylint to 1.8.2 ()
* 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
Paulus Schoutsen
17e5740a0c
Allow overriding name via entity registry ()
* Allow overriding name via entity registry

* Update requirements
2018-02-11 09:16:01 -08:00
Paulus Schoutsen
5601fbdc7a Entity layer cleanup ()
* Simplify entity update

* Split entity platform from entity component

* Decouple entity platform from entity component

* Always include unit of measurement again

* Lint

* Fix test
2018-02-08 12:16:51 +01:00
Paulus Schoutsen
e51427b284 Entity registry ()
* 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
Otto Winter
8dcfd35b8b Spelling fixes ()
* Spelling fixes

*Lots* of them.

* Spelling breaking changes

* Fix lint errors
2018-01-29 23:37:19 +01:00
Ville Skyttä
55ee8959ba Spelling fixes () 2018-01-27 11:58:27 -08:00
Paulus Schoutsen
183e0543b4
Clean up entity component ()
* Clean up entity component

* Lint

* List -> Tuple

* Add Entity.async_remove back

* Unflake setting up group test
2018-01-22 22:54:41 -08:00
Paulus Schoutsen
9384e2c963
Pr/11430 ()
* Fix error when name is non-latin script

When the name is non-latin script (e.g. Japanese), slugify returns empty string and causes failure in a later stage. This commit fixes the issue by using default name.

* Add test
2018-01-11 15:26:48 -08:00
Andrey
f43092c563 Print entity type in "too slow" warnings ()
* Update entity.py

* Update entity.py
2017-11-17 17:36:18 +01:00
Adam Mills
aa6b37912a Fix async missing decorators () 2017-11-16 21:03:05 -08:00
Paulus Schoutsen
4e8e04fe66 Clean up core ()
* Clean up core

* Lint

* Fix tests

* Address comment

* Update entity.py

* romve test for forward update to async_update

* fix lint
2017-11-03 14:19:36 +01:00