* Do not return cached values for state and brightness
* Move building the uncached state dict behind a lru_cache (_build_entity_state_dict)
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
* Upgrade pytest-aiohttp
* Make sure executors, tasks and timers are closed
Some test will trigger warnings on garbage collect, these warnings
spills over into next test.
Some test trigger tasks that raise errors on shutdown, these spill
over into next test.
This is to mimic older pytest-aiohttp and it's behaviour on test
cleanup.
Discussions on similar changes for pytest-aiohttp are here:
https://github.com/pytest-dev/pytest-asyncio/pull/309
* Replace loop with event_loop
* Make sure time is frozen for tests
* Make sure the ConditionType is not async
/home-assistant/homeassistant/helpers/template.py:2082: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
def wrapper(*args, **kwargs):
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
* Increase litejet press tests with a factor 10
The times are simulated anyway, and we can't stop the normal
event from occuring.
* Use async handlers for aiohttp
tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
/Users/joakim/src/hass/home-assistant/venv/lib/python3.9/site-packages/aiohttp/web_urldispatcher.py:189: DeprecationWarning: Bare functions are deprecated, use async ones
warnings.warn(
* Switch to freezegun in modbus tests
The tests allowed clock to tick in between steps
* Make sure skybell object are fully mocked
Old tests would trigger attempts to post to could services:
```
DEBUG:aioskybell:HTTP post https://cloud.myskybell.com/api/v3/login/ Request with headers: {'content-type': 'application/json', 'accept': '*/*', 'x-skybell-app-id': 'd2b542c7-a7e4-4e1e-b77d-2b76911c7c46', 'x-skybell-client-id': '1f36a3c0-6dee-4997-a6db-4e1c67338e57'}
```
* Fix sorting that broke after rebase
* Withing trigger a call to coordinator after init
* Stop discovery task on STOP event
* Stop dsmr connection task on STOP
* Use autospec in modem_serial tests
close on AioSerial is non async, and should not be mocked as a coroutine
* Make sure responder is specced correctly
tests/components/emulated_hue/test_init.py::test_setup_works
/Users/joakim/src/hass/home-assistant/homeassistant/components/emulated_hue/__init__.py:119: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
protocol.close()
* Don't assume Pymodbus is the only thing logging
* Use gather instead of wait
```
homeassistant/components/homeassistant/__init__.py:208: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
```
* Increase wait time for automation tests
Assuming exit within 1 seconds is unreasonable on a potentially loaded
test machine.
* Avoid changing app state after startup
* Add basic typing to emulated_hue
* type a few more places
* fixes
* numbers are always stringified
* numbers are always stringified
* coverage
* drop assert
* Add definitions for grouping media players
See https://github.com/home-assistant/architecture/issues/364
* Fix Google Assistant tests
* Define sync versions of async_join_players/async_unjoin
* Don't use async API in synchronous test methods
* Fix tests and make pylint happy
The method name `unjoin` is used by another component, so let's use
`unjoin_player` instead.
* Fix emulated_hue tests
The new media player entity in the `demo` component requires a tiny
adjustment in the emulated_hue tests.
* Use "target:" in service description
* Also use "name:" in service descriptions
Co-authored-by: Franck Nijhof <git@frenck.dev>
* Enable setting XY color and transition time by client
* New test for setting XY color value
* Correct block outdent
* New test for setting transition time value
* Fixed commented out code
Prior 0.113 all lights and switches were reported as dimmable devices and this was fixed by #37978.
However, under some circumstances Alexa will not smoothly transition from those broken devices to the new ones as it cache the list of entities.
It is imperative to have Alexa rediscover all devices and then remove the now non-responding duplicates using the Alexa phone App. This can take quite a while if you have lots of devices.
An alternative would be to log to the Alexa web site and remove all the lights instead and then re-discover them all.
If you have multiple echo devices on your network, it is possible that the entries would continue to show as duplicates. This is due to an individual echo devices caching the old list and re-using it.
The only known solution for this is to remove your echo devices from your Amazon account and re-add them.
After that, have Alexa rediscover all your devices.
This is a one-off requirement.
Fixes#39503
* Wait for the state of the entity to actually change before resolving PUT request
Additionally, we cache the entity's properties for up to two seconds for the successive GET state request
When Alexa issues a command to a Hue hub; it immediately queries the hub for the entity's state to confirm if the command was successful.
It expects the state to be effective immediately after the PUT request has been completed.
There may be a delay for the new state to actually be active, this is particularly obvious when using group lights.
This leads Alexa to report that the light had an error.
So we wait for the state of the entity to actually change before responding to the PUT request.
Due to rounding issue when converting the HA range (0..255) to Hue range (1..254) we now cache the state sets by Alexa and return those cached values for up to two seconds so that Alexa gets the same value as it originally set.
Fixes#38446
* Add new tests verifying emulated_hue behaviour.
* Increase code test coverage.
The remaining uncovered lines can't be tested as they mostly check that the hass framework or the http server properly work.
This commit doesn't attempt to fix exposed issues as it would be out of scope ; it merely create the tests to exercise the whole code.
* Update homeassistant/components/emulated_hue/hue_api.py
* Add test for state change wait timeout
* Preserve the cache long enough for groups to change
* Update tests/components/emulated_hue/test_hue_api.py
Co-authored-by: J. Nick Koston <nick@koston.org>