Rules with Friends of Hue


I want generate a rules files with Friends of Hue. items list have this items:

hue_0830_ecb5fa129bd9_21_last_updated (Type=DateTimeItem, State=2020-02-13T20:11:38.000+0100, Label=Letzte Aktualisierung, Category=Time)
Kueche_Lichtschalter_Switch (Type=SwitchItem, State=ON, Label=null, Category=null)
hue_0830_ecb5fa129bd9_21_tap_switch (Type=NumberItem, State=20.0, Label=Tap Schalter, Category=null)
hue_0840_ecb5fa129bd9_2_last_updated (Type=DateTimeItem, State=NULL, Label=Letzte Aktualisierung, Category=Time)
hue_0840_ecb5fa129bd9_2_status (Type=NumberItem, State=0.0, Label=Status, Category=null)

In the log I get this otuput when i push the button

20:32:38.251 [INFO ] [smarthome.event.ChannelTriggeredEvent] - hue:0830:ecb5fa129bd9:21:tap_switch_event triggered 20.0
20:32:38.253 [INFO ] [smarthome.event.ItemStateChangedEvent] - hue_0830_ecb5fa129bd9_21_last_updated changed from 2020-02-13T20:32:18.000+0100 to 2020-02-13T20:32:37.000+0100

my hue.items (I’m not shure whitch is the right, so I have set up two switches)

Switch Kueche_Lichtschalter_Switch {channel="hue:0830:ecb5fa129bd9:21:tap_switch"}
Switch Kueche_Lichtschalter_Switch_Event {channel="hue:0830:ecb5fa129bd9:21:tap_switch_event"}
Number Kueche_Lichtschalter_Number {channel="hue:0830:ecb5fa129bd9:21:tap_switch"}
DateTime Kueche_Lichtschalter_DateTime {channel="hue:0830:ecb5fa129bd9:21:last_updated"}

Now I wan’t set up a rule that I can change the light with the button (hue.rules):

rule "Küche Deckenlampe ein"
        Channel "Kueche_Lichtschalter_Switch" triggered "16.0" or Channel "Kueche_Lichtschalter_Switch" triggered "20.0"
        logWarn("myLog", "Chim Chimney Chim Chimney Chim Chim Cheree2")

I have try different ways with channel and only with one option. But My rule don’t run.

What is the right format for my Friends of Hue switch? Other rules work. Only the FoH not :thinking:

Thank you for help

You have Items… why not use them?

rule "Küche Deckenlampe ein"
        Item Kueche_Lichtschalter_Switch changed
        logWarn("myLog", "Chim Chimney Chim Chimney Chim Chim Cheree2")

Event (trigger) channels and state channels are two different, uh, things.

You cannot directly link a trigger channel to an Item; that’s what the state channels are for.

That’s not a Channel, it’s an Item. So that’s not going to work either.
You can trigger on the event channel - but use the ID given in your events.log

Channel ‘hue:0830:ecb5fa129bd9:21:tap_switch_event’ triggered

I have try with the Item but it is the same problem. And I must check if the new value is 16 or 20 and so I can’t use only changed

My Log:

2020-02-14 06:01:09.842 [vent.ChannelTriggeredEvent] - hue:0830:ecb5fa129bd9:21:tap_switch_event triggered 16.0
2020-02-14 06:01:09.843 [vent.ItemStateChangedEvent] - hue_0830_ecb5fa129bd9_21_tap_switch changed from 21.0 to 16.0
2020-02-14 06:01:09.844 [vent.ItemStateChangedEvent] - hue_0830_ecb5fa129bd9_21_last_updated changed from 2020-02-13T20:36:54.0$
2020-02-14 06:01:10.356 [vent.ItemStateChangedEvent] - hue_0830_ecb5fa129bd9_21_tap_switch changed from 16.0 to 20.0
2020-02-14 06:01:10.356 [vent.ChannelTriggeredEvent] - hue:0830:ecb5fa129bd9:21:tap_switch_event triggered 20.0

But What is the correct way when i must know if the new value is 16 or 20? The Friend of Hue has 4 Tab buttons. each button has 2 values (long and short press)

I have try a rule in the gui of paper UI. That works, but I want learn to set up this with rules files

A SwitchItem’s state can only be ON, OFF, NULL or UNDEF. It can’t be 16 or 20.

It sounds as though your Item is not properly defined and should be a NumberItem.

No you don’t :wink:. The UI rule editor is creating rules through the REST API, which makes JSON files. You can find these in your jsondb files and they are very difficult to write by hand. If you want to use the new rule engine and write script files, you’ll be much better off setting up Jython and the helper libraries using…

Thank you. When I show my logs, it givs one number Item:

Preformatted texthue_0830_ecb5fa129bd9_21_tap_switch (Type=NumberItem, State=20.0, Label=Tap Schalter, Category=null)`

Is this also a ITEM itemnameNumber triggered 20?
I will try this evening


Have you tried it? To trigger from a trigger channel, use the trigger channel ID as seen in your logs. Not any Item, because an Item is not a trigger channel.
You can go one step at time you know, trigger your rule from any event on your trigger channel, and when that works refine it to just selected events.

Now I have try. Thank you for all help.

My solution:

rule "Kueche Deckenlampe ein"
        Item Kueche_Lichtschalter_Number changed to 16.0 or Item Kueche_Lichtschalter_Number changed to 20.0