Fix cloud IP fallback and off-state attrs#4
Draft
ejc3 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This fixes two local-control issues used by the Home Assistant AiDot integration:
send_dev_attr()when setting attributes while the light is off. The method attempted to addOnOffto an undefined variable namedattr; it should mutate the supplieddev_attrpayload.properties.ipAddressas a fallback when UDP discovery has not provided an IP, while keeping UDP discovery authoritative when it succeeds.ip_addressproperty so integrations do not need to read_ip_addressdirectly.Details
DeviceClient.send_dev_attr()currently raisesNameErrorfor calls such as brightness/color/CCT while the device is off, because the code usesattr[CONF_ON_OFF]instead ofdev_attr[CONF_ON_OFF].AidotClient.get_device_client()now readsproperties.ipAddressdefensively only whenpropertiesis a dict. If UDP discovery has a current IP, that still wins. If not, the cloud IP is used as a best-effort LAN fallback, including when the previous IP is disconnected.Validation
py_compilepasses foraidot/client.py,aidot/device_client.py, andaidot/models/device_client_model.py.git diff --checkpasses.