forked from rospogrigio/localtuya
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Open
Lurker00
wants to merge
23
commits into
xZetsubou:master
Choose a base branch
from
Lurker00:light-fixes-and-ble-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
55482aa
Bug: CONF_SCENE_VALUES can be empty
Lurker00 ca3af1c
Bug: Always prepend with general mode controls
Lurker00 bc71204
Support for write-only (BLE) bulbs
Lurker00 2a8982b
If BLE bulb has Music mode, it must have Scene and Color.
Lurker00 93d7fd7
BLE bulbs: support for colors
Lurker00 d2de2e6
Comments regarding scene and color formats
Lurker00 cb20a6b
Fully functional BLE bulbs (from HA only)
Lurker00 e8cf025
Names for BLE bulbs DPs
Lurker00 22f5f61
Add color and scene DPs for BLE bulbs automatically
Lurker00 f8e0868
Add any DP, regardless of the "value"
Lurker00 98b2d2d
Automatic support for BLE color and scene data DPs
Lurker00 7c7e41b
Deduction of BLE bulb from DP 0 presence
Lurker00 fba6640
Fix: Music instead of Mode Scene, when DP CONF_COLOR is None
Lurker00 785ee12
Less calls
Lurker00 212e1a1
String not required anymore
Lurker00 4a1db74
Alphabetical order
Lurker00 eb5db24
Mark write-only DPs as such.
Lurker00 043b11f
Using cloud DP data for Ligths
Lurker00 78642b6
More scenes
Lurker00 cc4c20b
Less scenes
Lurker00 61c161b
Scene data must be lower case
Lurker00 be2f9e1
Obsolete
Lurker00 3f514ae
BLE bulb cloudless manual setup
Lurker00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -44,6 +44,7 @@ | |||||||||||||
from .coordinator import pytuya, TuyaCloudApi | ||||||||||||||
from .core.cloud_api import TUYA_ENDPOINTS | ||||||||||||||
from .core.helpers import templates, get_gateway_by_deviceid, gen_localtuya_entities | ||||||||||||||
from .core.ha_entities.base import DPCode | ||||||||||||||
from .const import ( | ||||||||||||||
ATTR_UPDATED_AT, | ||||||||||||||
CONF_ADD_DEVICE, | ||||||||||||||
|
@@ -1094,6 +1095,16 @@ def schema_defaults(schema, dps_list=None, **defaults): | |||||||||||||
return copy | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
def __is_special_dp(dp, cloud_dp_codes: dict[str, dict]) -> bool: | ||||||||||||||
if not (dp_data := cloud_dp_codes.get(dp)): | ||||||||||||||
return false | ||||||||||||||
if not (code := dp_data.get("code")): | ||||||||||||||
return false | ||||||||||||||
return code in ( | ||||||||||||||
DPCode.COLOUR_DATA_RAW, | ||||||||||||||
DPCode.SCENE_DATA_RAW, | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
def dps_string_list(dps_data: dict[str, dict], cloud_dp_codes: dict[str, dict]) -> list: | ||||||||||||||
"""Return list of friendly DPS values.""" | ||||||||||||||
strs = [] | ||||||||||||||
|
@@ -1102,7 +1113,11 @@ def dps_string_list(dps_data: dict[str, dict], cloud_dp_codes: dict[str, dict]) | |||||||||||||
for dp, func in cloud_dp_codes.items(): | ||||||||||||||
# Default Manual dp value is -1, we will replace it if it in cloud. | ||||||||||||||
add_dp = dp not in dps_data or dps_data.get(dp) == -1 | ||||||||||||||
if add_dp and ((value := func.get("value")) or value is not None): | ||||||||||||||
if add_dp and ( | ||||||||||||||
(value := func.get("value")) | ||||||||||||||
or value is not None | ||||||||||||||
or __is_special_dp(dp, cloud_dp_codes) | ||||||||||||||
): | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
dps_data[dp] = f"{value}, cloud pull" | ||||||||||||||
|
||||||||||||||
for dp, value in dps_data.items(): | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to make exceptions for DPS instead remove the current condition for now. If there are DPS without value and can be used then the condition is not always accurate.