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

[FEATURE REQUEST] Use move instead of stepping value with transition #168

Closed
jeroenvansch opened this issue Oct 29, 2020 · 17 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@jeroenvansch
Copy link

Feature Request

Is your feature request related to a problem?

I noticed that the brightness hold funtion doesn't dim smoothly with my Tradfri lights. And also quite a lot of traffic on the zigbee network during Hold functions.

Describe the solution / feature you'd like

Instead of sending a new brightness value to the lights with a transition time every second you could just send the "brightness_move": [value] command upon the "Hold" action and the "brightness_move" : 0 command upon the "release" action.
this results in smooth dimming and less traffic.

I don't know if all lights support this, Tradfri and Hue do, but maybe offer it as an alternative in the config so the current way is still available.

Describe alternatives you've considered

Not using ControllerX, but thats not really a good alternative ;)

Additional context

@jeroenvansch jeroenvansch added the enhancement New feature or request label Oct 29, 2020
@xaviml
Copy link
Owner

xaviml commented Oct 31, 2020

Hi @jeroenvansch,

Thank you for opening this issue. First of all, ControllerX was first created to do such behaviour, so it is able to support different integrations and different lights. What you are mentioning is related to Zigbee2MQTT, is that correct? deCONZ also has its way of doing so, but not ZHA as far as I know. So since each integration is different, I came up with a solution that would work for everyone - send requests periodically to HA and let HA handle the requests.

If you are having issues with your network, I would recommend you tweaking the delay parameter, so fewer requests are sent to HA.

Having said this, I love your idea, in fact, this is related to #118, which propose to send MQTT requests rather than sending call services to HA. However, this is not an easy change, to do, but it is something I will be adding, so ControllerX with Zigbee2MQTT can be used without the need of HA, therefore, improving the performance and the overall experience. What I did not consider is that Zigbee2MQTT has the brightness_move option, so thank you for pointing this out!

I will keep this ticket open, but it will be handle by #118.

Cheers,
Xavi M.

@jeroenvansch
Copy link
Author

Hi @xaviml,

You are correct in assuming my setup uses Z2M. Being able to directly send commands to MQTT would indeed be a major improvement!
Would you like an example of the automations from HA that I use to get smooth dimming/CCT changes using the Brightness move/step commands?

regards,
Jeroen

@xaviml
Copy link
Owner

xaviml commented Nov 1, 2020

Hi @jeroenvansch,

An example of your current automation would be indeed helpful, thank you :)

Regards,
Xavi M.

@xaviml
Copy link
Owner

xaviml commented Nov 7, 2020

Hi @jeroenvansch,

I have been playing today with the current code of ControllerX to achieve what we aim for this ticket:

exampe_app:
  module: controllerx
  class: E1810Controller
  controller: livingroom_controller
  integration: 
    name: z2m
    listen_to: mqtt
  light: light.livingroom_lamp
  smooth_power_on: true
  multiple_click_delay: 250
  merge_mapping:
    brightness_up_hold:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/livingroom_light/set
        payload: '{"brightness_move": 60}'
    brightness_down_hold:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/livingroom_light/set
        payload: '{"brightness_move": -60}'
    brightness_up_release:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/livingroom_light/set
        payload: '{"brightness_move": 0}'
    brightness_down_release:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/livingroom_light/set
        payload: '{"brightness_move": 0}'

I overwrote the brightness hold and release actions to call MQTT topic you mentioned, and this works as expected. This is just a proof of concept for me to know it is viable, the idea now is do this calls internally and through the MQTT integration with AppDaemon, so without communicating to HA.

I will keep you updated with my advancements.

Regards,
Xavi M.

@htvekov
Copy link
Contributor

htvekov commented Dec 21, 2020

Hi' @jeroenvansch & @xaviml

Just stumbled over this feature request by accident.

Have tested with completely default setting for an E1810 controller and only tweaked bringtness_move from 60 to 80.
This gave a 100% smooth transition in brightness from 0 to 255 and down again on an Ikea E14 White Spectrum bulb.
Never (as in NEVER !) experienced this before using z2m and HA / ControllerX with ANY settings of delay/automatic_steps.

This is as smooth as with proprietary Hue bridge and Hue dimmers.
Amazed I've never actually heard of brightness_move command before ?

We need this, Xavi !! 😁😆🎄🎁🎉😉
Well, if we could get this implemented along with ControllerX ->MQTT commands then my Hue Bridge will be obsolete for sure 😉
Then I'll be able to do perfect, smooth dimming, both single bulbs and zigbee groups, through ControllerX and z2m integration 😎👍

Merry Christmas guys and stay safe 🎄🎉🍻🍻

@xaviml
Copy link
Owner

xaviml commented Dec 22, 2020

Hey @htvekov,

I am glad it worked really well. I would love to implement this in ControllerX as you know, but it is not an easy task since ControllerX deeply depends on HA call services and calling it periodically with hold actions. I was thinking that the same way we have a integration attribute that indicates the integration of the controller (input), I would add an integration_output (name TBD) that would define the integration of the entity (light, media player, etc) which is the output. However, this is a very expensive solution since I will need to add support for all the integration and all the entities for it.

Another solution I thought was to ad a new attribute for light controller to define the strategy of the hold-release actions:

  • default: What is currently doing
  • z2m_mqtt: Implement connection directly with MQTT broker to change brightness or other attributes.
  • z2m_ha: Same as the previous one, but calling the mqtt.publish service from HA (as the example above)
  • deconz: deCONZ supports something similar to brightness_move

And more to come when needed. Probably this second option is cheaper in time, but it will still give the results we want.

Regards,
Xavi M.

@htvekov
Copy link
Contributor

htvekov commented Dec 26, 2020

Hi' @xaviml

As ControllerX from the very beginning was build with HA as core integration, I wouldn't suggest to start all over and build yet another complete parallel MQTT integration from scratch.

Neither, I don't believe there's an actual need for a full MQTT integration (non HA dependant) now or in future ?
HA integration as is, is extremely powerfull and has virtually very few limitations.
But, as discussed in other threads, HA state machine calls/requests can be quite time consuming and for many commands through HA integration lag becomes notisable compared to eg. direct MQTT integration.

A MQTT 'light' light entity integration 😉 as you've scheduled, would in my opinion be sufficient and add great value to ControllerX.

On, off, toggle and use of move and step commands for color/brightness control directly from ControllerX as MQTT commands (single entitys or groups) would be awesome ! 😉😎

Ciao !

@xaviml
Copy link
Owner

xaviml commented Jan 3, 2021

Hi Henning,

Thank you for your input. I totally agree with you, it would be time-consuming to start all over again to add this functionality, so I will be adding the MQTT functionality to the light controller as I described earlier. This way we can define how we want the light controller to work.

Regards,
Xavi M.

@htvekov
Copy link
Contributor

htvekov commented Jan 3, 2021

Awesome, Xavi 👍😊

Let me know when there's something to test and I'll gladly assist.

@bartplessers
Copy link

hi @xaviml

Can you provide an example for the E1744LightController?

Following does not work for me:

exampe_app:
  module: controllerx
  class: E1744LightController
  controller: sensor.my_n99_p99_switch_r14_dimmer_action
  integration:
    name: z2m
    listen_to: mqtt
  light: light.my_n01_p01_light_l18_hanglamp
  smooth_power_on: true
  multiple_click_delay: 250
  merge_mapping:
    brightness_up_hold:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": 60}'
    brightness_down_hold:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": -60}'
    brightness_up_release:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": 0}'
    brightness_down_release:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": 0}'


@bartplessers
Copy link

bartplessers commented Nov 20, 2021

FYI,
this works, and works very well.
set debounce in in zigbee2mqtt devices.yaml:

'0x680ae2fffe3d52fb':
  friendly_name: my/n99/p99/switch/R14/dimmer
  debounce: 0.2

sample config of controllerx in apps.yaml:

my_n99_p99_switch_r14_dimmer:
  module: controllerx
  class: E1744LightController
  integration: z2m
  controller: sensor.my_n99_p99_switch_r14_dimmer_action
  light: light.my_n01_p01_light_l18_hanglamp
  smooth_power_on: true
  merge_mapping:
    brightness_move_up:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": 100}'
    brightness_move_down:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": -100}'
    brightness_stop:
      service: mqtt.publish
      data:
        topic: zigbee2mqtt/my/n01/p01/light/L18/hanglamp/set
        payload: '{"brightness_move": 0}'

@xaviml
Copy link
Owner

xaviml commented May 22, 2022

Leaving this link here for reference: https://www.zigbee2mqtt.io/devices/LED1545G12.html

@Bascht74
Copy link

@xaviml
Thank you for still looking into this!
It would be very nice to get that feature into ControllerX natively!

@xaviml
Copy link
Owner

xaviml commented May 28, 2022

Hi @Bascht74,

I have some working code already and it works quite well, but I still have to make some adjustments. The approach for this ticket is to create a new type controller. The same as we have Light controller, Media Player controller, Switch controller, etc. I create a new Z2MLight controller. I realised that the functionalities that z2m offers are quite limited to what ControllerX offers with the LightController, so I decided to make it as a separate controller type.

I will keep you all updated once I have PR and beta release for you guys to test.

Regards,
Xavi M.

xaviml added a commit that referenced this issue May 29, 2022
xaviml added a commit that referenced this issue Jun 2, 2022
xaviml added a commit that referenced this issue Jun 2, 2022
@xaviml
Copy link
Owner

xaviml commented Jun 2, 2022

Hi all :)

After a very (very very...) long time, I have been able to tackle this issue. I know I have said that I would be integrating this as part of the Light Controller, however, I realized that there would be so many incompatibilities that it made more sense to create a new controller type, Zigbee2MQTT Light Controller (Z2MLightController). I am happy to announce I have created PR #500 which adds this new controller type.

You can now read the documentation for this functionality here, and you can try it out if you get the code and put it in your instance. Otherwise, I will be releasing a beta version soon, so people can try it.

Regards,
Xavi M.

xaviml added a commit that referenced this issue Jun 3, 2022
xaviml added a commit that referenced this issue Jun 3, 2022
xaviml added a commit that referenced this issue Jun 3, 2022
xaviml added a commit that referenced this issue Jun 3, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
xaviml added a commit that referenced this issue Jun 5, 2022
@xaviml
Copy link
Owner

xaviml commented Jun 5, 2022

Hi all,

I just released a beta version v4.21.0b0 with the support of Z2M Light Controller as described in my previous comments.

You can download from HACS enabling beta versions on ControllerX. Please, let me know if you find any problems. I will be releasing the non-beta version next week or the next.

You can read more about it here.

Regards,
Xavi M.

@xaviml
Copy link
Owner

xaviml commented Jun 15, 2022

This feature has been added to ControllerX v4.21.0 with the addition of Zigbee2MQTT Light Controller.

@xaviml xaviml closed this as completed Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants