Nee, dit script is helaas niet voor Belgiƫ te gebruiken.
Deze sectie stelt je in staat om alle bijdragen van dit lid te bekijken. Je kunt alleen de bijdragen zien waar je op dit moment toegang toe hebt.
Citaat van: TheVork op 01 juni 2020, 14:24:48
Hallo Joost,
Ik loop tegen een probleempje aan, en het zal zeker aan mij liggen, maar tocch, hoe los ik dit op?
Alles doorgelopen zoals je schrijft wat te doen, maar als ik de cron test, krijg ik dit:
...
Snap jij wat er gebeurt? Of iemand anders?
Citaat van: dude op 27 mei 2020, 19:49:42
Kun je aangegeven met een voorbeeld hoe ik dit script daadwerkelijk koppel aan devices in domotics ?
bijv Device = 'temperature' en de combinatie function (device)
Hetzelfde geld voor sunscreen
Citaat van: GerritH op 13 mei 2020, 21:30:04
In de regels 154 t/m 169 gebruik je als index 44, moet dat niet de variabele $weerstation zijn?
Citaat van: GerritH op 13 mei 2020, 21:30:04
Verder de vraag wat er gebeurt als je een weerstation gebruikt dat een bepaalde waarde (vb. visibility) niet levert, loopt het script dan vast?
<?php
/*
WEERSTATIONS:
Amsterdam = 36 Groningen = 13 Oost-Groninigen = 31 Vlissingen = 44
Arnhem = 2 Hoek van Holland = 17 Oost-Overijssel = 12 Voorschoten = 46
Berkhout = 3 Hoogeveen = 18 Rotterdam = 33 Wadden = 19
Den Helder = 6 Leeuwarden = 26 Utrecht = 5 Weert = 8
Eindhoven = 7 Lelystad = 27 Terneuzen = 47 West-Friesland = 38
Gilze Rijen = 10 Maastricht = 29 Twente = 41 West-Utrecht = 28
Goes = 11 Noord-Groninigen = 24 Uden = 45 Woensdrecht = 50
Gorinchem = 16 Noordoostpolder = 30 Venlo = 1 Zwolle = 15
Note: Sommige weerstations bevatten niet alle benodigde gegevens, waardoor er fouten kunnen ontstaan in het script. Om te testen kun je weerstation 45 gebruiken.
REGIO'S VOOR ALERTS:
007=Groningen 011=Noord-Holland 015=Utrecht
008=Flevoland 012=Limburg 016=Overijssel
009=Zuid-Holland 013=Noord-Brabant 017=Friesland
010=Zeeland 014=Gelderland 018=Drenthe
801=Vlissingen 805=Rottum
802=Hoek van Holland 806=Waddenzee
803=IJmuiden 807=IJsselmeer
804=Texel
*/
// SETTINGS
$webserver_ip = '192.168.2.63'; // Alleen IP
$domoticz_url='http://192.168.2.63:8080/'; //URL met poortnummer
$weerstation = 45; // Zie weerstations
$alerts_country = 'NL'; // Niet wijzigen
$alerts_region = '013'; // Zie 'Regio's voor alerts'
// IDX van devices
// Maak in Domoticz de juiste type virtuele sensoren aan en zet hieronder het IDX-nummer neer. De namen van de devices kun je naar eigen keuze kiezen.
$idx1 = '25'; // Alerts vandaag - Alert sensor
$idx2 = '26'; // Alerts morgen - Alert sensor
$idx3 = '8'; // Temperatuur buiten - Temperature sensor
$idx4 = '9'; // Temperatuur gevoel - Temperature sensor
$idx5 = '20'; // Temperatuur grond - Temperature sensor
$idx6 = '12'; // Zicht - Visibility sensor
$idx7 = '24'; // Zonkracht - Solar Radiation sensor
$idx8 = '21'; // Weer nu - Text sensor
$idx9 = '18'; // Weer uitgebreid - Text sensor
$idx10 = '22'; // Verwachting 1-5 dagen - Text sensor
$idx11 = '23'; // Verwachting 6-10 dagen - Text sensor
$idx12 = '71'; // Verwachting week - Text sensor
$idx13 = '19'; // Komende 24 uur - Text sensor
$idx14 = '13'; // Wind - Wind sensor
$idx15 = '11'; // Luchtdruk - Barometer sensor
$idx16 = '87'; // Regen (afgelopen 24 uur) - Rain sensor
$idx17 = '88'; // Regen (afgelopen uur) - Rain sensor
$idx18 = '10'; // Luchtvochtigheid - Humidity sensor
// *** HIERONDER NIETS WIJZIGEN!!!! *** //
$url_1 = 'https://data.buienradar.nl/2.0/feed/json';
$url_2 = 'http://'.$webserver_ip.'/meteo-alarm-weather-warnings-1.1/src/warnings.php?country='.$alerts_country.'®ion='.$alerts_region.'&time_zone=Europe/Amsterdam';
// Functions
function Weather($idx,$temp) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$temp),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Barometer($idx,$bar,$bar_for) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$bar.';'.$bar_for),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Wind($idx,$winddirectiondegrees_now,$winddirection_now,$windspeed_now,$windgusts_now,$temp_now,$tempfeel_now) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$winddirectiondegrees_now.';'.$winddirection_now.';'.$windspeed_now.';'.$windgusts_now.';'.$temp_now.';'.$tempfeel_now),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Humidity($idx,$hum,$hum_stat) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue='.$hum.'&svalue='.$hum_stat),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Text($idx,$text) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$text),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Notification($subject,$thebody) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=sendnotification&subject='.$subject.'&body='.$thebody),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Rain($idx,$rainrate,$raincounter) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$rainrate.';'.$raincounter),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function Alert($idx,$level,$text) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue='.$level.'&svalue='.$text),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
function TempHum($idx,$temp,$hum,$hum_stat) {
global $domoticz_url;
$reply=json_decode(file_get_contents($domoticz_url.'json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue=0&svalue='.$temp.';'.$hum.';'.$hum_stat),true);
if($reply['status']=='OK') $reply='OK';else $reply='ERROR';
return $reply;
}
// Ophalen gegevens Buienradar
$contents = file_get_contents(($url_1),true);
$clima=json_decode($contents);
foreach ($clima->actual->stationmeasurements as $item) {
if ($item->stationid == $weerstation) {
$airpressure_now=$item->airpressure;
$humidity_now=$item->humidity;
$temp_now=$item->temperature;
$tempground_now=$item->groundtemperature;
$tempfeel_now=$item->feeltemperature;
$precipitation_now=$item->precipitation;
$rainFallLast24Hour=$item->rainFallLast24Hour;
$rainFallLastHour=$item->rainFallLastHour;
$sunpower_now=$item->sunpower;
$visibility_now=$item->visibility/1000;
$weather_now=$item->weatherdescription;
$winddirection_now=$item->winddirection;
$windgusts_now=$item->windgusts*10;
$windspeed_now=$item->windspeed*10;
$windspeedBft_now=$item->windspeedBft;
$winddirectiondegrees_now=$item->winddirectiondegrees;
}
}
$weatherreport_summary=$clima->forecast->weatherreport->summary;
$weatherreport_title=$clima->forecast->weatherreport->title;
$weatherreport_text=$clima->forecast->weatherreport->text;
$weatherreport_shortterm=$clima->forecast->shortterm->forecast;
$weatherreport_shortterm_startdate=substr($clima->forecast->shortterm->startdate, 0, 10);
$weatherreport_shortterm_enddate=substr($clima->forecast->shortterm->enddate, 0, 10);
$weatherreport_longterm=$clima->forecast->longterm->forecast;
$weatherreport_longterm_startdate=substr($clima->forecast->longterm->startdate, 0, 10);
$weatherreport_longterm_enddate=substr($clima->forecast->longterm->enddate, 0, 10);
$temp_min_day1=$clima->forecast->fivedayforecast[0]->mintemperatureMin;
$temp_min_day2=$clima->forecast->fivedayforecast[1]->mintemperatureMin;
$temp_min_day3=$clima->forecast->fivedayforecast[2]->mintemperatureMin;
$temp_min_day4=$clima->forecast->fivedayforecast[3]->mintemperatureMin;
$temp_min_day5=$clima->forecast->fivedayforecast[4]->mintemperatureMin;
$temp_max_day1=$clima->forecast->fivedayforecast[0]->maxtemperatureMax;
$temp_max_day2=$clima->forecast->fivedayforecast[1]->maxtemperatureMax;
$temp_max_day3=$clima->forecast->fivedayforecast[2]->maxtemperatureMax;
$temp_max_day4=$clima->forecast->fivedayforecast[3]->maxtemperatureMax;
$temp_max_day5=$clima->forecast->fivedayforecast[4]->maxtemperatureMax;
$sunchance_day1=$clima->forecast->fivedayforecast[0]->sunChance;
$sunchance_day2=$clima->forecast->fivedayforecast[1]->sunChance;
$sunchance_day3=$clima->forecast->fivedayforecast[2]->sunChance;
$sunchance_day4=$clima->forecast->fivedayforecast[3]->sunChance;
$sunchance_day5=$clima->forecast->fivedayforecast[4]->sunChance;
$rainchance_day1=$clima->forecast->fivedayforecast[0]->rainChance;
$rainchance_day2=$clima->forecast->fivedayforecast[1]->rainChance;
$rainchance_day3=$clima->forecast->fivedayforecast[2]->rainChance;
$rainchance_day4=$clima->forecast->fivedayforecast[3]->rainChance;
$rainchance_day5=$clima->forecast->fivedayforecast[4]->rainChance;
$rainmin_day1=$clima->forecast->fivedayforecast[0]->mmRainMin;
$rainmin_day2=$clima->forecast->fivedayforecast[1]->mmRainMin;
$rainmin_day3=$clima->forecast->fivedayforecast[2]->mmRainMin;
$rainmin_day4=$clima->forecast->fivedayforecast[3]->mmRainMin;
$rainmin_day5=$clima->forecast->fivedayforecast[4]->mmRainMin;
$rainmax_day1=$clima->forecast->fivedayforecast[0]->mmRainMax;
$rainmax_day2=$clima->forecast->fivedayforecast[1]->mmRainMax;
$rainmax_day3=$clima->forecast->fivedayforecast[2]->mmRainMax;
$rainmax_day4=$clima->forecast->fivedayforecast[3]->mmRainMax;
$rainmax_day5=$clima->forecast->fivedayforecast[4]->mmRainMax;
$winddirection_day1=strtoupper($clima->forecast->fivedayforecast[0]->windDirection);
$winddirection_day2=strtoupper($clima->forecast->fivedayforecast[1]->windDirection);
$winddirection_day3=strtoupper($clima->forecast->fivedayforecast[2]->windDirection);
$winddirection_day4=strtoupper($clima->forecast->fivedayforecast[3]->windDirection);
$winddirection_day5=strtoupper($clima->forecast->fivedayforecast[4]->windDirection);
$wind_day1=$clima->forecast->fivedayforecast[0]->wind;
$wind_day2=$clima->forecast->fivedayforecast[1]->wind;
$wind_day3=$clima->forecast->fivedayforecast[2]->wind;
$wind_day4=$clima->forecast->fivedayforecast[3]->wind;
$wind_day5=$clima->forecast->fivedayforecast[4]->wind;
$forecast_day1=date('D',strtotime($clima->forecast->fivedayforecast[0]->day));
$forecast_day1 = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), array('Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'), $forecast_day1);
$forecast_day2=date('D',strtotime($clima->forecast->fivedayforecast[1]->day));
$forecast_day2 = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), array('Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'), $forecast_day2);
$forecast_day3=date('D',strtotime($clima->forecast->fivedayforecast[2]->day));
$forecast_day3 = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), array('Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'), $forecast_day3);
$forecast_day4=date('D',strtotime($clima->forecast->fivedayforecast[3]->day));
$forecast_day4 = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), array('Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'), $forecast_day4);
$forecast_day5=date('D',strtotime($clima->forecast->fivedayforecast[4]->day));
$forecast_day5 = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), array('Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'), $forecast_day5);
$weatherdescription_tomorrow=$clima->forecast->fivedayforecast[0]->weatherdescription;
//Barometer
//if ($airpressure_now = nil) {$bar_for = 5;} // 5 = unknow
if ($airpressure_now < 966) {$bar_for = 4;} // 4 = thunderstorm
if (($airpressure_now > 966) && ($airpressure_now < 993)) {$bar_for = 6;} // 6 = cloudy/rain
if (($airpressure_now > 993) && ($airpressure_now < 1007)) {$bar_for = 2;} // 2 = cloudy
if (($airpressure_now > 1007) && ($airpressure_now < 1013)) {$bar_for = 3;} // 3 = unstable
if (($airpressure_now > 1013) && ($airpressure_now < 1033)) {$bar_for = 0;} // 0 = stable
if (($airpressure_now > 1033) && ($airpressure_now < 1050)) {$bar_for = 1;} // 1= sunny
// Windrichting van Engels naar Nederlands
$winddirection_now = str_replace(array('N', 'O', 'Z', 'W'), array('N', 'E', 'S', 'W'), $winddirection_now);
// Weer komende 24 uur
$weather_tomorrow = $weatherdescription_tomorrow.'<br><br>Komende nacht daalt de temperatuur naar '.$temp_min_day1.' °C. Morgen overdag wordt morgen maximaal '.$temp_max_day1. '°C. Er is morgen '.$sunchance_day1.'% kans op zon en '.$rainchance_day1.'% kans op neerslag ('.$rainmin_day1.'-'.$rainmax_day1.' mm). De wind komt uit het '.$winddirection_day1.' en zal kracht '.$wind_day1.' Bft hebben.<br><br>';
// Vervangen 'vreemde' tekens
$weather_now = str_replace(array(">", "<", "\"", "&", "%", " "), array(">", "<", """, "&", "%25", "%20"), $weather_now);
$weatherreport_title = str_replace(array(">", "<", "\"", "&", "%", " "), array(">", "<", """, "&", "%25", "%20"), $weatherreport_title);
$weatherreport_shortterm = str_replace(array(">", "<", "\"", "&", "%", " "), array(">", "<", """, "&", "%25", "%20"), $weatherreport_shortterm);
$weatherreport_longterm = str_replace(array(">", "<", "\"", "&", "%", " "), array(">", "<", """, "&", "%25", "%20"), $weatherreport_longterm);
$weatherreport_text = str_replace(array(" ", " "), array("%20", "%20"), $weatherreport_text);
$weather_tomorrow = str_replace(array("\"", "&", "%", " "), array(""", "&", "%25", "%20"), $weather_tomorrow);
// Week komende 5 dagen
$dag1=$forecast_day1.':%20'.$temp_min_day1.'/'.$temp_max_day1.'°C,%20'.$winddirection_day1.$wind_day1.',%20☀️'.$sunchance_day1.'%25,%20️'.$rainchance_day1.'%25%20('.$rainmin_day1.'-'.$rainmax_day1.'%20mm)<br>';
$dag2=$forecast_day2.':%20'.$temp_min_day2.'/'.$temp_max_day2.'°C,%20'.$winddirection_day2.$wind_day2.',%20☀️'.$sunchance_day2.'%25,%20️'.$rainchance_day2.'%25%20('.$rainmin_day2.'-'.$rainmax_day2.'%20mm)<br>';
$dag3=$forecast_day3.':%20'.$temp_min_day3.'/'.$temp_max_day3.'°C,%20'.$winddirection_day3.$wind_day3.',%20☀️'.$sunchance_day3.'%25,%20️'.$rainchance_day3.'%25%20('.$rainmin_day3.'-'.$rainmax_day3.'%20mm)<br>';
$dag4=$forecast_day4.':%20'.$temp_min_day4.'/'.$temp_max_day4.'°C,%20'.$winddirection_day4.$wind_day4.',%20☀️'.$sunchance_day4.'%25,%20️'.$rainchance_day4.'%25%20('.$rainmin_day4.'-'.$rainmax_day4.'%20mm)<br>';
$dag5=$forecast_day5.':%20'.$temp_min_day5.'/'.$temp_max_day5.'°C,%20'.$winddirection_day5.$wind_day5.',%20☀️'.$sunchance_day5.'%25,%20️'.$rainchance_day5.'%25%20('.$rainmin_day5.'-'.$rainmax_day5.'%20mm)';
$weer=$dag1.$dag2.$dag3.$dag4.$dag5;
$weer='<font%20face="courier%20new">'.$weer.'</font>';
// WEERALERTS
// Ophalen gegevens
$contents2 = file_get_contents(($url_2),true);
$clima2=json_decode($contents2);
// Alert vandaag
$alerttype_today1=$clima2->warnings->regions[0]->today[0]->awareness->awareness_type->type;
$alertlevel_today1=$clima2->warnings->regions[0]->today[0]->awareness->awareness_level->level;
$alertcolour_today1=$clima2->warnings->regions[0]->today[0]->awareness->awareness_level->colour; // 0=White/Unknown, 1=Green/No Warnings, 2=Yellow, 3=Amber, 4=Red
$alertcolour_today1=str_replace(array('Yellow', 'Amber', 'Red', 'Green', 'White'), array('GEEL', 'ORANJE!', 'ROOD!!!', 'groen', 'onbekend'), $alertcolour_today1);
//if ($alertlevel_today1 != 1) {
$alertstarttime_today1 = str_replace('CEST', '', $clima2->warnings->regions[0]->today[0]->period->starttime);
$alertstart_today1 = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), array('maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'), $alertstarttime_today1);
$alertendtime_today1 =str_replace('CEST', '', $clima2->warnings->regions[0]->today[0]->period->endtime);
$alertend_today1 = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), array('maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'), $alertendtime_today1);
$alerttext_today1 = str_replace('nederlands: ', '', $clima2->warnings->regions[0]->today[0]->description);
//}
// Alert morgen
$alerttype_tomorrow1=$clima2->warnings->regions[0]->tomorrow[0]->awareness->awareness_type->type;
$alertlevel_tomorrow1=$clima2->warnings->regions[0]->tomorrow[0]->awareness->awareness_level->level;
$alertcolour_tomorrow1=$clima2->warnings->regions[0]->tomorrow[0]->awareness->awareness_level->colour; // 0=White/Unknown, 1=Green/No Warnings, 2=Yellow, 3=Amber, 4=Red
$alertcolour_tomorrow1=str_replace(array('Yellow', 'Amber', 'Red', 'Green', 'White'), array('GEEL', 'ORANJE!', 'ROOD!!!', 'groen', 'onbekend'), $alertcolour_tomorrow1);
//if ($alertlevel_tomorrow1 != 1) {
$alertstarttime_tomorrow1 = str_replace('CEST', '', $clima2->warnings->regions[0]->tomorrow[0]->period->starttime);
$alertstart_tomorrow1 = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), array('maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'), $alertstarttime_tomorrow1);
$alertendtime_tomorrow1 =str_replace('CEST', '', $clima2->warnings->regions[0]->tomorrow[0]->period->endtime);
$alertend_tomorrow1 = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), array('maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'), $alertendtime_tomorrow1);
$alerttext_tomorrow1 = str_replace('nederlands: ', '', $clima2->warnings->regions[0]->tomorrow[0]->description);
//}
if ($alertlevel_today1 !=1) {
$alerttext_today1 = explode('english:', $alerttext_today1);
// echo $alerttext_today1[0]; // engels
// echo $alerttext_today1[1]; // nederlands
}
if ($alertlevel_tomorrow1 !=1) {
$alerttext_tomorrow1 = explode('english:', $alerttext_tomorrow1);
// echo $alerttext_tomorrow1[0]; // engels
// echo $alerttext_tomorrow1[1]; // nederlands
}
if ($alerttype_today1 == 0) {
$alerttitle_today1 = 'Geen waarschuwingen';
} elseif ($alerttype_today1 == 1) {
$alerttitle_today1 = 'Wind waarschuwing';
} elseif ($alerttype_today1 == 2) {
$alerttitle_today1 = 'Sneeuw/IJzel waarschuwing';
} elseif ($alerttype_today1 == 3) {
$alerttitle_today1 = 'Onweer waarschuwing';
} elseif ($alerttype_today1 == 4) {
$alerttitle_today1 = 'Mist waarschuwing';
} elseif ($alerttype_today1 == 5) {
$alerttitle_today1 = 'Extreem hoge temperatuur waarschuwing';
} elseif ($alerttype_today1 == 6) {
$alerttitle_today1 = 'Extreem lage temperatuur waarschuwing';
} elseif ($alerttype_today1 == 7) {
$alerttitle_today1 = 'Kust waarschuwing';
} elseif ($alerttype_today1 == 8) {
$alerttitle_today1 = 'Bosbrand waarschuwing';
} elseif ($alerttype_today1 == 9) {
$alerttitle_today1 = 'Lawine waarschuwing';
} elseif ($alerttype_today1 == 10) {
$alerttitle_today1 = 'Regen waarschuwing';
} elseif ($alerttype_today1 == 11) {
$alerttitle_today1 = 'Niet beschikbaar';
} elseif ($alerttype_today1 == 12) {
$alerttitle_today1 = 'Overstroming waarschuwing';
} elseif ($alerttype_today1 == 13) {
$alerttitle_today1 = 'Regen/Overstroming waarschuwing';
}
if ($alerttype_tomorrow1 == 0) {
$alerttitle_tomorrow1 = 'Geen waarschuwingen';
} elseif ($alerttype_tomorrow1 == 1) {
$alerttitle_tomorrow1 = 'Wind waarschuwing';
} elseif ($alerttype_tomorrow1 == 2) {
$alerttitle_tomorrow1 = 'Sneeuw/IJzel waarschuwing';
} elseif ($alerttype_tomorrow1 == 3) {
$alerttitle_tomorrow1 = 'Onweer waarschuwing';
} elseif ($alerttype_tomorrow1 == 4) {
$alerttitle_tomorrow1 = 'Mist waarschuwing';
} elseif ($alerttype_tomorrow1 == 5) {
$alerttitle_tomorrow1 = 'Extreem hoge temperatuur waarschuwing';
} elseif ($alerttype_tomorrow1 == 6) {
$alerttitle_tomorrow1 = 'Extreem lage temperatuur waarschuwing';
} elseif ($alerttype_tomorrow1 == 7) {
$alerttitle_tomorrow1 = 'Kust waarschuwing';
} elseif ($alerttype_tomorrow1 == 8) {
$alerttitle_tomorrow1 = 'Bosbrand waarschuwing';
} elseif ($alerttype_tomorrow1 == 9) {
$alerttitle_tomorrow1 = 'Lawine waarschuwing';
} elseif ($alerttype_tomorrow1 == 10) {
$alerttitle_tomorrow1 = 'Regen waarschuwing';
} elseif ($alerttype_tomorrow1 == 11) {
$alerttitle_tomorrow1 = 'Niet beschikbaar';
} elseif ($alerttype_tomorrow1 == 12) {
$alerttitle_tomorrow1 = 'Overstroming waarschuwing';
} elseif ($alerttype_tomorrow1 == 13) {
$alerttitle_tomorrow1 = 'Regen/Overstroming waarschuwing';
}
if ($alertlevel_today1 != 1) {
$alert_today1 = urlencode($alerttitle_today1.PHP_EOL.PHP_EOL.$alertstart_today1.' uur t/m '.$alertend_today1.' uur'.PHP_EOL.PHP_EOL.$alerttext_today1[0].PHP_EOL.PHP_EOL);
} else $alert_today1 = urlencode($alerttitle_today1.PHP_EOL.PHP_EOL.'Er zijn geen waarschuwingen'.PHP_EOL.PHP_EOL.PHP_EOL);
if ($alertlevel_tomorrow1 != 1) {
$alert_tommorow1 = urlencode($alerttitle_tomorrow1.PHP_EOL.PHP_EOL.$alertstart_tomorrow1.' uur t/m '.$alertend_tomorrow1.' uur'.PHP_EOL.PHP_EOL.$alerttext_tomorrow1[0].PHP_EOL.PHP_EOL);
} else $alert_tommorow1 = urlencode($alerttitle_tomorrow1.PHP_EOL.PHP_EOL.'Er zijn geen waarschuwingen'.PHP_EOL.PHP_EOL.PHP_EOL);
// Devices updaten
TempHum($idx3,$temp_now,$humidity_now,0);
Weather($idx4,$tempfeel_now);
Weather($idx5,$tempground_now);
Weather($idx6,$visibility_now);
Weather($idx7,$sunpower_now);
Text($idx8,$weather_now);
Text($idx9,($weatherreport_title. '<br><br>' . $weatherreport_text));
Text($idx10,(date('l%20d%20F', strtotime($weatherreport_shortterm_startdate))). '%20t/m%20' . (date('l%20d%20F', strtotime($weatherreport_shortterm_enddate))). '<br><br>' . $weatherreport_shortterm);
Text($idx11,(date('l%20d%20F', strtotime($weatherreport_longterm_startdate))). '%20t/m%20' . (date('l%20d%20F', strtotime($weatherreport_longterm_enddate))). '<br><br>' . $weatherreport_longterm);
Text($idx12,$weer);
Text($idx13,$weather_tomorrow);
Wind($idx14,$winddirectiondegrees_now,$winddirection_now,$windspeed_now,$windgusts_now,$temp_now,$tempfeel_now);
Barometer($idx15,$airpressure_now,$bar_for);
Rain($idx16,0,$rainFallLastHour); // Todo: nog vervangen door mm/u op dat moment
Rain($idx17,0,$rainFallLastHour); // Todo: nog vervangen door mm/u op dat moment
Humidity($idx18,$humidity_now,0); // Todo: nog vervangen https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's#Humidity
// Notifications versturen
$subject = 'WEER-ALERT!';
if ($alertlevel_today1 != 1) {
$thebody = urlencode('Code '.$alertcolour_today1.PHP_EOL.PHP_EOL.$alerttitle_today1.PHP_EOL.PHP_EOL.$alertstart_today1.' uur t/m '.$alertend_today1.' uur'.PHP_EOL.PHP_EOL.$alerttext_today1[0]);
} else $thebody = urlencode('Code '.$alertcolour_today1.PHP_EOL.PHP_EOL.'Er zijn geen waarschuwingen');
$url_3= $domoticz_url.'json.htm?type=devices&rid='.$idx1;
$contents3 = file_get_contents(($url_3),true);
$clima3=json_decode($contents3);
$alert_now1=urlencode($clima3->result[0]->Data);
if (($alert_now1 != urlencode($alerttitle_today1.PHP_EOL.PHP_EOL.$alertstart_today1.' uur t/m '.$alertend_today1.' uur'.PHP_EOL.PHP_EOL.$alerttext_today1[0].PHP_EOL.PHP_EOL)) && ($alert_now1 != urlencode($alerttitle_today1.PHP_EOL.PHP_EOL.'Er zijn geen waarschuwingen'.PHP_EOL.PHP_EOL.PHP_EOL))) {
Notification($subject,$thebody);
}
// Devices updaten (alerts)
Alert($idx1,$alertlevel_today1,$alert_today1);
Alert($idx2,$alertlevel_tomorrow1,$alert_tommorow1);
?>
Citaat van: GerritH op 21 april 2020, 23:28:29
Dag, nadat het script een tijd gedraaid heeft, ben ik het spoor toch weer bijster geraakt. Is het nu de bedoeling dat ik in Doimoticz zelf een LUA-script aanmaak, of moet ik het als script_time_weer.lua in de folder /home/pi/domoticz/scripts/lua zetten?
Laat ik zelf maar direct met een reactie/antwoord komen, het lijkt erop dat je ofwel het een ofwel het ander moet doen. Als je beide doet, loopt de boel spaak. Ik heb het bestand even "uit gezet", en dan draait het script ineens goed. Klopt deze redenatie??
return
{
on =
{
devices =
{
Schuurdeur =
{
'at nighttime',
},
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Group switch',
},
execute = function(dz, item)
local tuin = dz.groups('Tuin') -- Change to name of your group
if item.state == 'Alarm' then
tuin.cancelQueuedCommands()
tuin.switchOn()
tuin.switchOff().afterSec(120)
end
end
}