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

[NEW DEVICE] Support for Shelly Dimmer 2 as a Controller #1014

Closed
wafliron opened this issue Jul 3, 2024 · 5 comments
Closed

[NEW DEVICE] Support for Shelly Dimmer 2 as a Controller #1014

wafliron opened this issue Jul 3, 2024 · 5 comments
Assignees
Labels
new-device New device

Comments

@wafliron
Copy link

wafliron commented Jul 3, 2024

Would be awesome to have the Shelly Dimmer 2 added as a supported Controller. I've just had tons of them installed in my house, with several setup as "scene switches" - i.e. they're connected to light switches on the wall, connected to HA, but don't have any lights directly wired to them. I'd love to be able to use those scene switches to control "disconnected" lights with ControllerX - e.g. use the Shelly Dimmer 2 setup as a scene switch near my bedroom door to control the IKEA ZigBee bulbs in the lamps next to the bed.

I have tried using all three of the existing Shelly Controllers that ControllerX supports, but unfortunately none of them work.

Thank-you!

New Device Support

Device Information

  • Device Model: Dimmer 2 (Wi-Fi)
  • Device Description: Shelly Dimmer 2 (Wi-Fi)
  • Device Manufacturer: Shelly

Integrations

Integration: shelly

Actions

Short activation of SW1 channel (by default the "dim up" channel). e.g. a single short "click" of a push-button lightswitch mechanism connected to SW1 terminal on the device:

event_type: shelly.click
data:
  device_id: 2da13527cbcbe7e0181cb181e49813aa
  device: shellydimmer2-EC64C9C2EF3C
  channel: 1
  click_type: single
  generation: 1
origin: LOCAL
time_fired: "2024-07-03T09:37:05.419816+00:00"
context:
  id: 01J1VZ8TWBVD9BAM1TDEJM7KFQ
  parent_id: null
  user_id: null

Long activation of SW1 channel (by default the "dim up" channel). e.g. push-and-hold of a push-button lightswitch mechanism connected to SW1 terminal on the device - the event seems to appear in HA after the button is pushed for approx 500ms:


event_type: shelly.click
data:
  device_id: 2da13527cbcbe7e0181cb181e49813aa
  device: shellydimmer2-EC64C9C2EF3C
  channel: 1
  click_type: long
  generation: 1
origin: LOCAL
time_fired: "2024-07-03T09:51:40.702965+00:00"
context:
  id: 01J1W03HMYGGRW09GHACVFBNQ8
  parent_id: null
  user_id: null

Short activation of SW2 channel (by default the "dim down" channel). e.g. a single short "click" of a push-button lightswitch mechanism connected to SW2 terminal on the device:

event_type: shelly.click
data:
  device_id: 2da13527cbcbe7e0181cb181e49813aa
  device: shellydimmer2-EC64C9C2EF3C
  channel: 2
  click_type: single
  generation: 1
origin: LOCAL
time_fired: "2024-07-03T09:49:30.881500+00:00"
context:
  id: 01J1VZZJW164CKR0R2KDPXK28V
  parent_id: null
  user_id: null

Long activation of SW2 channel (by default the "dim down" channel). e.g. push-and-hold of a push-button lightswitch mechanism connected to SW2 terminal on the device - the event seems to appear in HA after the button is pushed for approx 500ms:

event_type: shelly.click
data:
  device_id: 2da13527cbcbe7e0181cb181e49813aa
  device: shellydimmer2-EC64C9C2EF3C
  channel: 2
  click_type: long
  generation: 1
origin: LOCAL
time_fired: "2024-07-03T09:49:32.802486+00:00"
context:
  id: 01J1VZZMR2NY9HCCX92SWK8HPB
  parent_id: null
  user_id: null

I haven't been able to generate any other events from the device - nothing similar to "release", "double click", etc.

Notes

