Aktionen bei bestimmten Wetterbedingungen

ist eingefügt, aber auch da bleibt der button unangetastet.

--[[
%% properties
3 ConditionCode
%% globals
--]]

local weather_code = fibaro:getValue(3, 'ConditionCode')
local previous_weather_code = fibaro:getValue(3, 'PreviousConditionCode')
local AM_Status = fibaro:getGlobal('AM_Status') 
local id = 94

if (weather_code == previous_weather_code) then
    --fibaro:debug('weather_code hat sich nicht geändert.')
else
  fibaro:debug('Wettervorhersage v0.01 gestartet.')
  fibaro:debug('ConditionCode: ' ..weather_code.. ' / Prüfe Wetterbedingung')
  if (weather_code == '6' or weather_code == '9' or weather_code == '11' or weather_code == '12' or weather_code == '40') then
    fibaro:debug('Wettervorhersage: Regen')
  elseif (weather_code == '31' or weather_code == '32' or weather_code == '33' or weather_code == '34') then
    fibaro:debug('Wettervorhersage: klar')
  elseif (weather_code == '17' or weather_code == '29' or weather_code == '30' or weather_code == '44') then
    fibaro:debug('Wettervorhersage: leicht bewölkt')
  elseif (weather_code == '26' or weather_code == '35') then
    fibaro:debug('Wettervorhersage: bewölkt')
  elseif (weather_code == '27' or weather_code == '28') then
    fibaro:debug('Wettervorhersage: stark bewölkt')
  elseif (weather_code == '19' or weather_code == '20' or weather_code == '21' or weather_code == '22') then
    fibaro:debug('Wettervorhersage: Nebel')
  elseif (weather_code == '3' or weather_code == '4' or weather_code == '37' or weather_code == '38' or weather_code == '39' or weather_code == '45' or weather_code == '46') then
    fibaro:debug('ACHTUNG: Gewitter')
  elseif (weather_code == '5' or weather_code == '7' or weather_code == '14' or weather_code == '19' or weather_code == '42' or weather_code == '46') then
    fibaro:debug('Wettervorhersage: Möglicherweise Schnee/Schneeregen')
  elseif (weather_code == '13' or weather_code == '15' or weather_code == '16' or weather_code == '41' or weather_code == '42' or weather_code == '43') then
    fibaro:debug('Wettervorhersage: Schnee')
  elseif (weather_code == '17' or weather_code == '35') then
    fibaro:debug('ACHTUNG: Hagel')
  elseif (weather_code == '8' or weather_code == '10') then
    fibaro:debug('Wettervorhersage: Überfrierende Nässe')
  elseif (weather_code == '0' or weather_code == '1' or weather_code == '2' or weather_code == '23' or weather_code == '23') then
    fibaro:debug('Wettervorhersage: Stürmisch')
  elseif (weather_code == '25') then
    fibaro:debug('Wettervorhersage: Kalt (Was immer das heißt...)')
  elseif (weather_code == '36') then
    fibaro:debug('Wettervorhersage: Heiß (Was immer das heißt...)')
  elseif (weather_code == '3200') then
    fibaro:debug('Code 3200. Nicht bekannt.')

  end    

  	if 
      (weather_code == '6' or weather_code == '9' or weather_code == '11' or weather_code == '12' or weather_code == '40' or 
       weather_code == '19' or weather_code == '20' or weather_code == '21' or weather_code == '22' or
       weather_code == '3' or weather_code == '4' or weather_code == '37' or weather_code == '38' or weather_code == '39' or weather_code == '45' or weather_code == '46' or
       weather_code == '5' or weather_code == '7' or weather_code == '14' or weather_code == '19' or weather_code == '42' or weather_code == '46' or
       weather_code == '13' or weather_code == '15' or weather_code == '16' or weather_code == '41' or weather_code == '42' or weather_code == '43' or
       weather_code == '17' or weather_code == '35' or
       weather_code == '8' or weather_code == '10' or
       weather_code == '0' or weather_code == '1' or weather_code == '2' or weather_code == '23' or weather_code == '23' or 
       weather_code == '3200')
    and
       AM_Status == 2 

    
    
    then
       fibaro:call(94, "pressButton", "4");
       fibaro:debug('Automower Modus: HOME gesetzt')

  
    elseif 
       (weather_code == '31' or weather_code == '32' or weather_code == '33' or weather_code == '34' or
        weather_code == '17' or weather_code == '29' or weather_code == '30' or weather_code == '44' or
        weather_code == '26' or weather_code == '35' or
        weather_code == '36') 
    and
        AM_Status == 0 or AM_Status == 1 or AM_Status == 3
    
    then
       fibaro:call(94, "pressButton", "2");
       fibaro:debug('Automower Modus: AUTO gesetzt')
    

    else
       fibaro:debug('weather_code : '..weather_code)
       fibaro:debug('AM_Status : '..AM_Status)
  
    end
  end
 

