Hi!
I have an idea project with a small hotel. 13 Rooms.
It has Salto locks (Owners of Danalock if anyone is wondering).
Normally there is a classic energy saving devices (ESD) in the room, where guest puts a key card into a device which turns off electricity when key card is removed.
When guests enter with mobile keys on their phones (Bluetooth) there's no key cards to put in the ESD. That's the reason for this idea project/solution. Yes Salto has it's own solutions but this is simpler installation wise.
Idea is to receive event's from the Salto locks and Fibaro motion sensors. Locks modify Globalvariable for each room to the last position (Entry/Exit) as it can read and stream the events of outside and inside handle openings. Whenever this changes the scene is triggered. Based on time if motion is detected or not the electricity stays on or turns off.
Just to think of all the ideas what can happen was a pain.
The first part (1)+(2) is if a guest enters a room. Everything turns on, but if he only opens the door and doesn't enter and move within X seconds everything turns off. In case he only checks the room really quickly.
Second (3)+(4)+(6) If guest leaves room after X seconds everything turns off, if it doesn't detect movement in X seconds. In case if 1 person leaves and other stays, or is asleep.
A brand new scene, really simple one, is going to be for motion detection, if everything else points to turning electricity off and there's actually still a person inside. Just being really still for 1 hour or so, sleeping or something.
I can't have it in this one because motion is going to be a trigger.
Timings are placeholders and comments language is Slovene.
--[[
%% killOtherInstances
%% properties
%% events
%% globals
kljucavnica1
--]]
local kljucavnicaStatus = fibaro:getGlobalValue("kljucavnica1")
local kljucavnicaLastModified = fibaro:getGlobalModificationTime("kljucavnica1")
--(1)+(2)Ko stranka odklene sobo se prižge vse, če samo odpre vrata in se ne giba X sekund se ugasne vse
--Nastavi številko device-a motion senzorja fibaro:getValue(ŠTEVILKA, 'lastBreached')
--Nastavi številko device-a za kontrolirat fibaro:call(ŠTEVILKA, "pressButton", "1")
local turnOffTime = 10
if (kljucavnicaStatus == "vhod") then
fibaro:debug("Vhod postopek.")
fibaro:call(194, "pressButton", "1");
setTimeout(function()
if (os.time() - fibaro:getValue(5, 'lastBreached') > turnOffTime) then
fibaro:call(194, "pressButton", "2");
fibaro:debug("Vhod in ni gibanja. Vse se ugasne.")
else
fibaro:debug("Vhod in je Gibanje. Vse ostane prižgano.")
end
end, turnOffTime*1000)
end
--(3)+(4)+(6)Ko stranka zapusti sobo se po X sekundah vse ugasne, razen če zazna gibanje v X sekundah.
--Nastavi številko device-a fibaro:getValue(ŠTEVILKA, 'lastBreached')
--Nastavi številko device-a za kontrolirat fibaro:call(ŠTEVILKA, "pressButton", "1")
local turnOffTime = 10
if (kljucavnicaStatus == "izhod") then
fibaro:debug("Izhod postopek.")
setTimeout(function()
if (os.time() - fibaro:getValue(5, 'lastBreached') > turnOffTime) then
fibaro:call(194, "pressButton", "2");
fibaro:debug("Izhod in ni gibanja. Vse se ugasne.")
else
fibaro:debug("Izhod in je Gibanje. Vse ostane prižgano.")
end
end, turnOffTime*1000)
end
Number 5 example I'm still thinking of how to solve. It's going to be "Guest enters room, leaves door open and triggers motion then leaves." So no inside handle opening and so no exit registered. Might add a second motion check with a delay for that.
If anyone has any suggestions to change or do things differently I'm welcome to it.
But the issue I'm having right now is. If a person enters-exits-enters-exits really close together in time, I've added %% killOtherInstances at the beginning, this should work fine I think even if it's a 30 minute timer to check movement.
But also I was thinking of putting an array of rooms in the scene. So I don't have to create scenes for every room. Is there a way of doing this without overwhelming the system with to many running scenes or killing an instance that's still in the process of confirming movement?
I know it's a long post and everything, but I wanted to put in as much detail as possible.
Thanks!