Fix Google Assistant brightness calculation (#72514)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>pull/72824/head
parent
f038d0892a
commit
fa98b7e136
|
@ -249,7 +249,7 @@ class BrightnessTrait(_Trait):
|
|||
if domain == light.DOMAIN:
|
||||
brightness = self.state.attributes.get(light.ATTR_BRIGHTNESS)
|
||||
if brightness is not None:
|
||||
response["brightness"] = int(100 * (brightness / 255))
|
||||
response["brightness"] = round(100 * (brightness / 255))
|
||||
else:
|
||||
response["brightness"] = 0
|
||||
|
||||
|
@ -1948,7 +1948,7 @@ class VolumeTrait(_Trait):
|
|||
level = self.state.attributes.get(media_player.ATTR_MEDIA_VOLUME_LEVEL)
|
||||
if level is not None:
|
||||
# Convert 0.0-1.0 to 0-100
|
||||
response["currentVolume"] = int(level * 100)
|
||||
response["currentVolume"] = round(level * 100)
|
||||
|
||||
muted = self.state.attributes.get(media_player.ATTR_MEDIA_VOLUME_MUTED)
|
||||
if muted is not None:
|
||||
|
|
|
@ -225,7 +225,7 @@ async def test_query_request(hass_fixture, assistant_client, auth_header):
|
|||
assert len(devices) == 4
|
||||
assert devices["light.bed_light"]["on"] is False
|
||||
assert devices["light.ceiling_lights"]["on"] is True
|
||||
assert devices["light.ceiling_lights"]["brightness"] == 70
|
||||
assert devices["light.ceiling_lights"]["brightness"] == 71
|
||||
assert devices["light.ceiling_lights"]["color"]["temperatureK"] == 2631
|
||||
assert devices["light.kitchen_lights"]["color"]["spectrumHsv"] == {
|
||||
"hue": 345,
|
||||
|
|
|
@ -385,7 +385,7 @@ async def test_query_message(hass):
|
|||
"light.another_light": {
|
||||
"on": True,
|
||||
"online": True,
|
||||
"brightness": 30,
|
||||
"brightness": 31,
|
||||
"color": {
|
||||
"spectrumHsv": {
|
||||
"hue": 180,
|
||||
|
@ -1510,7 +1510,7 @@ async def test_query_recover(hass, caplog):
|
|||
"payload": {
|
||||
"devices": {
|
||||
"light.bad": {"online": False},
|
||||
"light.good": {"on": True, "online": True, "brightness": 19},
|
||||
"light.good": {"on": True, "online": True, "brightness": 20},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue