Rule configuration netatmo GustStrenght

Hello,
I’m trying to configure a rule for the Gust Strength of my netatmo module, but the condition isn’t working, why?

rule "Allarme tende"
    when
        Item Anemometro_GustStrength changed or
        Item Flaminia_CO2 changed
    then
if(Flaminia_CO2.state > 10){
                        logInfo("casa.rules", "QUALCOSA E' CAMBIATO" + Anemometro_GustStrength.type)
                } else {
                        logInfo("casa.rules", "ECCO: " + Anemometro_GustStrength.state)
                }

end

I put 10 because generally in this case CO2 or Gust Strengh is always going in the else condition but it’s in the other condition. Why?

If Flaminia_CO2 is of Type Number, please try

then
    if(!(Flaminia_CO2.state instanceof Number))   //avoid error in log if Flaminia_CO2 is not initialized yet
        return;
    if((Flaminia_CO2.state as Number) > 10) {
        ...

Solved:

rule "Allarme tende"
    when
        Item Anemometro_GustStrength changed or
        Item Pluviometro_Rain1h changed
    then
        var Number wind = Anemometro_GustStrength.state as Number
        var Number rain = Pluviometro_Rain1h.state as Number

        if(rain.floatValue() > 0.0 || wind.intValue() > 15){
                logInfo("casa.rules", "Allarme tende vento " + wind + " pioggia " + rain.floatValue())
                if(TendaSinistra_BlindsControl.state > 1 || TendaDestra_BlindsControl.state > 1){
                        logInfo("casa.rules", "Tende erano abbassate, eseguo il comando di UP")
                        gShutterTende.sendCommand(UP)
                }
        }
end

1 Like

Thanks that help me, same problem solutions. :slight_smile: