Zone Size?

Is there a limit on the size of a zone?

My “workplace” is an entire county and would like to text my wife when i come and go as the only reason I’m ever in this county is for work.

Trying to figure the central lat/long to make a fence seems daunting so figured I’d ask before attempting.

In Node red there is an option to use polygon shapes.

But isn’t there like a road you always cross? Couldn’t that be the zone and depending on the direction of travel send an appropriate message?

Hmmm i was curious about parsing travel of direction. Because during the weekends I can travel to our sister county which is the opposite direction. I take different routes home though, depending on where I’m at when I’m done in the field. There’s also no set time between 8-430 im in the county in the field… so time conditions don’t work.

When i was on hubitat i had the hub running, 2 raspberry pis running two node red and hoobs. My goal has been to keep everything on one central hub. Granted node red has an integration so interesting thought.

Node red can run as an addon on the name PI as HA

Regarding direction of travel.
Have a look at the proximity integration.
This will give you distance from home and direction of travel

Thank you I will definitely look into this. I was thinking the same with node red as an integration it would still meet my goal of one platform.

Wouldn’t that be nicer to do with a county wide geo-fence in Node Red? I read somewhere that you can at least define country borders based on GPS location…

I’ve actually started this. I have the node-red geofence around the county line…that’s so cool because the geofence node literally uses a map with county lines drawn marked on the map lol.

Despite using it before node-red is so foreign to me. I used to use it only for exec commands for adb on my TVs before coming to Home Assistant.

Now to figure out how to send lat/long from the Home Assistant Companion app to Node Red. I can get the entire payload into the debug console but can’t figure out how to have that trigger the geofences…I just need it as simplified as possible…

I leave the county geofence going West then it sends a notification to my wife’s phone that I’m heading home from the county line.

Literally all I want is when device.tracker.(mine) leaves the county it flips an input_boolean in Home Assistant. I’ll then use that with the proximity integration to fire an automation if I’m going west…as our sister counties I can work on-call for are north and east. I would never have a reason to exit via the southern end of the county. There’s the odd chance I have to cut through traveling point A to point B, which with the way the county is drawn out that would likely happen only on the north end or if I’m on county line roads.

I think you could use something like this:

