smarthomej / addons

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

Alexa commands do not change brightness of RGB strips even though the brightness slider indicates it happened #430

Closed jshatch closed 1 year ago

jshatch commented 1 year ago

If you adjust the brightness slider of an RGB strip in the openhab item itself the strip responds appropriately, however if you use Alexa, either by voice or by moving the slider in the Alexa app the brightness slider in openhab moves but the command is never sent to the device. As soon as you move the slider in openhab after the Alexa attempt the brightness immediately changes.

Commands to change the color or the power state are successful.

jshatch commented 1 year ago

The thing configuration is here:

{
  "channels": [
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:control_data",
      "id": "control_data",
      "channelTypeUID": "tuya:string",
      "itemType": "String",
      "kind": "STATE",
      "label": "control_data",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 28
      }
    },
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:scene_data",
      "id": "scene_data",
      "channelTypeUID": "tuya:string",
      "itemType": "String",
      "kind": "STATE",
      "label": "scene_data",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 25
      }
    },
    {
      "linkedItems": [
        "StripLight_colourdata"
      ],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:colour_data",
      "id": "colour_data",
      "channelTypeUID": "tuya:color",
      "itemType": "Color",
      "kind": "STATE",
      "label": "colour_data",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 24,
        "dp2": 20
      }
    },
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:countdown",
      "id": "countdown",
      "channelTypeUID": "tuya:number",
      "itemType": "Number",
      "kind": "STATE",
      "label": "countdown",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 26,
        "max": 86400,
        "min": 0
      }
    },
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:bright_value",
      "id": "bright_value",
      "channelTypeUID": "tuya:dimmer",
      "itemType": "Dimmer",
      "kind": "STATE",
      "label": "bright_value",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "min": 10,
        "dp": 22,
        "max": 1000,
        "dp2": 20
      }
    },
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:work_mode",
      "id": "work_mode",
      "channelTypeUID": "tuya:string",
      "itemType": "String",
      "kind": "STATE",
      "label": "work_mode",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 21,
        "range": "white,colour,scene,music"
      }
    },
    {
      "linkedItems": [],
      "uid": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x:music_data",
      "id": "music_data",
      "channelTypeUID": "tuya:string",
      "itemType": "String",
      "kind": "STATE",
      "label": "music_data",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "dp": 27
      }
    }
  ],
  "statusInfo": {
    "status": "ONLINE",
    "statusDetail": "NONE"
  },
  "editable": true,
  "label": "Strip Light",
  "configuration": {
    "protocol": "3.3",
    "productId": "ozvljhfjwgachved",
    "deviceId": "eb4a4c6b63201dd215xx1x",
    "localKey": "<removed>"
  },
  "properties": {
    "category": "dd",
    "mac": "d4:a6:51:84:70:fc"
  },
  "UID": "tuya:tuyaDevice:eb4a4c6b63201dd215xx1x",
  "thingTypeUID": "tuya:tuyaDevice"
}
jshatch commented 1 year ago

The group / item:

  "members": [
    {
      "link": "http://openhab:8080/rest/items/StripLight_colourdata",
      "state": "0.0,100,1",
      "type": "Color",
      "name": "StripLight_colourdata",
      "label": "Strip Light Color",
      "category": "ColorLight",
      "tags": [
        "Point"
      ],
      "groupNames": [
        "StripLight"
      ]
    }
  ],
  "link": "http://openhab:8080/rest/items/StripLight",
  "state": "NULL",
  "editable": true,
  "type": "Group",
  "name": "StripLight",
  "label": "Strip Light",
  "category": "",
  "tags": [],
  "groupNames": []
}
J-N-K commented 1 year ago

You linked Alexa to the group and a member of the group is linked to the channel of the device? Did you try exposing the item directly to Alexa?

jshatch commented 1 year ago

Same behavior either way, I tried it as a group so I could try linking the brightness from the bright_value channel, but that only controls the white brightness (it's an RGBW strip). bright_value works from the Alexa app, just the brightness in colour_data does not. It's weird though because openhab is getting the message and moving the slider just not sending the command to the strip unless you move the slider in openhab itself.

J-N-K commented 1 year ago

I‘m astonished moving the slider in openHAB works. It looks like there is missing something on the code. I‘ll check that.

jshatch commented 1 year ago

Maybe the Alexa metadata I'm using will help. It doesn't look like I attached that.

value: Light.Brightness,Light.Color,Light.PowerState
config: {}
jshatch commented 1 year ago

Thanks, I tested the fix in #432 but sadly it seems it made no difference. Previous version was:

329 │ Active  │  80 │ 3.2.15                 │ SmartHome/J Add-ons :: Bundles :: Common Components
330 │ Waiting │  80 │ 3.2.15                 │ SmartHome/J Add-ons :: Bundles :: Tuya Binding

Version I compiled is:

332 │ Active  │  80 │ 3.2.16.202212190106    │ SmartHome/J Add-ons :: Bundles :: Common Components
333 │ Waiting │  80 │ 3.2.16.202212190113    │ SmartHome/J Add-ons :: Bundles :: Tuya Binding

I compiled from commit 4bdd7836f0fa65a3435fe9061e150d5a066b7bd9.

The behavior I described before is no different. I did notice something else though (also present in both versions). As you know, when I use the Alexa app to move the brightness slider the physical brightness does not change but the openhab slider does. However if I immediately select a color (even the current color) in the Alexa app, the color changes and the brightness is set to what the slider was moved to.

Also (this happens on both versions) there are several stack traces that print during initialization of the binding that say Caused by: java.net.BindException: Address already in use. Is this something you know about or is there something potentially wrong on my system that's causing it? It doesn't seem to cause any other problems, as the binding otherwise works. Likely this is not related to this issue though.

J-N-K commented 1 year ago

Did you try the group or the item in Alexa?!The group is not working due to a bug in openhab-core, the item did not work before in my setup bug works now.

if the binding is in waiting state something is wrong. Is there any other Tuya binding running? Can you show the full list of bundles?

jshatch commented 1 year ago

Well, look at that... I had an old Tuya binding buried in the list that didn't go away for some reason when I upgraded to 3.2.15.

242 │ Active  │  80 │ 3.2.13                 │ SmartHome/J Add-ons :: Bundles :: Tuya Binding
333 │ Waiting │  80 │ 3.2.16.202212190113    │ SmartHome/J Add-ons :: Bundles :: Tuya Binding

It has been removed, and the new one is showing as Active now:

333 │ Active │  80 │ 3.2.16.202212190113    │ SmartHome/J Add-ons :: Bundles :: Tuya Binding

Also, the fix is now confirmed as working using the item. Even though the things would respond to uninstalling / deactivating the new one, they still must have been communicating with the old one to some extent. In any case, the stack traces are gone now and everything looks good. Thanks!