xaviml / controllerx

Create controller-based automations with ease to control your home devices and scenes.
https://xaviml.github.io/controllerx/
MIT License
334 stars 67 forks source link

[QUESTION] Use case with Shelly official integration and two lights. #629

Open palinf opened 1 year ago

palinf commented 1 year ago

I use Shelly2.5 with official integration for HA.

A physical switch is connected to the Shelly2.5 input0. The shelly is configured in detached mode. Which means that the input is not directly connected to the output. When the physical switch is pressed: binary_sensor.input0 is ON When the physical switch is released: binary_sensor.input0 is OFF

I am successfully using the binary_sensor.input0 to switch light.light1 on and off using a small appdaemon app. I now want that a short press on the switch to switch on light.light1 and a long one switch on switch.light2

I thought controllerx was good for this. Am I correct ?

But:

shelly.click is only received when the switch is released. Therefore it is not possible to implement this use case using it. An event_type: state_changed is however received for the binary_sensor.

Is there a possibility to use the binary_sensor directly (or the state_changed event) ?

xaviml commented 1 year ago

Hi @palinf ,

Have you tried using this device implementation? https://xaviml.github.io/controllerx/controllers/Shelly25/ It supports shelly HA integration and it has an event for hold button:

Regarding the use of binary_sensor entity, I am afraid it is not possible to use it for hold action. The binary sensor only exposes 2 events : "on" and "off", so there is no way to indicate the "hold" action.

The shelly.click should be showing the click_type as long_push when long pressed.

Regards, Xavi M.

xaviml commented 1 year ago

This is an example of how you could control 2 lights with the same controller:

light_1:
  module: controllerx
  class: Shelly25LightController
  integration: shelly
  controller: shellybutton-ABC123456
  light: light.light1
  actions: [single_push_1, single_push_2]

light_2:
  module: controllerx
  class: Shelly25LightController
  integration: shelly
  controller: shellybutton-ABC123456
  light: light.light2
  mapping:
    long_push_1: "on"
    long_push_2: "off"