Skip to content

Commit

Permalink
Fix #194 CeilingFan Light support and modifications to existing Light…
Browse files Browse the repository at this point in the history
… classes

* Light fuinction support on CeilingFan

* Fix import and fix on/off functions

* Check ENL_FAN_LIGHT_STATUS in _setPropertyMap of Ceiling Fan

* Fix brightness function

* Bugfix of _attr_speed_count initialization

* Enable Fan entity of Lighting System (0x02-0xA3)

* Use setLightStates() if exist

* Support light effect function

* [Ceiling Fan] Invert color temperature and disable unnecessary entities

* Fix color temp problem

* Correcting careless mistakes

* Adjust the light color value set on the device

* Add attr _light_color_level_max
  • Loading branch information
nao-pon authored Sep 17, 2024
1 parent 68bbfa6 commit 51aabda
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 76 deletions.
18 changes: 17 additions & 1 deletion custom_components/echonetlite/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@
from pychonet.lib.const import ENL_CUMULATIVE_POWER, ENL_INSTANTANEOUS_POWER
from pychonet.lib.epc_functions import DATA_STATE_CLOSE, DATA_STATE_OPEN
from pychonet.CeilingFan import (
ENL_BUZZER,
ENL_FANSPEED_PERCENT,
ENL_FAN_DIRECTION,
ENL_FAN_LIGHT_BRIGHTNESS,
ENL_FAN_LIGHT_COLOR_TEMP,
ENL_FAN_LIGHT_MODE,
ENL_FAN_LIGHT_NIGHT_BRIGHTNESS,
ENL_FAN_LIGHT_STATUS,
ENL_FAN_OSCILLATION,
)

Expand Down Expand Up @@ -1190,7 +1196,17 @@
# Home Air Conditioner
0x30: {ENL_HVAC_MODE, ENL_HVAC_SET_TEMP, ENL_HVAC_SILENT_MODE},
# Ceiling fan
0x3A: {ENL_FANSPEED_PERCENT, ENL_FAN_DIRECTION, ENL_FAN_OSCILLATION},
0x3A: {
ENL_FANSPEED_PERCENT,
ENL_FAN_DIRECTION,
ENL_FAN_OSCILLATION,
ENL_FAN_LIGHT_STATUS,
ENL_FAN_LIGHT_MODE,
ENL_FAN_LIGHT_BRIGHTNESS,
ENL_FAN_LIGHT_COLOR_TEMP,
ENL_FAN_LIGHT_NIGHT_BRIGHTNESS,
ENL_BUZZER,
},
},
0x02: {
0x60: {ENL_OPENING_LEVEL, ENL_BLIND_ANGLE, ENL_OPENCLOSE_STATUS},
Expand Down
10 changes: 7 additions & 3 deletions custom_components/echonetlite/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from pychonet.lib.const import ENL_STATUS

from pychonet.lib.eojx import EOJX_CLASS
from pychonet.CeilingFan import (
ENL_FANSPEED_PERCENT,
ENL_FAN_DIRECTION,
ENL_FAN_OSCILLATION,
)
from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.const import (
PRECISION_WHOLE,
Expand All @@ -13,9 +18,6 @@
DATA_STATE_ON,
DOMAIN,
ENL_FANSPEED,
ENL_FANSPEED_PERCENT,
ENL_FAN_DIRECTION,
ENL_FAN_OSCILLATION,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -71,6 +73,8 @@ def __init__(self, connector, config):
self._attr_should_poll = True
self._attr_available = True

self._attr_speed_count = getattr(self._connector._instance, "SPEED_COUNT", 100)

self._set_attrs()
self.update_option_listener()

Expand Down
Loading

0 comments on commit 51aabda

Please sign in to comment.