Commit Graph

133 Commits (cb37df6a619afc167ae758796b8cd980d8e0ee39)

Author SHA1 Message Date
J. Nick Koston 5cde3ca4e1
Switch emulated_hue to use async_timeout instead of asyncio.wait_for (#78608) 2022-09-17 08:34:44 +02:00
epenet 7871a517a8
Import constants from root (#78271) 2022-09-12 18:53:05 +02:00
epenet ff356205bf
Use platform constants from root (#78032) 2022-09-08 12:24:45 +02:00
epenet f14bb8195f
Import climate constants from root [a-l] (#78021) 2022-09-08 11:24:15 +02:00
J. Nick Koston 006ea441ad
Pickup emulated_hue codeowner (#73725)
- I made some changes to this during this cycle so I
  want to get notifications for the next release.
2022-06-20 10:27:38 +02:00
J. Nick Koston f4d339119f
Cache which entities are exposed in emulated_hue (#73093) 2022-06-09 21:17:37 -10:00
J. Nick Koston 4c11cc3dbb
Additional cleanups for emulated_hue (#73004)
* Additional cleanups for emulated_hue

Followup to https://github.com/home-assistant/core/pull/72663#discussion_r884268731

* split long lines
2022-06-05 09:32:59 +02:00
J. Nick Koston 1c334605b6
Enable strict typing to emulated_hue (#72676)
* Add typing to emulated_hue part 2

* cleanups

* adjust targets in test
2022-05-30 08:49:37 +02:00
J. Nick Koston 237ef6419b
Add basic typing to emulated_hue (#72663)
* Add basic typing to emulated_hue

* type a few more places

* fixes

* numbers are always stringified

* numbers are always stringified

* coverage

* drop assert
2022-05-29 18:27:32 +02:00
Marc Mueller 9b9b553521
Disable no-self-use [pylint] (#70641)
* Disable no-self-use

* Remove disable comments
2022-04-25 07:41:01 -07:00
epenet c61378337a
Use EntityFeature enums in emulated_hue (#69573) 2022-04-07 15:22:56 +02:00
J. Nick Koston 723dcbafca
Complete fan speed transition from #59781 (#67743) 2022-03-09 10:38:12 +01:00
Josh Soref 2f5f6cc05e
spelling: components/emulated_hue (#64250)
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-01-19 09:14:57 +01:00
Marc Mueller 7b78862a11
Revert "Use Platform enum [emulated_hue] (#63498)" (#63576)
This reverts commit 4fd555f508.
2022-01-07 11:38:48 +01:00
Marc Mueller 4fd555f508
Use Platform enum [emulated_hue] (#63498) 2022-01-05 20:27:01 +01:00
Marc Mueller 1b32385ab2
Use const imports [a-e] (#63467) 2022-01-05 16:44:13 +01:00
epenet 04e8e84058
Add init type hints [e] (#63102)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-12-31 11:05:44 +01:00
Simone Chemelli 5fc51130ea
Replace util.get_local_ip in favor of components.network.async_get_source_ip() - part 4 (#58669)
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-11-15 09:18:57 -08:00
Marc Mueller 12d1dfdaf9
Use assignment expressions 10 (#57791) 2021-10-15 21:36:03 +02:00
Ville Skyttä d8d34fdd3b
Prefer HTTPStatus over int in HA view JSON functions (#56504)
* Prefer HTTPStatus over int in HA view JSON functions

* Update zwave tests to not expect a fixed typo
2021-09-22 21:59:52 +03:00
Simone Chemelli 8b6d0ca13f
Replace util.get_local_ip in favor of components.network.async_get_source_ip() - part 2 (#53368)
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-09-06 08:44:38 -10:00
J. Nick Koston 70961c79a0
Migrate emulate_hue to use storage to fix I/O in event loop (#50473) 2021-05-12 16:10:28 +02:00
J. Nick Koston 3fa8ffa731
Enable mccabe complexity checks in flake8 (#49616)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-04-25 12:38:40 +02:00
Thomas Hollstegge 66dbb17a4a
Fix opening cover via emulated_hue without specifying a position (#49570) 2021-04-22 19:12:52 -10:00
Erik Montnemery a9065f381d
Use supported_color_modes in emulated_hue (#49175) 2021-04-22 16:42:28 -07:00
Franck Nijhof 055cdc64c0
Add support for IoT class in manifest (#46935) 2021-04-15 10:21:38 +02:00
Franck Nijhof 0d595a2845
Merge of nested IF-IF cases - E-G (#48367) 2021-03-27 12:39:37 +01:00
Franck Nijhof 6932cf9534
Use contextlib.suppress where possible (#48189) 2021-03-23 14:36:43 +01:00
Franck Nijhof 8a56dbf587
Add flake8 comprehensions checks to pre-commit & CI (#48111) 2021-03-19 13:41:09 +01:00
tkdrob 8e06fa017d
Use core constants for emulated_hue (#46092) 2021-02-07 13:52:48 -05:00
denes44 14d914e300
Enable emulated_hue setting XY color and transition time by client (#45844)
* 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
2021-02-03 15:35:27 -10:00
Jean-Yves Avenard cf4b6307ae
Provide compatibility with older Home Assistant installations. (#39539)
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
2020-09-01 09:16:40 -05:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
J. Nick Koston 3cc099af80
Make emulated_hue upnp responder async (#39126) 2020-08-23 09:50:59 +02:00
J. Nick Koston 4371068f6a
Fix emulated hue on/off devices compatibility with alexa (#39063) 2020-08-20 10:27:14 +02:00
kbickar 1505343b4b
Update emulated_hue to allow getting bridge config without username (#38986)
* Allow bridge config without username

* Updated emulated_hue tests

* Test cleanup
2020-08-18 14:02:38 -05:00
Franck Nijhof cc4ebc925c
Improve X-Forwarded-* request headers handling (#38696)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
2020-08-11 22:57:50 +02:00
Jean-Yves Avenard 988cbf12ce
Cache emulated hue states attributes between get and put calls to avoid unexpected alexa errors (#38451)
* 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>
2020-08-03 15:30:16 -10:00
J. Nick Koston 03a0114e10
Avoid shutdown delays when emulated_hue is enabled (#38472)
We would have to wait for the select to timeout for
emulated_hue upnp thread to shutdown

We now close the socket so the select unblocks
right away
2020-08-02 08:32:07 -10:00
Jean-Yves Avenard 36ee9ff58f
Don't advertise switch devices as dimmable lights (#37978)
This issue has been corrected and then reverted multiple times.
It seems that the core issue was a casing one (On/off vs On/Off) ; for better
matching with a real Hue hub, also add the productname.

Tested to work with echo 2 and echo 5.
2020-07-19 22:33:56 -10:00
Franck Nijhof 53545c984b
Log lines do not end with a full stop (#37527) 2020-07-05 23:04:19 +02:00
Shulyaka 5ba38e5053
Add humidifier support to emulated_hue (#37110)
* Add humidifier support to emulated_hue

* add humidifier dependency

* move dependency to after_dependency

* move dependency to hassfest
2020-07-04 17:53:36 -05:00
J. Nick Koston 7746ecc9fb
Cache checking for entity exposure in emulated_hue (#37260)
Since we now base all of exposure checks on data that
will not change, we can cache the result instead
of calculating it every loop.

This change complements the work done in #32718
2020-06-30 13:22:17 -05:00
Igor Gocalinski 2ac4d30736
Add delay in emulated_hue after PUT (#35307) 2020-06-10 15:15:32 +02:00
Thomas Hollstegge ed62fe03b0
Fix emulated_hue compatibility with older devices (#36090)
* Fix emulated_hue compatibility with older devices

* Fix test ugliness

* Fix pylint errors
2020-05-25 14:55:23 -05:00
Thomas Hollstegge c5379a0f35
Improve emulated_hue compatibility with newer systems (#35148)
* Make emulated hue detectable by Busch-Jaeger free@home SysAP

* Emulated hue: Remove unnecessary host line from UPnP response

* Test that external IPs are blocked for config route

* Add another test for unauthorized users

* Change hue username to nouser

nouser seems to be used by the official Hue Bridge v1 Android app and is
used by other projects as well

Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-04 00:18:33 -05:00
Thomas Hollstegge e4e89becc6
Return emulated hue id for update requests (#35139)
* Return emulated hue id for update requests

* Emulated Hue: Rename function argument to match its content

* Use HTTP status consts throughout the test

* Use HTTP status consts in UPnP test
2020-05-03 19:27:19 -05:00
J. Nick Koston 23f278e090
Fix emulated_hue brightness off by one (#34185)
* Fix emulated_hue brightness off by one

Hue uses a max brightness of 254, Home Assistant
uses a max brightness of 255. Values > 127 were
off by one.

* use constant

* fix test

* add debug

* Revert "add debug"

This reverts commit 242220a02e.
2020-04-17 11:59:27 -05:00
springstan 46bbe816f6
Remove None from dict.get(key, None) (#33794) 2020-04-07 21:06:05 +02:00
springstan 0d95eff21d
Use dict literals (#33658) 2020-04-04 22:31:56 +02:00