[{"id":"1ad98ae7a4cf2aa2","type":"change","z":"ebaa69a9.649708","name":"","rules":[{"t":"set","p":"location.lat","pt":"msg","to":"data.new_state.attributes.latitude","tot":"msg"},{"t":"set","p":"location.lon","pt":"msg","to":"data.new_state.attributes.longitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":2600,"wires":[["125cec4b13ef75a3"]]},{"id":"fdad15034d801d69","type":"server-state-changed","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.moto_g_9_play","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":2600,"wires":[["1ad98ae7a4cf2aa2"]]},{"id":"125cec4b13ef75a3","type":"geofence","z":"ebaa69a9.649708","name":"","mode":"circle","inside":"true","rad":0,"points":[],"centre":{"latitude":0,"longitude":0},"floor":"","ceiling":"","worldmap":false,"outputs":1,"x":700,"y":2600,"wires":[["1a9ddbf4427f337d"]]},{"id":"1a9ddbf4427f337d","type":"switch","z":"ebaa69a9.649708","name":"","property":"data.event.new_state.attributes.course","propertyType":"msg","rules":[{"t":"btwn","v":"180","vt":"num","v2":"359","v2t":"num"},{"t":"btwn","v":"0","vt":"num","v2":"179","v2t":"num"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":2600,"wires":[["967c04f2a03830a9"],["07f0a4f4ba587549"]]},{"id":"967c04f2a03830a9","type":"debug","z":"ebaa69a9.649708","name":"westbound","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":2580,"wires":[]},{"id":"07f0a4f4ba587549","type":"debug","z":"ebaa69a9.649708","name":"eastbound","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":2620,"wires":[]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

you just need to change the device tracker and the geofence.

Not sure about the course if that works as expected. I have never looked at that attribute when driving.

Would the geofence be only points inside or only points outside?

I think I’ll need one for inside to turn the boolean on and one for outside to turn the boolean off?

If I remember correctly the last setting here makes it trigger on both inside and outside.
image

But this means you need to add a condition (current state node) to check if the boolean is on/off to not send the notification on every position update.

Ahhh ok hmmm. The boolean won’t do anything when I get to the county so I can have it only fire when that boolean is on.

I have been thinking a bit…
I think you need to make the area more or less just the border between the countries.
Otherwise I think going west to the toilet might trigger the automation.
Are you using high accuracy when driving?

Make sure you fire all actions to yourself the first few trips to make sure you debug it properly first.

That’s an idea but wouldn’t having the geofence trigger only on points outside with a boolean blocking after it fires once work as well?

From the Node-red-node-geofence docs.

msg.location.inarea is always a boolean and now just reflects the last geofence node that the message passes through.

So it appears that the in area is only a toggle of off/on depending on the last message passed through it.

Yes I drive with high acc. mode on. I have it turn on, along with turning off a potential accidental touch power save mode and turning on my hotspot.

correct.
You can test it from home if you want. Just open the developer tools - states and set a state on the device tracker and it should trigger the automation. (set “home” to “not_home” or “at Santas factory”, it doesn’t matter. Any state change will do)
But the in_area should say true if you are in that country and false if you are not.

But you are probably right with the first sentence. I’m just thinking of ways to make it one automation sequence do both.

If in_area is true and boolean is false (assuming boolean means you are working) then we know you have just crossed the border to work country, right?
if in_area is false and boolean is true then you just crossed the border going home?

Yeah about like that. I figured if the boolean is true and the in_area is true I’m at work. If the in_area and the boolean are false then I’m heading home…if going west…

I think these two variables would be enough to know what direction you are going.
I have a feeling the course will not work as expected. But lets see…

I think it’s better to trigger the action when these are not the same, meaning in_area false and boolean true because that way you know it will only trigger once (if you toggle the boolean as the action).
Triggering when both are false means anytime you are in home country can trigger the action.

This seems to do it. Had the boolean off and disconnected the course from the flow. Triggered a state change on the phone. This turned the boolean on the boolean isn’t turning back off with futher state changes. I’ll try it with the course attached, as the companion seems pretty accurate. If not maybe tie the HA proximity integration into it somehow?

[{"id":"71db559febb9523a","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"a02d0ee2b12e2e65","type":"change","z":"71db559febb9523a","name":"","rules":[{"t":"set","p":"location.lat","pt":"msg","to":"data.new_state.attributes.latitude","tot":"msg"},{"t":"set","p":"location.lon","pt":"msg","to":"data.new_state.attributes.longitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":240,"wires":[["d88bcad18b74f2d7"]]},{"id":"109512a6fec2f04c","type":"server-state-changed","z":"71db559febb9523a","name":"","server":"9405c3fe.d0a6c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.sm_s908u","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":160,"y":200,"wires":[["a02d0ee2b12e2e65"]]},{"id":"ec428b8aec2b01a9","type":"api-call-service","z":"71db559febb9523a","name":"","server":"9405c3fe.d0a6c","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.lapeer_geo"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":140,"wires":[["d3935d2b3964630f"]]},{"id":"5f638c458aab31ac","type":"api-call-service","z":"71db559febb9523a","name":"","server":"9405c3fe.d0a6c","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.lapeer_geo"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":300,"wires":[["d3935d2b3964630f"]]},{"id":"d88bcad18b74f2d7","type":"geofence","z":"71db559febb9523a","name":"","mode":"circle","inside":"both","rad":39089.81492421516,"points":[],"centre":{"latitude":40.2600359522212,"longitude":-83.3500786498189},"floor":"","ceiling":"","worldmap":false,"outputs":1,"x":420,"y":240,"wires":[["7ac182fdef4b6797"]]},{"id":"d3935d2b3964630f","type":"debug","z":"71db559febb9523a","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1040,"y":240,"wires":[]},{"id":"7ac182fdef4b6797","type":"switch","z":"71db559febb9523a","name":"In/Out Area","property":"location.inarea","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":240,"wires":[["a224b805c76b2057"],["5f638c458aab31ac"]]},{"id":"a224b805c76b2057","type":"switch","z":"71db559febb9523a","name":"Westbound","property":"data.event.new_state.attributes.course","propertyType":"msg","rules":[{"t":"btwn","v":"180","vt":"num","v2":"359","v2t":"num"}],"checkall":"true","repair":false,"outputs":1,"x":750,"y":200,"wires":[["ec428b8aec2b01a9"]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]