Openweathermap weather conditions multiple states for rain

Hi,

I’d like to create a rule when the 3 hours weather forecast changes to state rain, that the blind will close automatically.

I just found out, that for rain openweathermap uses a lot of different state types (e.g. like low rain, heavy rain etc.) I just want to activate the rule as soon as the word “rain” has been found in the state update.

Is it possible to configure multiple states? can I do this with a semicolon at the state? Or do I have to use multiple “But only if” conditions? what happens if I add a 2nd one, are the 2 conditions then combined with “OR” or “AND” operators?

here’s the code i currently use:

configuration: {}
triggers:

  • id: “1”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    type: core.ItemStateUpdateTrigger
    conditions:
  • inputs: {}
    id: “4”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Regen
    operator: =
    type: core.ItemStateCondition
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: ON
    itemName: Balkon_aus_Somfy_Action_Group_Trigger
    type: core.ItemCommandAction
  • inputs: {}
    id: “5”
    configuration:
    itemName: Terasseaus_SomfyActionGroupTrigger
    command: ON
    type: core.ItemCommandAction

many thanks for your help
chris

You can configure multiple triggers with specific states as one simple solution. All trigger are OR combinations so you can have: if this item changes to “light rain” OR if this item changes to “heavy rain”, but each of those would be a separate trigger.

You can also use a condition, but conditions are AND combinations, so you would have to use a script action on the condition that reads the item state and checks for the string rain in the state. This is a simple 1 or 2 lines in any of the script languages (and can even be done fairly easily in blockly if you prefer the low code option).

ok thank you for this information. I did configure for each state a trigger rule.currently the state is “mäßiger Regen”. But the rule is not working.

What I’m doing wrong?

Here is the code:

configuration: {}
triggers:

  • id: “1”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Regen
    type: core.ItemStateUpdateTrigger
  • id: “3”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Regenschauer
    type: core.ItemStateUpdateTrigger
  • id: “4”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Gewitter
    type: core.ItemStateUpdateTrigger
  • id: “6”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Gewitter mit leichtem Regen
    type: core.ItemStateUpdateTrigger
  • id: “7”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Gewitter mit Regen
    type: core.ItemStateUpdateTrigger
  • id: “8”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Gewitter mit starken Regen
    type: core.ItemStateUpdateTrigger
  • id: “9”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Leichtes Gewitter
    type: core.ItemStateUpdateTrigger
  • id: “10”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: starkes Gewitter
    type: core.ItemStateUpdateTrigger
  • id: “11”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: phasenweises Gewitter
    type: core.ItemStateUpdateTrigger
  • id: “12”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Gewitter mit leichten Nieselregen
    type: core.ItemStateUpdateTrigger
  • id: “13”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Leichtes Gewitter
    type: core.ItemStateUpdateTrigger
  • id: “14”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Nieselregen
    type: core.ItemStateUpdateTrigger
  • id: “15”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: starkes Nieselregen
    type: core.ItemStateUpdateTrigger
  • id: “16”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Leichtes Nieselregen/ Regen
    type: core.ItemStateUpdateTrigger
  • id: “17”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Nieselregen/ Regen
    type: core.ItemStateUpdateTrigger
  • id: “18”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: starkes Nieselregen/ Regen
    type: core.ItemStateUpdateTrigger
  • id: “19”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Regenschauer und Nebel
    type: core.ItemStateUpdateTrigger
  • id: “20”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Starker Regenschauer und Nebel
    type: core.ItemStateUpdateTrigger
  • id: “21”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Regenschauer und Nieselregen
    type: core.ItemStateUpdateTrigger
  • id: “22”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: leichter Regen
    type: core.ItemStateUpdateTrigger
  • id: “23”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: mäßiger Regen
    type: core.ItemStateUpdateTrigger
  • id: “24”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: starker Regen
    type: core.ItemStateUpdateTrigger
  • id: “25”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: sehr starker Regen
    type: core.ItemStateUpdateTrigger
  • id: “26”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: extremer Regen
    type: core.ItemStateUpdateTrigger
  • id: “27”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: gefrierender Regen
    type: core.ItemStateUpdateTrigger
  • id: “28”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Leichter Regenschauer/ Regen
    type: core.ItemStateUpdateTrigger
  • id: “29”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: Starker Regenschauer/ Regen
    type: core.ItemStateUpdateTrigger
  • id: “30”
    configuration:
    itemName: Lokales_Wetter_und_Wettervorhersage_Vorhergesagte_Wetterlage
    state: phasenweises Regenschauer/ Regen
    type: core.ItemStateUpdateTrigger
    conditions: []
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: ON
    itemName: Balkon_aus_Somfy_Action_Group_Trigger
    type: core.ItemCommandAction
  • inputs: {}
    id: “5”
    configuration:
    itemName: Terasseaus_SomfyActionGroupTrigger
    command: ON
    type: core.ItemCommandAction

Just a hint: it’s much easier for people to read code in posts if you use “code fences” to help format it. You can either do it by using the image button in the bar above the text area or just do it manually:

```
code goes here
```

I don’t know all the details of your weather setup, but you might get better luck using the Item “changed” trigger instead of the Item “updated” trigger.
image

Ok, wow, when you said there were a lot, you meant it…

There’s no reason you shouldn’t be able to get this to work the way you’re going, but with that many different options, moving the logic of testing the state to a script action is, as I said above, also a valid plan.

Again, this can be done in a blockly script relatively easily. You just need to make a list variable of the different state values:
image
(you can add more values to the list by clicking on the blue gear icon and dragging more item blocks into the list block structure).

Then you just do a simple test to see if the new state that triggered the rule is one of the strings in the list:

Inside the do block you can add as many send command blocks as you like to close your blinds or anything else you might also want to trigger as your automations grow more detailed.

If I would use changed instead of was update I need to no from which state the state change have been update and this is not possible to know.

I will look if I can get a better result with blockly. thank you

No, both the changed TO and changed FROM parameters are optional. So you can just set the changed TO without having to worry about what the previous state was the same way you have with updated.

In this case changed is probably the better option anyway because that doesn’t depend on whether the item is getting updated or receiving a command. The event will trigger no matter what causes the value to change but will only trigger if the value does change.

For example if your forecast gets polled every 15 minutes, and updates the rain item to one of the rain values, which causes that item to change from a non-rain value, that will trigger an updated event and then trigger a changed event. If the next poll 15 minutes later sends an update to the rain item which is the same, you will get an other updated event (when you don’t really need to run the rule because it just ran last time) but you will not get a changed event (because the item state is already the same as the updated value).

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.