i have read many option on forum but i cant figure it out how or what to do to get it to work
i want to calculate time from start sundown to self set end time 22:30
used variables are
text / (Tijd Week) (set to 22:30)
text / (Tijd Weekend) (set to 00:30)
number / (Tuin Timer) (set in seconds)
text / (Tijd Nu)
IF (Sundown in 0 min) then Set (Tijd Nu) with current time IF weekday then (Tijd Week) - (Tijd Nu) = result in minutes (*60) = seconds else (Tijd Weekend) - (Tijd Nu) = result in minutes (*60) = seconds then Set Result seconds to (Timer 1)
for example
sundown 18:30 (time)=18:30
end time 22:30 (endtime)
remaining time 22:30 - 18.30 = 4 hour * 3600 = 14400 sec (timer set 14400)
end result is then something like this
can someone please explain me how to make something like this or know what i can use for this to
First (voer // get the current time date and time)
// Get the current date and time
var currentDate = new Date();
var currentTimeInSeconds = Math.round((currentDate.getHours() * 3600) + currentDate.getMinutes() * 60) + (currentDate.getSeconds());
// Set the result in a Homey variable of type number
setTagValue("Tijd Nu", {type: "number", title: "Tijd Nu"}, currentTimeInSeconds);
// Log the result (optional)
console.log("Current Time in Seconds: " + currentTimeInSeconds);
Second (Voer // Define the time in hours and minutes)
// Define the time in hours and minutes
var weekhours = 22;
var weekminutes = 30;
var weekendhours = 00;
var weekendminutes = 30;
// Calculate the total seconds
var totalSecondsweek = (weekhours * 3600) + (weekminutes * 60);
var totalSecondsweekend = (weekendhours * 3600) + (weekendminutes * 60);
setTagValue("Tijd Week", {type: "number", title: "Tijd Week"}, totalSecondsweek);
setTagValue("Tijd Weekend", {type: "number", title: "Tijd Weekend"}, totalSecondsweekend);
// Log the result (optional)
console.log("22:30 in seconds: " + totalSecondsweek);
console.log("00:30 in seconds: " + totalSecondsweekend);
ALERT this is the normal time (no winter time for dutch)
if you need this you have to add 3600 sec somewhere you want