smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
59 stars 23 forks source link

Available channels for Tuya SmartBulbs #410

Closed rlarranaga closed 1 year ago

rlarranaga commented 1 year ago

Hello, I used Autodiscover to get my devices imported into openhab. I was surprised that none of my smart bulbs contains a default switch "on/off" channel.

I see that some of the other discovered channels (colour, brightness) have a second parameter "DP 2" that is supposed to work like an ON/OFF switch, however, looking at some of these parameters, de default value that I see is "20". I played with the lights to see if this parameter would change, but it did not.

In short, the question is, what is the best way to turn the lights on and off? Thanks

J-N-K commented 1 year ago

As always in openHAB: send OFF or ON to the brightness/color channel. These channels accept ON/OFF, INCREASE/DECREASE and PercentType for brightness (and HSBType in case of a color channel)

rlarranaga commented 1 year ago

After playing around with the binding for a bit, let me rephrase the question:

I have tuya bulbs from 2 different vendors in my house. Each was discovered with a number of channels (control_data, scene_data, colour_data, bright_value, temp_value ,work_mode, music_data, countdown_1).

I was surprised in that there was no on/off channel discovered automatically, even though both the bright_data and the colour_data channels hint at what DP the switch channel would use. Is there a reason why there isn't an On/Off channel added automatically to the bulbs? Specially taking into consideration that switching lights on and off is likely amongst the actions that are used the most with lightbulbs.

Is this the expected behavior, or is it something related with the specific metadata scheme of the 2 vendors I am using? Happy to share the product IDs if needed

After adding on of channels, (Utilizing the hinted DP from colour_data and bright_value) everything looks great, so thanks for all the work on this binding!

J-N-K commented 1 year ago

It is an openHAB concept that a device that supports

Since you can link a Color type (or Dimmer type) channel to a Switch item and it works as expected, there is no need for a Switch channel and therefore it is considered as duplicate and not added. This is not specific to this binding, it's a general rule.

As a side-note: You can link channels to more than one item, so you can have a Switch item called DiningRoom_Power and a Dimmer item called DiningRoom_Brightness and link both to the same channel of the thing.

You can instruct BasicUI (and I believe also MainUI, but not sure about that) to render the Dimmer item as a switch if you prefer that and from rules you can also send ON or OFF to a Color/Dimmer item, so in most cases a separate Switch item is not needed.

rlarranaga commented 1 year ago

Ok, thanks, that is an interesting concept I didn't know about. I will test using Sending On/Off commands straight to the brightness channel.

Appreciate the help!

J-N-K commented 1 year ago

Feel free to ask if there are any further questions.

rlarranaga commented 1 year ago

Hey,

After using the brightness channels as On/Off Switches for a couple of days, I had to revert to using the On/Of Channels that I created.

One of the issues I am facing is when using the light bulbs in groups. When I do this, I usually create an aggregation for the group that sets the group status as ON when all members are ON, and OFF in any other case.

The problem I encountered is that some of these lights will keep a brightness level of 100 when off. Since 100 appears to be equivalent to ON, this will make the group report the status incorrectly, which in turn will make the group based switches in hab panel non working.

Is this an expected behavior?

Thanks

J-N-K commented 1 year ago

Group aggregation is a little bit difficult if you link items that behave differently. Tuya devices show a very broad range of behavior, some report "zero" as brightness when turned off, some don't. Some report "off" if brightness is "0", some stay "on".

My best advice would be to have a rule that listens for the ON/OFF commands and properly updates the group state.

rlarranaga commented 1 year ago

In this case, I am using groups with the exact same models of lamps, which is why I would have expected all lights to show the same state. Like, if i am send all lights a command for 0 brightness, regardless of the final value, they should all have the same one, shouldn't they?

Thanks

On Fri, Nov 25, 2022, 2:50 PM J-N-K @.***> wrote:

Group aggregation is a little bit difficult if you link items that behave differently. Tuya devices show a very broad range of behavior, some report "zero" as brightness when turned off, some don't. Some report "off" if brightness is "0", some stay "on".

My best advice would be to have a rule that listens for the ON/OFF commands and properly updates the group state.

— Reply to this email directly, view it on GitHub https://github.com/smarthomej/addons/issues/410#issuecomment-1327788678, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABW5CXYOHVSA2BXTR66LNX3WKEC7BANCNFSM6AAAAAARVOS27U . You are receiving this because you modified the open/close state.Message ID: @.***>

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.