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!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

JSON for lights


julesmartens

Question

Hi,

 

I'm no fan of the build-in alarm in HC2 so I'd like to create my own scenes/VD's for this. .

@Sankotronic is working on a very promising UHAS system but his plans are pushed out (no offence, he released real nice things already, I'm fan) 

 so I decided to move on, writing some code myself with hopefully some help of you ;-)!

 

What do I use in my alarm;

> Lights (selected regular lights in the house to switch to 100% when alarm is breached)

> Door/window sensors

> PIRs 

> Sirenes (for acoustic alarm)

> flashlight (for visual alarm)

> RGBW led indicator (at the entrances to notify alarm is; just armed (leave the house indicator), armed (not safe to enter indicator), disarmed(safe to enter indicator)

 

What do I want;

> Fibaro remote keychains available to manually arm/disarm the alarm

> All users have a IFTTT account on their phones to trigger a scene when entering/leaving home (geofence). This will set my global "guestmode". (bad exerience with Fibaro GPS)

> When nobody is at home, the global "alarmmode" should set to "FullAlarm". At "FullAlarm" all PIRs and D/W's sensors are set to armed. (report error when not in safe state when arming).

> When at night (Darkness) all users are at home and all PIR and D/W are safe for X time, "sleepstate" to be set "sleep" else "awake".

> when at sleep, the "alarmmode" will switch to RingOnly. Only the D/W sensors will be armed (not PIR). When a PIR is breached the alarmmode will be set to disarmed state. When sleep state is reached again the alarmmode will switch back to RingOnly. 

> if armed and breached, the alarm is triggered. The sirenes and flashlight will start to run and all lights will be set to 100%. If all D/W and PIR are safe for X time, alarm to back to armed state and lights off.

> if armed and breached, the timestamp of alarm will be logged. If alarm is disarmed after it was breached the notification LED will warn for this.   

> If I disarm the alarm, put all lights/DW in safe state.

> Notifications via Pushover or even better, use the message hub of @autofrank with Fibaro PopUps and Push services. Unfortunately I currently have errors with the message hub.

 

What is my current status. All code based on simple if/then LUA coding, no fancy loops. 

DONE: scene to check all PIRs Scene will set global variable

DONE: scene to check D/W sensors. Scene will set global variable

DONE: One scene to take care of the global sleepstate

DONE: One scene to take care of the global guestmode 

DONE: a VD to manually set alarmstate and alarmmode.

DONE: a VD to manually set guestmode

todo: a mainalarm scene to arm/disarm the alarm (based on above algorithm)

todo: an alarm scene to trigger the alarm when breached (or merge this in the mainalarm scene)

todo: scene(s) for RGBW led indicators

todo: scene(s) for the push notifications (Alarm breached, error (Eg door/window open when arming the alarm)

 

I noticed that I get stuck with the remaining scenes. I'm no programmer, so I use mainly simple if/then LUA code. With a lot of scenes in the alarm you easily get lost.

In an attempt to keep my coding cleaner/more condensed I want to use tables/json. I already use the Hometable but that's just a simple copy the instructions of @AutoFrank.

 

Questions;

For the remaining alarm scenes I have difficulties how to store a table in a global and even more how to use from a table. The tutorials on this topic are not clear to me yet.

For example, when the alarm is breached, how to switch all lights to 100% for the device IDs in a global(table). I have seen examples of code like k,v in (i)pairs but I don't get it yet.

Can somebody help me with some code examples?

Any other suggestions on my ideas for an alarm?

 

Thanks!

 

Regards,

Jules

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi Jules,

 

Unfortunately it is true that my UHAS roadmap is not correct anymore. I'm falling back with coding for several reasons and one of them is Fibaro introducing some undocumented changes in firmware which at the end required my attention and correction of my code. Also after upgrading to 4.510 I had to rebuild my system with more than 100 devices included from scratch which took valuable time.

 

I'm still working on UHAS and will continue until I reach goal that I have put in front of me. It takes more time than originally anticipated but all this difficulties on the way have one advantage that will force me to make it even better :-)

 

Now, regarding your questions:

 

The best source to learn how to work with tables in LUA you can find here:

Please login or register to see this link.

I'm still learning from Roberto Lerusalimschy's book and is the best source there is.

I use mostly table data in UHAS and in my standalone versions of virtual devices which you can download either here from Download section or from Fibaro marketplace. Of course since they are not commented it will not be easy to understand them, but that is the best I can do in this moment. I can still answer to your questions regarding my code once you check it.

 

Burglar alarm panel on HC2 is quite OK and can be used to do most of the actions if alarm is breached. Actions can be added even to run scene that will then do whatever actions user needs Just don't forget to check option to keep scene running when alarm is breached. For example to turn on all lights to 100% you can use alarm panel option "LIGHTS ON" and since this options can turn on only dimmers, switches and wall plugs that are defined as Light the rest of the lights like HUE you can turn on with scene that is added  as action to alarm panel.

 

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi, thanks for feedback and keep up the good work!

    I have two reason to not work with the Fibaro build in alarm panel.

    1) I dont want the alarm to disarm via PIN codes.

    2) I have two sorts of alarm in mind, 1, full alarm (PIR and DW sensors) and a RingOnly alarm that will only check DW but not the PIRs. 

    This I use when I'm sleeping at home.

    I will continue with my plans, hopefully I get the grasp of tables soon!

     

    Regards,

    Jules

    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.

    Guest
    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...