die id ist die richtige, da die status-refresh-scene auch mit dieser id minütlich läuft

kann ich noch irgendwas ändern eurer Meinung nach?

Wie hast du die Nr des Buttons ermittelt?
Umgewandelte Block-Szene?

nein einfach nur abgezählt. der statusbutton bei der refreshscene ist der 6te…
buttons im vd

feierabend
auto stop
home manuell
status

etwa nicht richtig?

aber durchs umwandeln der blockscene ist es genauso

Würde schon mal der Debug für dein IF bzw elseif ausgegeben?
Sonst liegt es nicht am Button, sondern den Nichtzutreffenden Bedingungen

Würde schon mal der Debug für dein IF bzw elseif ausgegeben?
Sonst liegt es nicht am Button, sondern den Nichtzutreffenden Bedingungen

Nutz mal statt getglobal getglobalvalue

nein wurde nix ausgegeben.
…getglobalvalue geändert

[DEBUG] 00:33:11: Wettervorhersage v0.01 gestartet.
[DEBUG] 00:33:11: ConditionCode: 31 / Prüfe Wetterbedingung
[DEBUG] 00:33:11: Wettervorhersage: klar
[DEBUG] 00:33:11: weather_code : 31
[DEBUG] 00:33:11: AM_Status : 0

mein power schläft = status 0
Wettermodell jetzt gerade 31

also müßte button 2 gedrückt werden, tut es aber nicht. oh man wird das ne schlaflose nacht mit Kopfzerbrechen

wettercode sollte es heißen

Hallo hoggle, hallo boomx

also der AM_Status wird richtig gesetzt, das hab ich nun nochmal kontrolliert. der Wettercode wird auch im Debug ausgegeben …
mir scheint es aber das die Zeilen 66,67 und 79,80 einfach übersprungen werden, da auch in diesem debug nix angezeigt wird. was denkt ihr ?

gruss xn8

ja.
Deine If und Deine elseif-Bedingungen treffen nicht zu.
Daher geht er da nicht rein.
Er macht nur das else.
Deswegen die Abfrage des AM_Status in der else-Abfrage.
Ich kann es mir zwar nicht vorstellen aber versuche mal in Zeile 9:


local AM_Status = tonumber(fibaro:getGlobalValue('AM_Status'))

Kann auch sein, dass er die "or"s und Dein “and” nicht so umsetzt.
An den Button dürfte es ja nicht hängen, weil er auch den Debug nicht angibt.

Mach mal in Zeile 51 am Anfang eine “(” und am Ende von 62 eine “)”.
Dito Zeile 71 und 76.

hallo hoggle

danke für deine Geduld . hab Zeile 9 geändert, aber jetzt kommt im debug folgendes

[DEBUG] 23:17:00: line 9: attempt to call global ‘tonumer’ (a nil value)

die klammern hab ich auch so gesetzt wie du geschrieben hast

gruss xn8

