GEO Fence

Forum rules
We've moved! Head over to Synology Community (community.synology.com) to meet up with our team and other Synology enthusiasts!
pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Fri Aug 03, 2018 5:03 pm

Ok , will do tomorrow, not at home right one

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Fri Aug 03, 2018 5:08 pm

pergola.fabio wrote:
Fri Aug 03, 2018 5:03 pm
Ok , will do tomorrow, not at home right one
Thanks, will appreciate very much.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Fri Aug 03, 2018 8:07 pm

here is how i did it, you dont need curl of whatever to get SID first and stuff like that, its quite easy actually to create a SINGLE url to set home mode to ON / OFF

so in home mode: settings - enable the setting for actions, because we are going to create 2 actions for this
action 1 = Home mode ON
use for event = External device, event = external event 1 , action= surveillance station = home mode = ON

action 2 = Home mode OFF
use for event = External device, event = external event 2 , action= surveillance station = home mode = OFF

to get the 2 url's, just go to the action again, on the EVENT tab, there is a button = "get command", this gives this result :

http//192.168.0.14:5001/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method="Trigger"&version=1&eventId=1&eventName="This is external event1"&account="{account}"&password="{password}


notice , eventid=1 , = ON , eventid=2 = OFF
just replace the internal IP to your public IP, and offcourse change account/password
that modified url, you can now use in the webhook, or whatever other application to set home mode to ON or OFF

easy :)

one problem though, with multiple users , the geofence of surveiilance has binding devices
so when using IFTTT or whatever, if one persons leaves, home mode = OFF, while the other person is still in the house :)

but there is also more info about that here :
https://homealarmreport.com/guide-using ... eofencing/
or

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Fri Aug 03, 2018 10:05 pm

Thanks @pergola.fabio Tomorrow came quickly.

I'll be busy for a while figuring out how to use the tools for this project. I was surprised to learn that there actually is a Web API for the Surveillance Station, and that give me hope this is do-able.

The single user limitation on the IFTTT geofence makes that source unattractive as a trigger for me. I really don't want to have it setting into Home Mode OFF while my wife is still at home. I am hopeful that I might instead be able to use my house Alarm System Away activation and resetting, via my Vera system for the triggers instead. That will make it totally automatic, assuming I can make it all work together. This will be great fun.

UPDATE: The first part of that project didn't really take very long. I was able to create the Action Rules & test them successfully. I was also able to create a couple of Bookmarks on my phone home page - one to switch Home Mode ON and another to switch it OFF. Both work fine.

The second task, getting the alarm system trigger over to them may be a little more difficult, but I'm thrilled that the API exists, and that Synology has made it so easy to utilize it. For the interim I can do the manual switching almost instantly, which beats the heck out of waiting for the long login and load on DS Cam to finish before making the switchover.

Thanks again for sharing.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sat Aug 04, 2018 7:11 am

glad i could help :)
if you read that article IFTTT and life360 is a good alternative for multiple users, i think we can use that life360 also fot other purposes :)

but anyway, indeed trigger the url/action with the alarm system is the best way :)
i am also waiting for my alarm system to be ready as as a service for 3th party, i am using risco as a alarm system
they have now a smart home device already, but ist limited, i think they are now developing something for IFTTT too

but anyway, at the moment i am both testing out the geofence from ds cam, and location from phone ,
i have the both enabled with email notification, so i know witch one trigger the Home system On or OFF

after 2 days, they both were reliable to me , on the same moment
but i think when the phone is in deep sleep, it takes a while before its passes the location information to DS cam or IFTTT

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sat Aug 04, 2018 1:25 pm

Actually, I have found it , my alarm can send email notifications when it's. Armed or disarmed...
Now I just make in ifttt en email service , based on the subject of the email i enable the corresponding webhook ...

Done ;) no need for geofence anymore...!

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Sat Aug 04, 2018 6:03 pm

Me Too. I used the email that my Vera System generates whenever the Alarm System - Alarm Away is Activated or Disarmed, added multiple filters in Gmail to put them in separate folders and labels, then used IFTTT to Trigger off the labelled emails, and Webhook to output the HTTPS URL's to switch Home Mode OFF and ON, as appropriate. I put the entire Action Rule URL in the URL field in Webhook, designated it as GET type and simple text.

It all worked the first time I tried it. The Home Mode switchover & Notification worked within a minute on my first couple of tests, so I'm pretty confident it will do the job reliably. Time will tell.

I want to watch to see if IFTTT running in the background will have any effect on battery life, but hopefully it will be minimal. I'm running on the Android 9 beta, so I know it will work with the latest & greatest OS in Android. Barring any unhappy surprises regarding the setup, I'm optimistic this will be my ongoing arrangement. Having this all automated, starting with setting and resetting the Alarm Away is incredibly useful and appropriate.

