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

Use color picker white point to switch to white mode. #182

Merged
merged 2 commits into from
Nov 23, 2020

Conversation

ultratoto14
Copy link
Collaborator

Fix also unwanted DP request that can generate unneeded log entry in DEBUG mode.

@ultratoto14 ultratoto14 requested a review from postlund November 23, 2020 12:40
@ultratoto14 ultratoto14 mentioned this pull request Nov 23, 2020
@FeikoJoosten
Copy link

@ultratoto14 seems to function as intended. However, did find another bug. If you change the brightness of the lamp, the previous color value is taken into account instead of the last assigned mode (white/color).

@ultratoto14
Copy link
Collaborator Author

@FeikoJoosten can you describe a little more the steps for your brightness issue ?

@FeikoJoosten
Copy link

@ultratoto14 I have the lamp configured as followed.
image

With the setup from the screenshot. The lamp is set to white with a low brightness.
Adjusting the brightness changes the lamp to a blue color and allows me to change the brightness.
Adjusting the color temperature back to the desired color, reverts the brightness to the low brightness again (no clue what the brightness value is).

@ultratoto14
Copy link
Collaborator Author

On the screenshot, the white point is not centered, it means HA thinks your device is in color mode.
If you use this PR, close the window and reopen it, the color picker should be really centered, if it's not the case, the white status is not reflected in HA. Do you use the tuya app at the same time ?

@FeikoJoosten
Copy link

FeikoJoosten commented Nov 23, 2020

I have it perfectly centered now and I still have the same issue I mentioned before.
image

I do not use the Tuya app for this device at the same time. This is only running through LocalTuya.

@ultratoto14
Copy link
Collaborator Author

Can you enable the debugging, do the steps and post here the log file ?
It could also help to point the time for each step you are doing.

@FeikoJoosten
Copy link

FeikoJoosten commented Nov 23, 2020

Per your request here are the logs when changing the light settings.

2020-11-23 15:30:00 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Send payload: b'{"devId":"80157022e09806021245","uid":"80157022e09806021245","t":"1606145400","dps":{"1":true,"5":"727272002d0075","2":"colour"}}'
2020-11-23 15:30:00 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Waiting for sequence number 19
2020-11-23 15:30:00 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Dispatching message TuyaMessage(seqno=19, cmd=7, retcode=0, payload=b'', crc=1902033541)
2020-11-23 15:30:00 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Dispatching sequence number 19
2020-11-23 15:30:00 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Decrypted payload: {}
2020-11-23 15:30:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Sending command set (device type: type_0a)
2020-11-23 15:30:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Send payload: b'{"devId":"80157022e09806021245","uid":"80157022e09806021245","t":"1606145401","dps":{"1":true,"2":"white","3":3,"4":141}}'
2020-11-23 15:30:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Waiting for sequence number 20
2020-11-23 15:30:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Dispatching message TuyaMessage(seqno=20, cmd=7, retcode=0, payload=b'', crc=204324061)
2020-11-23 15:30:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Dispatching sequence number 20
2020-11-23 15:30:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Decrypted payload: {}
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Sending command heartbeat (device type: type_0a)
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Send payload: b'{}'
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Waiting for sequence number -100
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211)
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Got heartbeat response
2020-11-23 15:30:03 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Decrypted payload: {}

Full log: home-assistant.log

@ultratoto14
Copy link
Collaborator Author

Hi @FeikoJoosten thanks for the logs. What we can see is that the HA light does not receive any data from the device, all the decrypted payload are empty.
I also see in the sent commands that your brightness is set to 3 ("3":3):

2020-11-23 15:30:01 DEBUG (MainThread) [custom_components.localtuya.pytuya] [801...245] Send payload: b'{"devId":"80157022e09806021245","uid":"80157022e09806021245","t":"1606145401","dps":{"1":true,"2":"white","3":3,"4":141}}'

Can you set a min value of 25 as you showed in your post and check again ?

@FeikoJoosten
Copy link

FeikoJoosten commented Nov 23, 2020

The issue still occurs if I set the brightness min to 25. However, I think there might be something else going on as well, possibly causing this issue. The lamp seems to be unaware of it's actual state. For example, turning off the lamp in HA causes HA to turn it back on in Lovelace. (The lamp does stay off though).

Included updated log from the moment I've set the min brightness to 25. home-assistant.log

Edit: Gif of issue where the lamp turns on again in Lovelace.
3GhhGL7Vzh

@ultratoto14
Copy link
Collaborator Author

ultratoto14 commented Nov 23, 2020

I had this issue before, when you set a value out of the range, the device may fail. Can you try to physically switch off and on the device ?

@FeikoJoosten
Copy link

Hmm and now I have a feeling I might need to reinstall LocalTuya.

Platform localtuya does not generate unique IDs. ID local_80157022e09806021245_1 already exists - ignoring light.kitchen_light
Home Assistant has started!``` 

@ultratoto14
Copy link
Collaborator Author

ultratoto14 commented Nov 23, 2020

You can first try to remove the entity from the integration page and restart HA first.

@postlund, this error mentioned by FeikoJoosten, also occurred sometimes on my setup, maybe it's linked to YAML device configuration migration. Are you aware of that one ? Is it problematic or an expected behavior ?

@FeikoJoosten
Copy link

Okay, readding the light and with the change from this PR resolves all of my issues. The light seems to function properly!

@postlund
Copy link
Collaborator

@ultratoto14 I think I've seen it in some other issue before, I don't know what has happened but I sure do want know. If you can manage to replicate, I would like to know how and also see the config entries created by the integration.

custom_components/localtuya/light.py Show resolved Hide resolved
custom_components/localtuya/light.py Outdated Show resolved Hide resolved
@postlund postlund closed this Nov 23, 2020
@postlund postlund reopened this Nov 23, 2020
@postlund
Copy link
Collaborator

Sorry 'bout the accidental close, I'm on mobile and the UI jumped all over the place and I was too fast...

@ultratoto14
Copy link
Collaborator Author

No problem.

@ultratoto14 ultratoto14 merged commit 095f649 into master Nov 23, 2020
@ultratoto14 ultratoto14 deleted the white_point branch November 23, 2020 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants