Luligu / matterbridge-zigbee2mqtt

Matterbridge zigbee2mqtt plugin
https://github.com/Luligu/matterbridge-zigbee2mqtt/blob/main/README.md
Apache License 2.0
63 stars 8 forks source link

Support transitionTime where applicable (e.g. transition) #28

Closed stefan-schweiger closed 2 months ago

stefan-schweiger commented 2 months ago

Most (if not all) zigbee2mqtt light devices support a duration/transition time for controlling the dim level and sometimes also color.

As far as I can tell this currently is not exposed / passed through with this plugin. Would be great to have this ability where it applies.

Here is the corresponding definition in matter.js:

Luligu commented 2 months ago

Hi, I agree with you 100 %. The problem here unfortunately is not what we could do in the plugin, but what we con do right now with the actual versions of the controllers. There is no controller that send appropriate commands for the duration and transition so there is nothing we can do now. We are still in a situation where all controllers support (not even completely) Matter 1.1. The Matter 1.3 specs added a lot of new devices that I would love to see in the controllers and of course add to z2m plugin too... but we have to wait. Just to make you an example, Matterbridge had the Air Quality device ready since October last year. I had to wait 8 month before seeing it in a controller (HA in this case). All common use new Matter 1.3 devices are already added to Matterbridge but no controllers support them... If you have found a controller that support more let me know... I will be happier then you to add some new devices and more control over the supported clusters. Same problem applies to shelly plugin that I'm releasing now. The devices have a lot of functionalities that I cannot use cause the controllers don't support more then On Off Level Color.

stefan-schweiger commented 2 months ago

Thank you very much for that detailed explanation. Since I'm not running home assistant myself I don't have too much insight how their controller works, but just from a quick glance at the HA code shouldn't this send the command with the transition time? Or do you mean the actual UI/automations don't support it?

EDIT: here is the corresponding issue https://github.com/home-assistant/core/pull/109803

Luligu commented 2 months ago

{ level: 130, transitionTime: 2, optionsMask: { executeIfOff: false, coupleColorTempToLevel: false }, optionsOverride: { executeIfOff: false, coupleColorTempToLevel: false } } This is how the command moveToLevelWithOnOff is sent to our devices from ha. You have no option to set the transition in the ha ui. image

stefan-schweiger commented 2 months ago

It seems a bit weird to me that apparently they just always send transitionTime: 2 in your setup. But what I can gather from the HA documentation (search for transition) it seems like you can either configure a default value for all lights through profiles or use it through automations. For example to create a wakeup light which gets gradually brighter for a duration of like 30 minutes.

stefan-schweiger commented 2 months ago

Just set up HA real quick and configured a automation to move the brightness to 80 within 10 seconds and this is what I see in the matterbridge logs:

Invoke moveToLevelWithOnOff with data {"level":80,"transitionTime":100,"optionsMask":{"executeIfOff":false,"coupleColorTempToLevel":false},"optionsOverride":{"executeIfOff":false,"coupleColorTempToLevel":false}}

So I think HA does handle this correctly.

EDIT: Automation used:

alias: New Automation
description: ""
trigger:
  - platform: webhook
    allowed_methods:
      - POST
      - PUT
      - GET
    local_only: true
    webhook_id: "<my_webhook_id>"
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: <my_entity_id>
    metadata: {}
    data:
      brightness: 80
      transition: 10
mode: single
Luligu commented 2 months ago

Hi, is done.

Are you available to test it on your setup before I publish?

[2.0.18] - 2024-06-17

Added

Fixed

Buy me a coffee

stefan-schweiger commented 2 months ago

Sure, what's the best way to try out some "prerelease" when running matterbridge in a docker container? Just manually building it on my system and copy the results over in the Matterbridge/matterbridge-zigbee2mqtt folder?

Luligu commented 2 months ago

I guess you are expert so I usually do this way with my collaborators that use docker:

This always work but for sure there are other methods...

matterbridge-zigbee2mqtt-2.0.18.zip

Let me know if you need more help.

Thanks for testing.

[2.0.18] - 2024-06-17

Added

Fixed

Buy me a coffee

If you don't want your name just tell me before I publish.

Luligu commented 2 months ago

This work unless you are using a local copy of the plugin.. In that case remove the plugin from the gui. Install it globally like I wrote. Add again the plugin and check it is the global installed one.

Luligu commented 2 months ago

matterbridge-1.3.0.zip

This is matterbridge. You need it before you install z2m plugin, cause there is a change in the api.

stefan-schweiger commented 2 months ago

The transition seems to work fine, so thanks a lot for that! But I'm still seeing the username/password as required for the settings GUI

stefan-schweiger commented 2 months ago

Ok seems like the npm -g install ~/Matterbridge/*.tgz didn't update the config file, if I manually copy it over it's fine

Luligu commented 2 months ago

Yeah I need to publish both cause when you noticed that I was refactoring the loading of schema from .matterbridge to plugin directory. And removing from matterbridge so I don't need to modify matterbridge to modify a plugin schema...

Luligu commented 2 months ago

I need to update ColorControl to Matter 1.3 (they changed a few stuff there). After I will add transition also there... If everything is ok you can close the issue. Thanks for collaborating with me.

stefan-schweiger commented 2 months ago

Thanks again for implementing this so quickly :) let me know once the color control transition is ready then I can test that as well. I will leave the issue upon till then if that's ok for you

Luligu commented 2 months ago

I didn't forget the transition on ColorControl... Just need to publish again Matterbridge (probably if the tests go well tomorrow) and then I will add the transition.

Luligu commented 2 months ago

matterbridge-zigbee2mqtt-2.1.5.zip

[2.1.5] - 2024-07-01

Changed

Can you please test the transition on ColorControl ?

stefan-schweiger commented 2 months ago

Sure, give me a few minutes and I will come back to you!

stefan-schweiger commented 2 months ago

Seems to work exactly as expected! Thank you very much again for implementing this.

Luligu commented 2 months ago

My pleasure, one day maybe all the controllers will have the option for transition... Thanks for testing and for the idea.