Multiple conditions to trigger flow

Hi All,

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.

I would change the PING path so the true side of the switch sets a flow variable like 'i_am_home' to true and the false side sets it to false.

Then in the warning flow add a switch to query the flow variable to see if you are home or not.

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" :wink:) 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?

Yes IFTTT. ok i'll try my best to explain but will probably sound confusing. Its all bases off

I use an application called xDrip which continuously uploads the readings to a Mongo DB which my account with 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:

BG_HIGH (urgent high)
BG_LOW (urgent low)
BG_TARGET_BOTTOM (below target range)
BG_TARGET_TOP (above target range)

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.

Isn't that what my suggestion would do for you? Here is a high lever description[tion of what will happen.

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

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.

You are correct that MongoDB can be integrated with Node-Red but I gave up trying as I couldn't figure it out.

Which part?

Another possible alternative would be to look at NightScout itself as it seems likely that it has an API that might be usable for querying?

To be honest my database knowledge is terrible.



"Error: missing delimiting slash between hosts and options"

Nightscout has a URL which displays blood glucose levels

OK, just signed up for a Heroku account. I'll try setting up a dummy MongoDB database then see if I can connect to it.

Any thoughts on a possible NightScout API?

Drat, Heroku wants a credit card before it will let me set up a db.

Don't worry it won't charge you. Just part of the process to setup account.

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 realise that but I object to giving over my credit card details for no reason. Each time you do that is a risk since they are storing that data.

So I'm afraid I can't go further at least for now.

I suspect that you need to do some investigation into how to connect to the services remotely. Perhaps someone else who uses Heroku knows the answer.

I would at least expect to have to use an API key somewhere.

in the host field, are you sure you need to use http:// ? try removing that part.

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 :slight_smile:

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.

Thanks for all your help!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.