Notificatie voor het ophalen van het oud papier

Gestart door Joost, 20 maart 2021, 07:17:23

Vorige topic - Volgende topic

Joost

Vergeet je ook wel eens het oud papier op tijd aan de straat te zetten? Met onderstaand PHP-script zal dat niet meer gebeuren.
Bij ons wordt het oud papier op de eerste zaterdag van de maand opgehaald. Is dat bij jou op een andere dag? Vervang dan "first saturday", door iets anders, bijvoorbeeld "third wednesday",  "last monday", "fourth friday", etc.

Het script kun je uit laten voeren door een cronjob, maar ik gebruik zelf een container-script via Domoticz.


<?php
include("/home/pi/domoticz/scripts/php/functions.php");
include(
"/home/pi/domoticz/scripts/php/settings.php");

// Saturday this month
$thisMonthStart mktime(0,0,0,date('m')+0,0,date('Y'));
$saturday date("d.m.Y",strtotime("first saturday"$thisMonthStart ));

//Saturday next month
$nextMonthStart mktime(0,0,0,date('m')+1,1,date('Y'));
$first_saturday date("d.m.Y",strtotime("first saturday"$nextMonthStart));

$tomorrow date("d.m.Y",strtotime("+1 day")); 

if ((
$tomorrow == $saturday) || ($tomorrow == $first_saturday)) {
Telegram("Papier wordt morgenochtend opgehaald!",false,1);
}
?>