[SOLVED] Rule is not working

Hey,

I’m using openhab on a raspberry pi 3 with the openhabian image.

Because the Hue Binding doesn’t support scenes, I tried to write a rule for it. But it is not working, like there is no rule.

Item:

Number Hue_Wohnzimmer <dimmer>

Sitemap:

Selection item=Hue_Wohnzimmer label="Beleuchtungsszene wählen" mappings=[0="Nichts gewählt", 1="Sonnenuntergang", 2="Tropendämmerung", 3="Nachtlicht"] icon="slider"

Rule:

rule "Hue Wohnzimmer Szene"
when 
    Item Hue_Wohnzimmer changed
then 
    logDebug("Hue_Wohnzimmer", "Start")
    scene_group = "1"

    if (Hue_Wohnzimmer == 0) {
        logDebug("Hue_Wohnzimmer", "Item Wert = 0")
    }
    else {

        if (Hue_Wohnzimmer == 1) {
            scene_id = "5jOHGhUZDGs1VDV"
            logDebug("Hue_Wohnzimmer", "Szene Sonnenuntergang")
        }
        else if (Hue_Wohnzimmer == 2) {
            scene_id = "o0bZ8PNthun8sKi"
            logDebug("Hue_Wohnzimmer", "Szene Tropendämmerung")
        }
        else if (Hue_Wohnzimmer == 3) {
            scene_id = "bL6s-5CLABfEv0V"
            logDebug("Hue_Wohnzimmer", "Szene Nachtlicht")
        }

        // HTTP Request

        sendHttpPutRequest(bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
        logDebug("Hue_Wohnzimmer", "HTTP Request:")
        logDebug("Hue_Wohnzimmer", bridgeURL + "groups/" + scene_group + "/action", "application/json", '{"scene": "' + scene_id + '"}')
    }

end

The log is only showing the following entry:

2018-07-28 19:52:34.995 [ome.event.ItemCommandEvent] - Item 'Hue_Wohnzimmer' received command 1
2018-07-28 19:52:35.010 [vent.ItemStateChangedEvent] - Hue_Wohnzimmer changed from 0 to 1

Thank’s for your help.

Try changing your logDebug to logInfo and look in openhab.log.

The other obvious thing I see is that you need to replace Hue_Wohnzimmer with Hue_Wohnzimmer.state.

For example:

    if (Hue_Wohnzimmer.state == 0) {

1 Like

Thank you so much.
It works :slight_smile:

1 Like