Skip to content

Commit

Permalink
Fix transform between 0-100 values and 0-255 values
Browse files Browse the repository at this point in the history
  • Loading branch information
mnordseth committed Mar 29, 2023
1 parent 8cc5749 commit 879faf8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/enet/light.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Enet Smart Home light support"""
import logging
import math

from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity

Expand Down Expand Up @@ -92,7 +93,7 @@ async def async_turn_on(self, **kwargs):
_LOGGER.info("async_turn_on: (%s) %s", self.name, kwargs)

if brightness := kwargs.get("brightness"):
value = int(float(brightness) / 255 * 100)
value = int(math.ceil(float(brightness) / 255 * 100))
await self.channel.set_value(value)
else:
await self.channel.turn_on()
Expand Down

0 comments on commit 879faf8

Please sign in to comment.