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

support for nebula lights #34

Closed
accelle17 opened this issue Sep 21, 2020 · 14 comments
Closed

support for nebula lights #34

accelle17 opened this issue Sep 21, 2020 · 14 comments
Labels
question Further information is requested

Comments

@accelle17
Copy link

accelle17 commented Sep 21, 2020

Hello, I just got this and it uses a different dps for status, I tried 1.2 and master. It's working on 1.2 by modifying the DEFAULT_ID from 1 to 20.
Below is the DPS:

{ dps:
{ '20': true,
'21': 'white',
'22': 10,
'24': '013103e803e8',
'25': '000e0d00002e03e802cc00000000',
'26': 120,
'101': 1000,
'102': false,
'103': true } }

102 - laser light control/status
103 - nebula control/status
22 - laser brightness default 800 (80%) max 1000 (100%)
101 - laser/rotation speed default 500 (50%) max 1000 (100%)
24 - color (first four digit - color, 2nd four digit - contrast, last four digit - brightness of nebula)
26 - timer in seconds
25 -?
20 - state
21 - mode (colour/white)

@postlund
Copy link
Collaborator

You can set the default DPS by specifying id in the config. You can also do that from a config flow if you add via the Integrations page (assuming you use master and not the latest release).

@accelle17
Copy link
Author

Thanks. I was able to add and define the dps but couldn't see any devices/entities. The logs says:

2020-09-22 11:20:33 ERROR (MainThread) [homeassistant.components.light] Error while setting up localtuya platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/localtuya/light.py", line 74, in async_setup_entry
TuyaCache(tuyainterface, config_entry.data[CONF_FRIENDLY_NAME]),
NameError: name 'TuyaCache' is not defined

@accelle17
Copy link
Author

I was able to add it by modifying TuyaCache to TuyaDevice on light.py. Anyway, I can only turn the light on and off. However, I was trying to add it again by specifying different DPS (to control laser at DPS 102 and nebula light at 103) but the integration wouldn't let me since it's already added. Workaround maybe to send command using this integration to specific dps, is this possible?

@postlund
Copy link
Collaborator

@rospogrigio I think the error above is a side-affect from #38. We really need to setup GitHub actions and with to run static code-analysis, it shouldn't be possible to merge broken code. I can try to fix that.

@postlund
Copy link
Collaborator

If you remove the device fist, you can add multiple lights (one for each of the DP of interest). But you cannot do that after already adding one device. Maybe we should change that.

@accelle17
Copy link
Author

If you remove the device fist, you can add multiple lights (one for each of the DP of interest). But you cannot do that after already adding one device. Maybe we should change that.

great, was able to do this. Is it possible to map the DP for each light entity attribute (brightness/color/contrast)?

@postlund
Copy link
Collaborator

If you remove the device fist, you can add multiple lights (one for each of the DP of interest). But you cannot do that after already adding one device. Maybe we should change that.

great, was able to do this. Is it possible to map the DP for each light entity attribute (brightness/color/contrast)?

Sorry about late reply! We support that for brightness and color temperature. Brightness is a bit buggy now as we only support 255 brightness levels (due to Home Assistant API) and tuya uses roughly 1000. So I guess you will only get the first quarter of brightness levels for now. See #73.

@postlund postlund added the question Further information is requested label Oct 11, 2020
@postlund
Copy link
Collaborator

Brightness levels will be fixed in #80, so we are getting closer. Would be great if you tried out that PR and verified if your bulb works.

@accelle17
Copy link
Author

Thanks. The way I mapped this right now:

  1. nebula (this controls if the device is off/on )
    type: switch
    state DP: 20 (working)

  2. nebula laser:
    type: light
    state DP: 102 (working)
    brightness DP: 22 (NOT working)

  3. nebula light:
    type: light
    state DP: 103
    brightness DP: 101 (use for rotation speed as they have the same min/max value of 29 to 1000, NOT working)

note: brightness of this light is on a DP that has 12 digit hexadecimal so it might be a special type.

I'm contented that I can control this locally so many thanks!

Here's the log when trying to control brightness (no errors):

2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Sending command heartbeat (device type: type_0a)
2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Paylod: b'{}'
2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Waiting for sequence number -100
2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Got heartbeat response
2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Decode payload: b''
2020-10-15 15:09:41 DEBUG (MainThread) [custom_components.localtuya.pytuya] [ebb2e815c7c80a5fc4cq0v] Decrypted payload: {}

@accelle17
Copy link
Author

note: this device uses wb3s board as I updated on blakkader, so flashing is out of the option for anyone who might get to bump on this github.

@postlund
Copy link
Collaborator

Can you provide some values for DP 22 for various settings, so we can try to reverse engineer it? 12 hex bytes almost suggests it's some kind of RGB encoding.

I'm not sure I understand what you mean regarding brightness for nebula light? Rotation speed?

@accelle17
Copy link
Author

For the nebula light component DP24, it's the same as #33 which is HSV.

For DP 22 (brightness of laser) and DP 24 (rotation speed), setting the value using tuya-cli, it ranges from 29 to 1000. It will not take any values below or above that range.

I'm not sure I understand what you mean regarding brightness for nebula light? Rotation speed?

The device has three components - the master control, laser and nebula light. I was thinking to map the rotation speed as brightness since they have the same lower and upper value. Here's a link of the demo so you got the idea of the rotation of the laser stars and nebula light - https://youtu.be/rhdYzAY2pVE

I am thinking of just configuring this device with 3 existing components

  1. The master control as standard light which uses DP20 for the state and DP24 (rotation) for the brightness
  2. The laser component as standard light which uses DP102 for the state and DP22 for the brightness
  3. The nebula lights as RGB light which uses DP103 for the state and DP24 for the HSV once it gets developed.

@postlund
Copy link
Collaborator

Ok, I think I got it. With #80 you should hopefully be able to configure the brightness range according to your needs. Maybe you can try it out? Otherwise it's just color support that is missing for the last part? Should not be any problems as long as we don't have any special encodings to deal with.

@accelle17
Copy link
Author

Tested with the master branch after your merge and it is working. I guess we can close this now and I will just follow #33 for the RGB support. DP 26 for the timer is not that important. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants