Send event jython

is there a way to do a send Event (like events.sendCommand) in jython ?
I would like to simulate a button press (hue button), in code…

Do you mean events.postUpdate?

no , you can have rules which can be triggered by an event.
@when("Channel hue:0820:0017886a75c1:92:dimmer_switch_event triggered ")

so, I was thinking if it was possible to send an event or trigger an event.

Why not create an Item linked to the dimmer_switch Channel and then send a Command to it?

a command?
let me explain: I have a hue smart button.
When I press the button, in openhab, there’s a trigger event.
But, that button, is connected with my hue bridge, and configured on my bridge.
so, pushing the button, does, let’s say, put my lights on or off.
I want to simulate that trigger by code, so, the bridge thinks, it comes from that button. and turns on/off the lights.
if i do a sendCommand to the dimmer_switch, with value 1002.0 (short released)
the dimmer_switch item just gets the value 1002.0 and nothing more…

Hmmm… do the lights change after the sendCommand? I’m not familiar with it, but this sounds like an issue with the Hue binding. What is the point of the Channel if Commands sent to Items linked to them don’t do anything? If sending a Command doesn’t do anything, then I doubt triggering an event for the Channel would do anything either (BTW, this is possible using scripted automation).

So it’s the binding you want to be able to send an “event”? (How you’d trigger that from within openHAB is pretty immaterial, and the regular Item.sendCommand() would do nicely)

1 Like

the channel dimmerswitch just keeps the state I guess.

If Items linked to Hue binding Thing Channels cannot be controlled by sending them a command, then something sounds really wrong. Does the Action do anything?

Do you mean that you want to trigger a button-pressed event (e.g. 1002.0) in software that should cause the Hue bridge to act as if the corresponding physical button was pressed? I don’t think that is possible.

But, like @rossko57 said, what’s the point? Pressing the buttons will result in some action. Let’s say that pressing the physical button triggers an event that turns two lights on. What you really want is to get that same result from your OH system by turning on those two lights triggered by some other condition (like a switch on a sitemap). End result: exactly the same… :sunglasses:

yes I want that same result. That is also what home automation is about. I want to be able to use that button, or, when I’m not at home or sitting at the table, do the same with a switch on a sitemap or maybe when a sensor gets triggered…

Well, that should be easy. Whatever the rule triggered by the event does, just make it also trigger when you flip a virtual switch item on a sitemap. Either by adding an additional when or separating the logic into a lambda and call it whenever you want the action to take place.

To elaborate a bit on that, you should create a switch item and add an additional when changed condition for that switch item to the rule that is now triggered by the button press event.

that doesn’t work. My hue button doesn’t know the lights were changed to on or off.
When I turn off lights off that were on, and then, I push the hue button, nothing happens. When pushing again, lights go ON. and vice versa.
When I turn off lights using the hue app, and then push the hue button, it just works…
so, the hue binding is incomplete

If you think this is a hue binding problem, you might change the thread title or tags to attract the correct interested people.

You might also provide details of how you have configured the offending Items, channels, Things, and a sample of your events.log showing what happens.

The hue button does not keep any state, it just sends commands to the ZigBee coordinator through the ZigBee network. In your case, this is the Hue bridge. The hue bridge has the configuration too (configuration, lights, groups, scenes, …). In openhab, you are not able to get any events from the hue binding. the hue binding is polling the hue bridge in order to get state changes of items/channels which are changes outside of openhab.
If you want to get button events you need to exchange the ZigBee coordinator with one like deCONZ/Phoscon. I did this and it is not an easy way to go.

You have to be more precise to describe your problem case as said in the quote above.
I would be glad to help you with the hue lighting.

Hue Bridge
1 Hue Lamp
1 Hue Button
The hue button is configured though the hue app: Scene selection
This means: One push: first scene, 2 pushes: Second scene , etc…
for the test: one push: light turns on with first scene
wait a few seconds(so we have no double click), push again, lights turns off.
Openhap config:
hue binding active
light and button is discovered.
light and button created as thing with paperUI
light channels and button item channels created with paperUI
Official Hue App running on android
Test 1:
Light is ON
Turn off light with hue app, push hue button=> light is turned on again
Push hue button again, => light is turned off
=> test success
Test 2:
Light is ON
a (Jython)rule executes a events.sendCommand OFF to the light Item => the light is turned OFF
Push hue button => NOTHING HAPPENS
wait a few seconds => push button=> light goes ON
Test Failed…
tested it in different combinations. Same results.
When I look at :
I see not only the light is set, but also a sensor?? is set. Maybe that’s the problem?
Anyway, something is not fully implemented…
ps: getting button events is no problem…

But they remain completely invisible to us.

I think we are not talking about the same button events :slight_smile:

I’ve been searching info about the hue binding.
Where van i find:
Info about development
Info about the changes
Info about problems
Important too, test scenario’s

This binding is not maintained any more, at least too intensively. Few days ago there was a small PR about problems with deCONZ. I went away from hue binding and written a rule to manage groups and scenes, which both are not supported by the hue binding. Now I defined all lights, even when it is as single one, as group.