Skip to content

trigger channel events for ON/OFF#936

Open
joerg1985 wants to merge 1 commit intoopenhab:mainfrom
joerg1985:trigger-channel-events
Open

trigger channel events for ON/OFF#936
joerg1985 wants to merge 1 commit intoopenhab:mainfrom
joerg1985:trigger-channel-events

Conversation

@joerg1985
Copy link
Copy Markdown
Contributor

This PR will add support for channel events to the new Level Control Events and Switch Events channels.
Allowing to create rules triggered everytime a button on a Level Control or Switch ignoring the state of the channel.

To have trigger different rules depending on the times the button is pressed there are the following events supported:

  • SINGLE_ON: Pressed On once within a short time
  • DOUBLE_ON: Pressed On twice within a short time
  • TRIPLE_ON: Pressed On thrice within a short time
  • SINGLE_OFF: Pressed Off once within a short time
  • DOUBLE_OFF: Pressed Off twice within a short time
  • TRIPLE_OFF: Pressed Off thrice within a short time
  • SINGLE_TOGGLE: Pressed Toggle once within a short time
  • DOUBLE_TOGGLE: Pressed Toggle twice within a short time
  • TRIPLE_TOGGLE: Pressed Toggle thrice within a short time

This has been tested with a IKEA RODRET.

@joerg1985
Copy link
Copy Markdown
Contributor Author

This is a sample rule to listen to `SINGLE_ON:

configuration: {}
triggers:
  - id: "1"
    configuration:
      event: SINGLE_ON
      thingUID: zigbee:device:620c1d1d12:c4d8c8fffef024b6
      channelUID: zigbee:device:620c1d1d12:c4d8c8fffef024b6:C4D8C8FFFEF024B6_1_dimmer_events
    type: core.ChannelEventTrigger
conditions: []
actions:
  - inputs: {}
    id: "3"
    configuration:
      command: ON
      itemName: switch_A
    type: core.ItemCommandAction

@joerg1985 joerg1985 marked this pull request as draft March 2, 2026 21:03
@joerg1985 joerg1985 force-pushed the trigger-channel-events branch from 19a6e78 to 79b4e87 Compare March 2, 2026 21:08
@joerg1985 joerg1985 marked this pull request as ready for review March 2, 2026 21:14
@cdjackson
Copy link
Copy Markdown
Contributor

Sorry I've been travelling a lot over the past few weeks so have had little time to look at this.

I've really only had a quick look over this, but are you aware of the existing button event functions for remotes etc? I'm wondering if we shouldn't be extending that if necessary rather than coming up with these special on/off, or level event handlers. Where do we stop with this? We could end up duplicating this for a bunch more clusters which feels a bit strange given that the events are the same.

I'm just wondering if we really need this functionality, then can we make it generic like the existing events? I'm also not so keen on the binding generating derived events (such as the multi press events), but if we can find a nice way to make it generic it would be better and it might be ok.

@joerg1985
Copy link
Copy Markdown
Contributor Author

joerg1985 commented Mar 8, 2026

Sorry I've been travelling a lot over the past few weeks so have had little time to look at this.

No need to be sorry, we are all doing this on our free time.

I've really only had a quick look over this, but are you aware of the existing button event functions for remotes etc? I'm wondering if we shouldn't be extending that if necessary rather than coming up with these special on/off, or level event handlers. Where do we stop with this? We could end up duplicating this for a bunch more clusters which feels a bit strange given that the events are the same.

Yes, i was aware of these, but the dimmer has two buttons, so i need a way to add more payload to the events.
This is not possible as fair as i can tell, so i did created new events.

I'm just wondering if we really need this functionality, then can we make it generic like the existing events? I'm also not so keen on the binding generating derived events (such as the multi press events), but if we can find a nice way to make it generic it would be better and it might be ok.

I could drop the TRIPLE_* events and use the exisiting SHORT_PRESSED and DOUBLE_PRESSED events with different channels. So one channel for each button, how about ..._on_events, ..._off_events, ..._toggle_events?

This would still allow to:

  • run a rule as soon a button is pressed on a dimmer (see comment in the original issue ticket)
  • use one button for more than one case

@joerg1985 joerg1985 force-pushed the trigger-channel-events branch from 79b4e87 to ed5ce14 Compare March 12, 2026 20:04
@joerg1985
Copy link
Copy Markdown
Contributor Author

I have now simplified the events, there are only two new channels for dimmers and the existing events are used instead of defining new once. So i hope this get's closer to a potential merge :D

@joerg1985 joerg1985 marked this pull request as draft March 19, 2026 16:53
@joerg1985 joerg1985 force-pushed the trigger-channel-events branch from ed5ce14 to bc6ef3e Compare March 19, 2026 21:56
@joerg1985 joerg1985 marked this pull request as ready for review March 19, 2026 21:57
@joerg1985
Copy link
Copy Markdown
Contributor Author

I have found a way to only use one event channel for both buttons and updated the PR, see the updated README.md for details.

Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
@joerg1985 joerg1985 force-pushed the trigger-channel-events branch from bc6ef3e to 2ccba6a Compare March 19, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants