"Bedtime" PHP example?

Can someone point me to a PHP script example, that I can use as template for a „Bedtime“ action? The script shouldn’t have to be too complicated, something like this:

  1. Start scene „Dim lights 45% in living room“, and after 10 minutes start scene „Lights off 0% in living room“
  2. Start scene „Dim lights 25% in bedroom“, and after 10 minutes start scene „Lights off 0% in bedroom“

Thanks!

The minimum script would be (if not called by a timer event itself):

if($_IPS[‚SENDER‘] == „TimerEvent“)
{
IPS_SetScriptTimer($_IPS[‚SELF‘], 0);
// place code of yours system call for „Lights off“
}
else
{
// place code of yours system call for „Dim-Lights xx%“
IPS_SetScriptTimer($_IPS[‚SELF‘], 600); // 10 mins.
}

1 „Gefällt mir“

Thanks. This is what I’ve come up with (uptil now). Is there a „native“ command to switch lights on/off? The command structure looks a bit different than the command for Scene Control.

<?php

//Start writing your code here

if($_IPS['SENDER'] == "TimerEvent")
{
IPS_SetScriptTimer($_IPS['SELF'], 0);
// place code of yours system call for "Lights off"
SZS_CallScene(12345, 1);
SZS_CallScene(23456, 2);
RequestAction(34567, false);
}
else
{
// place code of yours system call for "Dim-Lights xx%"
IPS_SetScriptTimer($_IPS['SELF'], 600); // 10 mins.
SZS_CallScene(45678, 3);
SZS_CallScene(56789, 4);
RequestAction(67890, true);
}
?>

Those things will get easier in our new upcoming new script type, which will allow you to define flows with timers and specific actions which you just click+add through the UI.

paresy

1 „Gefällt mir“

That sounds promising. I’m looking forward to it! :wink:

Dennis.

Unfortunately I can’t tell much about these SZS_ functions since I didn’t find the documentation for it, yet. My experiences are focussed at KNX and HomeMatic.
Since I don’t know how the implementation of the script-timer invokation is made, I would always suggest to make it the last command in a block. You wrote it at first place.