hepcat72 / node-red-contrib-life360

GNU General Public License v3.0
3 stars 4 forks source link

Knowing if anyone is at at a place #3

Closed vellad1 closed 3 years ago

vellad1 commented 3 years ago

Hi,

So I am trying to build a flow that tells me if someone is at a configure place (home) at a time.

I am thinking of doing this by implementing a system of counters; i.e. a variable that increases/decreases everyone arrives/leaves a home. Than I would assume that if the variable is 0 then it means that there is no one at home. In concept i think this could work but while designing it I thought that I would probably have an issue in case of node-red restarts (as count would be lost) or a failure to track meaning that a count was not increased or decreased.

So i thought to ask to see if anyone implemented this flow and maybe they solved my concerns already.

I also know that there is the checkbox 'Trigger arrivals on Node Red Restart' and I wanted to see what this actually does.

Thank you.

hepcat72 commented 3 years ago

I have a similar flow, but mine's more streamlined. I use the first to arrive, last to leave settings to set an occupied variable. In fact, that's why I created this node - to make this flow simpler. I have 2 L360 nodes. One emits first to arrive events that sets occupied to true and one emits last to leave events which sets occupied to false. While I save the variable in a persistent fashion, you could use the first to arrive node to set to true upon restart, however, that won't help you with initializing the variable to false (if that's the occupied state). Though you could assume that if the variable does not exist when checked, initialize it to false.

Rob

vellad1 commented 3 years ago

Hey Rob,

The way you do it is much simpler and to the point :) I will implement something similar. Pity there isn't a way how you can 'ask' L360 if anyone is at home instead of L360 notifying you on change!

Thanks Rob!

hepcat72 commented 3 years ago

Theoretically, you could, but you'd have to track each user individually and ask for each one. Honestly, it seems easier to use the first/last to arrive/leave and track that one result.