ahhh, sorry. mein Fehler
Sollte heißen “tonumber”

war nicht dein fehler, sondern von copy&paste :slight_smile:
aber jetzt passiert garnix mehr, die scene startet nicht mehr

Welche Fehlermeldung kommt im Debug? Der Trigger von der Szene hat sich ja nicht geändert…

soooo, hab alles noch mal rückgängig gemacht und nochmal Zeile 9 mit “tonumber” geändert. und siehe da jetzt gehts :-)))
folgendes zeigt das debug

[DEBUG] 23:55:02: Wettervorhersage v0.01 gestartet.
[DEBUG] 23:55:02: ConditionCode: 3200 / Prüfe Wetterbedingung
[DEBUG] 23:55:02: Code 3200. Nicht bekannt.
[DEBUG] 23:55:02: Automower Modus: HOME gesetzt

und er macht es tatsächlich

man war das ne Geburt , aber dank eurer hilfe scheint es zu funktionieren .

danke euch beiden hoggle und boomx

Kein Ding :slight_smile:

Schön zu hören.

Hallo Daniel,

kannst Du mir bitte behilflich sein bei meinem Problem? Ich benutze das oben aufgeführte LUA Skript, als Wetterstation benutze ich das VD aus dem Forum verbunden mit meinem Netatmo. Nun wollte ich das Skript für die Regenwarnung wieder zum laufen bringen. Aus irgendwelchen Gründen wird dieses aber nicht angesprochen wenn die Wetterbedingung “regen” anzeigt/ vorhersagt. Sobald ich das Skript manuell starte, klapt alles. Ich erhalte keine Meldung im debug!

Muss ich an dem Regenwarn Skript etwas ändern?

Anbei das Skript “Regenwarnung”

--[[
%% properties
3 WeatherConditionConverted
%% globals
--]]

local phoneID = {fibaro:getGlobal("var_mareen_handy"), fibaro:getGlobal("var_daniel_handy")} -- Handy-IDs
local maxID = 1000

Debug = function ( color, message )
	fibaro:debug(string.format('< %s style="color:%s;">%s', "span", color, message, "span"))
end

local startSource = fibaro:getSourceTrigger();

if (fibaro:getValue(3, "WeatherConditionConverted") == "rain" or startSource['type'] == 'other') then
--if (fibaro:getValue(3, "WeatherConditionConverted") == "9" or startSource['type'] == 'other') then
  	if (startSource['type'] == 'other') then
		Debug('white', "SZENE MANUELL GESTARTET")
	else
	Debug('green', "SZENE DURCH REGEN-VORHERSAGE GESTARTET")
	end
	Debug('red', "ACHTUNG! Es könnte regnen")
	Debug('white', "Prüfe offene Fenster")
	
	for id = 1, maxID do
		local deviceType = fibaro:getType(id)
		if (deviceType == 'com.fibaro.windowSensor' or deviceType == 'com.fibaro.doorSensor') then
			if (tonumber(fibaro:getValue(id, 'value')) == 1) then
				local name = fibaro:getName(id)
				local room = fibaro:getRoomNameByDeviceID(id)
				Debug('red', "ACHTUNG! Regen vorhergesagt. " ..name.. " im Raum " ..room.. " ist offen!")
		
				for k=1, maxID do
					if phoneID[k] ~= nil then
					fibaro:call(phoneID[k], 'sendPush', 'ACHTUNG: Regen vorhergesagt! ' ..name.. ' im Raum ' ..room.. ' ist offen!')
					end
				end
			end
		end
	end
end

Die vorherigen Scripte hier gehen alle von “ConditionCode” aus, hast Du das mal alternativ geprüft?


--[[
%% properties
3 ConditionCode
%% globals
--]]
 
local weather_code = fibaro:getValue(3, 'ConditionCode')

Da Du Netatmo nutzt kannst Du auch direkt über die globale Variable “rain_hour” (sofern Du das Script von boomx nutzt) gehen.