Perhaps many of you have encountered the situation that you were leaving your own home. You may did not know if you had left any of the windows open. So you had to go check the window in a particular room. In this blog will be presented a short and simple LUA script, which will send you a PUSH notification with information about the window or door that remained open.
This LUA script can run eg:
You can link the script to any condition that suits you.
In the LUA script below, you need to make some adjustments to work with your control unit.
Need to know:
1. IDs of the Window and Door Sensors you want to check. (LUA 8th line)
Then insert these values in the LUA script on the 8th line, which looks like -> sensors = {33, 37, 59}
2. IDs of the Mobile Devices to which you want to send PUSH notifications. (9th LUA line)
Then insert these values in the LUA script on the 9th line, which looks like this -> phones = {205, 206}
--[[
%% properties
%% weather
%% events
%% globals
--]]
sensors = {33, 37, 59} -- IDs of Windows or Door sensors
phones = {205, 206} -- IDs of Mobile Devices for PUSH Notifications
local sensor_triggered = 0;
local sensor_name = 0;
local sensor_room = 0;
local message1 = "Okno miestnost: "; -- content of PUSH notification for Room Name, can be changed
local message2 = "Okno zariadenie: "; -- content of PUSH notification for Device Name, can be changed
local message3 = "Vsetko zatvorene!"; -- content of PUSH notification when no sensor is triggered
function sensors_check()
for i=1, #sensors do
if(tonumber(fibaro:getValue(sensors[i], "value")) > 0) then
sensor_triggered = 1;
sensor_name = fibaro:getName(sensors[i]);
sensor_room = fibaro:getRoomNameByDeviceID(sensors[i]);
message1 = message1 .. sensor_room .. " | ";
message2 = message2 .. sensor_name .. " | ";
end
end
end
function message_push()
if (sensor_triggered == 1) then
for j=1, #phones do
fibaro:call(phones[j], "sendPush", message1);
fibaro:call(phones[j], "sendPush", message2);
end
fibaro:debug(message1);
fibaro:debug(message2);
elseif (sensor_triggered == 0) then
for j=1, #phones do
fibaro:call(phones[j], "sendPush", message3);
end
fibaro:debug(message3);
end
end
-- main code
sensors_check()
message_push()
Push notification on mobile phone looks like in both the original and new FIBARO controllers.
Note 1: This LUA script is an inspiration, you can incorporate the changes by yourself. e.g. not just send notification as PUSH notification but as email.
Note 2: To send only room name to PUSH notification, comment out (-) all lines in the LUA script containing "message1".
Note 3: To send only a specific device name to the PUSH notification, comment out (-) all lines in the LUA script containing "message2".
You can get the Z-Wave ID of your window and door sensors in several ways:
You can get mobile device IDs in several ways:
LUA Script: Battery check - Fibaro Home Center 2
A simple LUA script to check the status of battery devices.
Implementations and setting the device for the triggering of the Fibaro Swipe scenes using the LUA script.
2 Comments
Norbert Kovács 12/25/2020 Reply
Hello,the scene runs on the controller, but no push notification comes
- I entered phone IDs
do I need to change anything else?
thank you and merry christmas!
SmarterHOME Team 12/26/2020 Reply
Hello,thank you for comment.
Are you sure that you entered correct IDs of mobile/smart devices?
If yes then - Are you able to connect to your HC2 trough cloud (FIBARO ID service)?
If yes, try to reboot your HC2.
Have a nice day.