#Person Tracking for Room + Home/Away

1 messages · Page 1 of 1 (latest)

frigid echo
#

Has anyone got an elegant way of tracking a persons location using MQTT Room and the Companion App?

In HA i have the person.dave tracker which comes from the companion app and gives Home/Away etc

I then have MQTT Room, that tracks the same Companion Apps Bluetooth Beacon.

What I ultimately want though is a field in HA that basically does:

If user is home, show the room they are in from MQTT Room, else, show companion app status

violet light
#

I'm sure it can all be done but we'd need to see the states of things because you likely need templates

frigid echo
#

So i had a play, and i think i managed something in Node-Red

person.greg

person: "home"
data: object
topic: "person.greg"
_msgid: "a1267f3b66553540"
beacon: "not_home"

sensor.greg_phone_beacon

beacon: "not_home"
data: object
topic: "sensor.greg_phone_beacon"
_msgid: "f8c5031cb0a3b740"
person: "home"

Then i have some javascript to do:

let dev_id;
const person = msg.person;
const beacon = msg.beacon;
let zone = "unknown"

if(msg.topic.includes("greg")) dev_id = "greg"
if(msg.topic.includes("rach")) dev_id = "rach"

// node.warn(zone)

if(person === "not_home") {
    zone = person
} 
else if (beacon !== "not_home"){
    zone = beacon
} else {
    zone = person
}


// node.warn(zone)

msg.payload = {
    domain: 'device_tracker',
    service: 'see',
    data: {
        dev_id: dev_id,
        location_name: zone
    }
}
    
return msg;

Maybe theres a more elegant way?

violet light
#

no idea cause you aren't sharing the entities

#

this is most likely a 1 liner template entity.

#

We don't know what I then have MQTT Room, that tracks the same Companion Apps Bluetooth Beacon is or means

#

so no one can help you

frigid echo
#

the entities are at the top of my reply?

#

person.greg
State = Home or Away (or a HA Zone)

sensor.greg_phone_beacon
State = Dressing Room, Living Room (whatever the last room it tracked me in was)

#
sensor:
  - platform: template
    sensors:
      greg_status:
        friendly_name: "Greg's Status"
        value_template: >
          {% if is_state('person.greg', 'home') %}
            {{ states('sensor.greg_phone_beacon') }}
          {% else %}
            {{ states('person.greg') }}
          {% endif %}
violet light
#

Yes, your template entity is about as simple as it gets

signal cradle
#

bit pricey, but works like a charm

#

doesnt trigger on e specific person tho