I have a continuously blood glucose monitor and want to create a process flow to trigger low and high alerts to my amazon echo when this occurs & be smart enough to only broadcast when I am at home.
What I've done so far is make ITFFF send a message to node-red via telegram which then posts an http request to a 3rd party alexa skill known as "Virtual Buttons". This then triggers an Alexa routine which broadcasts a pre-set message.
The 2nd process I've made is having a continuous ping to the IP address of my mobile phone and posting an http request if it is able to ping.
I want merge these together so this can only happen if both are true.
Another step which I can hopefully figure out myself is to add a delay before this repeats.
Thank you in advance if anyone can put me in the right direction or refer me to any guides.
Just to be clear, how is the monitor sending alerts? And where to?
The issue with using IFTTT (I assume that's what you mean by "ITFFF" ) is that it may only respond in a 15 minute window. Is that fast enough? You are also using 2 separate cloud services to provide the alert which might be somewhat unreliable.
Also, do you really only want the alerts when at home or is that an artefact of how you are doing things?
I use an application called xDrip which continuously uploads the readings to a Mongo DB which my account with https://dashboard.heroku.com/apps which has a setting where you enter maker key details to pull to IFTTT.
There are some settings where you can set alerts for events called:
You can set thresholds to how frequently they alert e.g. 15 mins. But this only alerts when its been low or high for over the set time and I want it to tell me straight away then repeat every 15 - 20 mins (or whatever I specify).
I'm hoping this can be achieved via node-red.
When I'm at work there's no point my Amazon echo's making noise if I'm not home. I'll just rely on the mobile to vibrate instead.
OK, so NightScout seems to have many ways of getting data out which is nice.
I think that you will struggle with IFTTT but it looks like there are probably other ways if you wanted to investigate them.
I get that you don't want the Echo going off if you aren't there, that makes sense.
I think that you could connect to your MongoDB instance directly from Node-RED. Don't think MongoDB supports a subscribe method but you could poll it once a minute (you would have to work out the best timeframe for your use). Then test the output, if above/below the required thresholds, check the presence variable then send to the Echo. I would expect this to be a lot more reliable and faster than using IFTTT/Telegram.
I'm assuming that your phone notifies you anyway so do don't need anything else for that? If you do, then you can incorporate Telegram into your flow. Typical delays on Telegram are between 1/2 second to 3 or 4 seconds in my experience.
This was the video I followed to setup nightscout. You need card details to create an account but won't be charged. Fast forward to 3mins 20 secs where this is mentioned.
I tried that with no success. However I've followed zenofmud's ping flow suggestion to solve the only broadcast a message when my mobile is connected to the Wi-Fi
Ping flow
ping -> switch node (are you home)
yes -> set flow.i_am_home 'true'
no -> set flow.i_am_home 'false'
end ping flow
Alert flow
alert arrives -> switch node (see if you are home)
is flow.i_am_home 'true' -> send alexa message
is flow.i_am_home 'false' -> do nothing
end alert flow
However my mobile seems to block ping request when inactive for more than 5 minutes. There's a settings called "Stay connected when device sleeps" which was already set to on, although the mobile was set to go to sleep after 2 minutes but changing to 10 minutes still stopped pinging after 5 minutes. The mobile is a Huawei p30 pro.
I've got 1 extra challenge which isn't really related to the post title.
When I eat my blood sugars levels will naturally go above their target range for approx. 2 hours before returning to normal. During this time I would like a way of snoozing the high alarms (but no low ones) for 2 hours. I would trigger this be using a webbook or certain key phrase message to telegram bot.
If there a way to create a delay when the number is a variable?
Now we are getting to a different topic. How mobile devices save power.
Personally, I've been having more success using a regular nmap command on my node-red host along with a flow that accumulates last-seen timestamps.
Better still if your router or WiFi AP tracks active devices as that is more likely to be accurate.
There was another thread on this recently.
Another approach is an in/out board. I've seen these done with pegs for hanging up your keys so pretty automatic. Or you could have some simple touch switches. Or indeed, you could use Google Home or an Echo "Hey Google, I'm home!".
I think I leave this thread for now since I'm moving onto a difference topic. What I might do is set the flow so when it gets a successfull ping request "I_am_home" changes to true but do nothing when the ping is false. Then maybe create an IFTTT rule on mobile like when if exiting a GPS location to change "I_am_home" to false.
I would rather it think I home when I'm not then the other way round.