Documentation is good, examples are better.
- Ex1 - Turn off device after 5 min
- Ex2 - Turn off device after 5 min if motion sensors are off
- Ex3 - Turn off devices after 5 min if motion sensors are off from 2 min
- Ex4 - If a switch is turned on, do something
- Ex5 - Create custom events
- Ex6 - Be notified if a custom event is on for a number of minutes
- Ex7 - Be notified if device is on since 5 min or more
- Ex8 - Auto off device at a specific time
- Ex9 - Gradually increase every 2 min the level of the light from the last level to 50%, by step 5%.
- Ex10 - Blink/flash a switch
- Ex11 - Switch on 2 switches if they are off.
- Ex12 - Update different types of devices.
- Ex12 - Change the icon of the device
- Ex13 - Display the day of the week as an icon
- Ex14 - Updates every 5 min the public ip address in a text device
- Ex15 - Execute a long http request with a timeout of 5s, and catch the result
- Ex16 - Call meteo (Openweathermap) plugin and update 4 text devices
- Ex17 - Be notified when a lamp is on and no one is at home
- Ex18 - Interact with a Telegram bot
- Ex19 - French holidays
- Ex20 - Be notified if the public ip address change
- Ex21 - Push on quickly 2 times
- Ex22 - Switch on/off quickly 2 or 3 times
- Ex23 - Day off
- Ex24 - Auto on device between 20h and 22h, and keep it off all other times
- Ex25 - Calculate every 30min the travel time between your home and the Eiffel Tower (Waze)
- Ex26 - Meteo in Paris (OpenWeathermap)
- Ex27 - French holidays in Toulouse (BigInfo)
- Ex28 - Battery check
- Changelog
dzbasic
auto off after 5
dzbasic
auto off when minutesago >= 5, state "motion1,motion2" = alloff
"motion%d" refers to all devices named motion1, motion2, motion3...
dzbasic
auto off when minutesago >= 5, state "motion%d" = alloff , minutesago "motion%d" >=2
dzbasic
on dz_switchon
print "Hello world"
endon
These events are updated every minute and are visible from everywhere:
dzbasic
event ev_outdoor1 when %%temperature%% < 10 or %%temperature%% > 30
event ev_outdoor2 when %%temperature%% < 5, time = "7:00-9:00"
event ev_outdoor3 when %%sensorhum#humidity%% > 50
Reuse of ev_outdoor1 event declared in Ex5
dzbasic
on ev_outdoor1 duration >= 300 -- 5min
notification "Outdoor temp alert", FREQUENCY = 60, QUIET = "22:00-08:00", SUBSYSTEMS = "PROWL"
endon
dzbasic
on state = on, minutesago >= 5: notification "%%name%% on > 5 min", FREQUENCY = 30
dzbasic
auto off at "at 01:00 on monday"
Starts as soon as the light is turned on.
dzbasic
auto dim 5, 50 after 2
Blink 5 times every second
dzbasic
switch flash
dzbasic
switch on , "myswitch1,myswitch2", checkfirst
dzbasic
-- update value of a text device
update "hello world", "my_text_device"
update "A text"
-- update level% of a dimmer light
update 60, "my_dimmer_light"
-- update the temperature value of a sensor
update "21", "my_temp_sensor"
-- update values of a temp/hum sensor
update "21,50,0", "my_temp_hum_sensor"
-- update the level of a selector
update "Level", "my_selector"
dzbasic
icon 110
We assume that the values 100 to 700 correspond to the icon number in Domoticz.
dzbasic
on time "at 00:00"
$ICONS = 100,200,300,400,500,600,700
icon $ICONS[@date("%w")+1]
endon
dzbasic
after 5: update @url("https://api.ipify.org")
or
dzbasic
auto update @url("https://api.ipify.org") after 5
dzbasic
at "at 10:00" : url "https://longtimeresult.com/returnvalue", cb, 5
on dz_url : print "The site return "..$$
Appid can also be in a user variable named openweathermap_appid
.
Meteo plugin uses latitude and longitude recorded in domoticz configuration.
dzbasic
on minutesago >= 30
call meteo, appid="xxxxxxxxxxx"
--print "Meteo plugin return: ", $$
update $$["prevision"][2]["meteo"], "Meteo tomorrow"
update $$["rain"], "Rain today (mm)"
update $$["%rain"][1], "Rain % in 1h"
update $$["meteo"]
endon
Reminder: "Light" refers to all devices whose name begins with Light and "Presence" refers to all devices whose name begins with Presence.
dzbasic
-- At least one device "Light" is on; and all devices "Presence" are off
on state "Light" = on, state "Presence" = alloff
notification "Lights turned off, nobody is at home"
switch off, "Light"
endon
We assumed that an external script updates a text device with the Telegram messages
dzbasic
on dz_update
-- drop accents and unnecessary spaces
$text = @cleanstr("%%text%%")
if $text == "alarm on": switch on "Alarm"
if $text == "alarm off": switch off "Alarm"
if $text == "lights off": switch off "Lights"
notification "Ok, well received '%%text%%' command", SUBSYSTEMS = "TELEGRAM"
endon
dzbasic
on time = "at 1:00"
$zone="B"
url "http://domogeek.entropialux.com/schoolholiday/"..$zone.."/now/"
if $$ == "False"
switch off, checkfirst
else
switch on, checkfirst
endif
endon
or
dzbasic
$zone="B"
on time = "at 1:00": auto onoff when @url("http://domogeek.entropialux.com/schoolholiday/"..$zone.."/now/")~="False"
dzbasic
on minutesago > 120
url "https://api.ipify.org"
if %%text%% ~= $$ : notification "New IP= "..$$
update $$
endon
or
dzbasic
after 120: update @url("https://api.ipify.org")
on dz_selfchange : notification "New IP= %%text%%"
dzbasic
-- trigger event if the button is pushed within 1 second after the last push
event ev_quickpushonbutton when dz_update, secondsago <= 1
on ev_quickpushonbutton repeat = 2
print "The button was pressed 2 times"
endon
dzbasic
on dz_switchon
event ev_quickswitchonoff when repeat <= 2
on ev_quickswitchonoff repeat = 1 : print "Action 1"
on ev_quickswitchonoff repeat = 2 : print "Action 2"
on ev_quickswitchonoff repeat = 0 : print "Default Action"
endon
Prerequisite : install the plugin biginfo.lua
dzbasic
auto onoff when $BI_ISWE or $BI_ISPUBHOLIDAYS
dzbasic
auto onoff at "20:00-22:00"
or
dzbasic
auto on at "20:00-22:00"
auto off at "22:00-00:00 and 00:00-20:00"
Prerequisite : install the plugin waze.lua
dzbasic
on minutesago >= 30
call waze, dest_addr="5 Avenue Anatole France, 75007 Paris"
update $$["totalRouteTime"]
endon
Prerequisite : install the plugin meteo.lua
dzbasic
on minutesago >= 30
call meteo, addr="5 Avenue Anatole France, 75007 Paris", appid="xxxxxxxxxxx"
update $$["meteo"]
endon
Prerequisite : install the plugin biginfo.lua
dzbasic
on minutesago >= 30
call biginfo, addr="mairie de Toulouse"
print "Vacances à Toulouse: "..$$["BI_HOLIDAYS"]
endon
dzbasic
on dz_batterylow: notification "Battery for %%name%% is low (<10%)"
or
dzbasic
on %%batteryLevel%% < 20: notification "Battery for %%name%% is low (<20%)"
- 26/04/21 : Creation
- 27/04/21 : Addon, corrections (Ex5, Ex13, Ex9)
- 27/04/21 : Addon, corrections (Ex5, Ex6)
- 28/04/21 : Addon, improve explication, corrections
- 29/04/21 : Addon, corrections
- 05/05/21 : Addon, corrections