Store ZHA light brightness when fading off to turn on at the correct brightness (#26680)

* Use light's on_level in ZHA to turn on at the correct brightness

Previously, if the light is turned off with a time transition, the
brightness level stored in the light will be 1. The next time the light
is turned on with no explicit brightness, it will be at 1.

This is solved by storing the current brightness in on_level before
turning off, and then using that when turning on (by calling the
onOff cluster 'on' command).

* store off light level locally to avoid wearing device's flash memory

* store off brightness in HA attributes

* improve set/clear of off_brightness

* fix device_state_attributes; clear off_brightness when light goes on

* fix tests
This commit is contained in:
Abílio Costa 2019-09-23 14:08:44 +01:00 committed by David F. Mulcahey
parent 2c80ce3195
commit 61634d0a64
2 changed files with 21 additions and 6 deletions

View file

@ -230,7 +230,7 @@ async def async_test_level_on_off_from_hass(
4,
(types.uint8_t, types.uint16_t),
10,
5.0,
0,
expect_reply=True,
manufacturer=None,
)