Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,


as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.


As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!



Smart Home Forum by FIBARO Team

  • 0

Max instances and killotherinstances





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.


Please login or register to see this code.



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.




Edited by Weider
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

This can be difficult to get right and unhappy guests are not a good thing.... :-) 

This problem is somewhat equivalent with all the attempts people have made to turn off the lights in the bathroom when no-one is there...

I would keep a variable 'inside' that is true if there is motion inside and the lock is closed. Then you can avoid turning off lights if someone is inside.

Coding it for multiple locks can get messy, but it's an interesting problem that I used as a morning coding exercise...

If I had coded it I would have used my EventRunner scene for HC2


and this is what I came up with

(I'm a bit unsure about the lock status, assume that locks global variable is 'inout' when opened and something else otherwise)


Please login or register to see this code.

This is only six locks/rooms but could easily be extended.

The whole event runner scene with the rules is attached:

Please login or register to see this attachment.


I would also recommend to run it using the HC2 emulator to test various scenarios (you see that I have some test code at the end of the main scene).


However, I have completely moved over to HC3 these days, but I still think the code is valid.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Heya!


    Thanks for your really comprehensive response. It's a lot to go through for a novice like me :D 

    Hopefully I'll have the time to dig into it. It looks interesting.



    But yeah. motion and lights is always going to be a pain. The main problem being that the trigger for OFF is no movement, zero, nothing. It has to be a more direct EXIT command. This is something SALTO Systems locks are great at, as they know which handle you used to open the door. So they know if someone is leaving or entering.



    I'll take a more in depth look at your stuff. Right now on the road and typing on a laptop sucks ass and I can't test anything.

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    • Create New...