Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light fixes and BLE bulbs support #425

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deduction of BLE bulb from DP 0 presence
Lurker00 committed Dec 21, 2024
commit 7c7e41b3f1c57fd6c2cd823cd5bffc2226608c9c
1 change: 0 additions & 1 deletion custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
@@ -97,7 +97,6 @@
CONF_MUSIC_MODE = "music_mode"
CONF_SCENE_VALUES = "scene_values"
CONF_SCENE_VALUES_FRIENDLY = "scene_values_friendly"
CONF_WRITE_ONLY = "write_only"

# switch
CONF_CURRENT = "current"
11 changes: 8 additions & 3 deletions custom_components/localtuya/light.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@
CONF_COLOR_TEMP_REVERSE,
CONF_MUSIC_MODE,
CONF_SCENE_VALUES,
CONF_WRITE_ONLY,
)

_LOGGER = logging.getLogger(__name__)
@@ -161,7 +160,6 @@ def flow_schema(dps):
vol.Optional(CONF_SCENE): col_to_select(dps, is_dps=True),
vol.Optional(CONF_SCENE_VALUES, default={}): selector.ObjectSelector(),
vol.Optional(CONF_MUSIC_MODE, default=False): selector.BooleanSelector(),
vol.Optional(CONF_WRITE_ONLY, default=False): selector.BooleanSelector(),
}


@@ -179,7 +177,7 @@ def __init__(
super().__init__(device, config_entry, lightid, _LOGGER, **kwargs)
# Light is an active device (mains powered). It should be able
# to respond at any time. But Tuya BLE bulbs are write-only.
self._write_only = self._config.get(CONF_WRITE_ONLY, False)
self._write_only = self.is_ble
if self._write_only:
self._device.write_only = self._write_only

@@ -232,6 +230,13 @@ def __init__(
if self._config.get(CONF_MUSIC_MODE):
self._effect_list.append(SCENE_MUSIC)

@property
def is_ble(self):
"""Return if this sub-device is BLE."""
# BLE bulbs don't have status, we can rely on status to detect that but this workaround works fine.
# we can also add status check this way even if somehow 0 was added by mistake it still works.
return self._device.is_subdevice and "0" in self._device._device_config.manual_dps.split(",")

@property
def is_on(self):
"""Check if Tuya light is on."""