Skip to content

Commit

Permalink
fix: ensure a minimum flame height value of 1 for any non-zero bright…
Browse files Browse the repository at this point in the history
…ness value from the entity

See https://community.home-assistant.io/t/napoleon-efire-enabled-fireplaces-work-in-progress/547976/31

Signed-off-by: Felix Kaechele <felix@kaechele.ca>
  • Loading branch information
kaechele committed Oct 21, 2023
1 parent 57222b7 commit 36e2a78
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/napoleon_efire/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import logging
from math import ceil
from typing import Any

from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
Expand Down Expand Up @@ -63,7 +64,7 @@ async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the flame to turn on."""
flame_height = 6
if ATTR_BRIGHTNESS in kwargs:
flame_height = round(kwargs[ATTR_BRIGHTNESS] / 255 * 6)
flame_height = min(ceil(kwargs[ATTR_BRIGHTNESS] / 255 * 6), 6)
# Setting the flame height to a non-zero value will also implicitly
# call the power_on function in the bonaparte library.
# Therefor, not calling it explicitly here.
Expand Down

0 comments on commit 36e2a78

Please sign in to comment.