I'll be sure to post here if I encounter any issues with the setup in the future.

@pergola.fabio II really appreciate that you made me aware of the Synology Action Rules to control Home Mode, and the IFTTT/Webhook capabilities. I hope you are also successful with your similar approach to the problem.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sat Aug 04, 2018 7:07 pm

no problem at all :) just done lots of trial and error :-)

i have the exact same setup as you , also based on gmail service in ifttt based on labels, for my incoming email events from my alarm system... i never thought about this idea :)
now i also setup to turn off lights/radio when i leave home based on an email trigger :) or turn on lights when there is alarm etc...


but you said you are running IFTTF as an app? you dont have to run IFTTT at all on your android, since its a cloud service
you are using gmail and webhook, they dont rely on your android

the only problem, well not a problem, is the timeout
the email from my alarm is instant;, but seems a small delay when IFTTT is picking up the mail, maybe 1-2 mintues, so a small delay when home mode is off/on
but probably there is also a delay when using geofence sometimes

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Sat Aug 04, 2018 10:59 pm

You made a good point about the IFTTT app on the Android phone. I don't really need to have it installed there for the triggers to be acted upon by IFTTT and Webhook. I removed it.

I've seen some delays between the Alarm Away Activated email receipt and the Home Mode action shown in Synology - between 4 and 13 minutes so far. That's much longer than I would prefer, but not a major issue, as long as it completes the task each time. I have found that if I issue the Alarm OFF Trigger prior to the previous switching action having completed, it seems that the second one is not acted upon, and apparently discarded or ignored.

That results in Home Mode being left OFF. In the real world that's probably not a big issue, since it's unlikely that I will set the alarm, and clear again within minutes, but I need to be aware of that behavior. If I ever do have a very short cycle, and that happens,, I can quickly set Home Mode ON again from the phone.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sun Aug 05, 2018 4:26 am

Well, didn't notice that huge delay, did I think 3 tests now , maximum was like 4 minutes here...
Even quick turn off on alarm here worked, the 2 mails were processed in right order...

I think you can do it faster with the email service of ifttt , not Gmail labels... So you need the forward to an ifttt account , based on hashtag you launch the webhook , instead of the labels...
But then you need another account, since Gmail can't forward the email, you need to verify the sender in Gmail or you need to change the from address in your alarm system...I cant do that...


But there are also other alternatives besides ifttt, that do the same webhook.... And maybe with less delay...

https://context.io/features/
https://automate.io/integration/gmail/webhooks
....

Maybe you have some other services or dockers running on your Synology that you can use to launch an webhook....

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sun Aug 05, 2018 6:29 am

Ok, noticed now delay too in ifttt , 9 min now, gonna test an alternative now for ifttt, like in my previous post, or do email forwarding with hashtag , but then not with a Gmail account...
Or maybe there is IMAP fetcher on Synology tool, that can forward a mail based on a folder/label...
Then send that email to ifttt itself, should be quicker then

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Sun Aug 05, 2018 2:21 pm

It looks like the variable lag time is attributable to the period between the Alarm System email to gmail and the IFTTT trigger to Webhook. That makes sense, since IFTTT has to poll the gmail account for the emails, and I'm guessing that it does that on a periodic basis, hence the variable delays.

Webhook appears to be acting pretty instantaneously upon the IFTTT request. I see no significant time delay between the IFTTT trigger to Webhook, and the resulting Synology Home Mode switchover.

As soon as I can, I'm going to experiment to see if I can cause the Vera emails to include a unique hashtag in the subject line. If that is possible, I think I can just forward the email to IFTTT email address to trigger the action, rather than wait on the polling.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sun Aug 05, 2018 2:25 pm

ok, well, with our alarm system, i cant change the "from" address
so i need to use another gmail adress if i want the forward option to an ifttt address, since gmail doesnt allow forwarding to an address that is not verified

but now, i am testing "Home Assisant" , i already had that running on my synology for other home automation purposes..
seems it has also a email agent that can trigger webhook... so i just need to rely on the polling of the email agent, maybe thats also a setting, like 1 min polling or something

vicw
Sharp
Sharp
Posts: 166
Joined: Wed Apr 04, 2007 1:31 am

Re: GEO Fence

Unread post by vicw » Sun Aug 05, 2018 2:49 pm

I was able to get Vera to include the hashtag in the subject line, but I now see what you mean about gmail not allowing forwarding to an unverified address. I didn't know that until now. That's a bummer.

pergola.fabio
Student
Student
Posts: 76
Joined: Thu Jul 12, 2018 7:42 pm

Re: GEO Fence

Unread post by pergola.fabio » Sun Aug 05, 2018 3:01 pm

:)

is it quicker now if you work with the hashtag and an ifttt email address?

Locked

Return to “DS cam”