The above events were collected with the Shelly Dimmer 2 configured in "Dual button mode" (in device's web UI -> Settings -> Button Type). In this mode you have a separate switch connected to each of the SW1 and SW2 terminals, with one acting as "dim up" and the other acting as "dim down" (when the circuit is closed on the respective terminal). I'm not clear what events would be fired (and when) for the other switch modes, and have no practical way of testing unfortunately.

@wafliron wafliron added the new-device New device label Jul 3, 2024
@wafliron
Copy link
Author

wafliron commented Jul 3, 2024

I should have added - if there's any further information you need, please let me know. And I'm ready / able to help test if you're able to add support.

@xaviml
Copy link
Owner

xaviml commented Sep 10, 2024

This feature has been added to ControllerX beta release v4.27.0.

@xaviml xaviml closed this as completed Sep 10, 2024
@wafliron
Copy link
Author

Thanks for implementing this @xaviml, really appreciate it.

FYI I've just done some testing and it largely seems to work as expected. There is one area where I'm getting strange behaviour however. With this example controller configuration:

shellydimmer2_example:
  module: controllerx
  class: ShellyDimmer2LightController
  integration: shelly
  controller: shellydimmer2-ABC123456
  light:
    name: light.bedroom_lamp_group
  merge_mapping:
    single_1: set_half_brightness
    single_1$2: on_full_brightness
    long_1: hold_brightness_up
    single_2: "off"
    single_2$2: on_min_brightness
    long_2: hold_brightness_down

Whenever I long-press one of the switches attached to the Shelly Dimmer 2 it initiates a dim up/down action as expected - but the dimming doesn't stop when I release the switch, continuing on all the way to 100%/1%. I've tried playing with the delay and automatic_steps parameters, to no avail.

I'm thinking this is due to a limitation of the Shelly device - the fact it doesn't send a "release" action when the switch is released, specifically, so ControllerX doesn't know when to stop the dim - but wanted to double check this is correct / it's not a bug or misconfiguration?

Also, a couple of misc minor suggestions / documentation issues:

  1. Small thing, but it would be logical to set the default action for single_1/long_1 to "on" and single_2/long_2 to "off" (currently "toggle" and no action respectively).
  2. There is a minor mistake in the documentation at https://xaviml.github.io/controllerx/controllers/ShellyDimmer2/ - the example includes the line "controller: shellybutton-ABC123456" - for a Dimmer 2 this should be "shellydimmer2-ABC123456".

Thanks again.

@xaviml
Copy link
Owner

xaviml commented Sep 16, 2024

Hi @wafliron ,

Thank you for double checking this device.

I confirm that the hold-release issue you have is a device limitation as you state. ControllerX needs to know when to stop dimming with a release action which this device lacks of. A solution for this is to leverage the hold_release_toggle feature, so the hold action work as release when another hold action is running. This would mean that you can dim the light holding the button, and stop the dimming by holding the button again.

https://xaviml.github.io/controllerx/start/type-configuration/?h=hold_release_toggle

I can set "on" and "off" for long presses by default with no problem.

Regarding the controller name you see in the docs is a default and generic name for any shelly controller.

Regards,
Xavi M.

@wafliron
Copy link
Author

wafliron commented Sep 16, 2024

Thanks @xaviml.

I will have a play around with the hold_release_toggle option, but it will likely be quite clunky with the type of physical switches I have connected to my Shelly Dimmer 2s.

I suspect a better solution for me will be to have ControllerX take no action on the long action, and then setup separate HA automations to sync the brightness percentage of each Dimmer 2 / controlled-light pair. The Dimmer 2 still adjusts and tracks its own on/off/brightness percent state internally when the switches are pushed/held, even with no light directly connected to it - so I can e.g. hold the dim down switch for a while, Dimmer 2 changes its internal brightness state from e.g. 100% to 99% to 98% (etc), and then that brightness state gets synced to the controlled light via HA automation each time it changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-device New device
Projects
None yet
Development

No branches or pull requests

2 participants