Hello,
I’ve configured espresense to track iBeacons:
sensor:
- platform: mqtt_room
name: "x"
device_id: "x"
state_topic: "x"
away_timeout: x
This works like a charm, though I can’t assign this sensor
entity to a person. It seems only device
entities can be assigned:
Does anyone know how can the sensor
entity be used with users, or perhaps a way of converting it into a device, so it can be assigned to users?
UPDATE: Here’s the final solution, with templating to work in a single automation:
alias: "Presence: Beacons"
description: ""
trigger:
- platform: state
entity_id:
- sensor.charlie_beacon
- sensor.foxtrotdelta_beacon
- sensor.mikedelta_beacon
enabled: true
condition: []
action:
- service: device_tracker.see
data:
dev_id: "{{ trigger.entity_id.split('.')[1] }}"
location_name: |
{% set locations = ['hallway', 'living_room', 'work_room'] %}
{% if trigger.to_state.state in locations %}
home
{% elif trigger.to_state.state not in locations %}
not_home
{% else %}
unknown
{% endif %}
source_type: router
mode: restart
1 Like
The person entity connects to device trackers whereas these are mqtt rooms (Person - Home Assistant )
I’ve not used it with ESPresence but I use my wifi to post MQTT messages to a specific MQTT Device Tracker. There is nothing stopping you doing a similar route based on the esprence room - MQTT Device Tracker - Home Assistant
For my use case, I post to the relevant topics based on my phone connecting to our wifi as a backup to other presence sensors.
Looking in this thread:
Thanks for your quick solution. If i get this right, I need an existing device_tracker.tracker1 entity id and the above automation just changes its state, right?
I’ve created an automation that creates a device_tracker entity which updates when the sensor updates:
alias: "Presence: Beacon X"
description: ""
trigger:
- platform: state
entity_id:
- sensor.x_beacon
condition: []
action:
- service: device_tracker.see
data:
dev_id: x_beacon
location_name: |
{% if trigger.to_state.state == 'home' %}
home
{% elif trigger.to_state.state == 'not_home' %}
not_home
{% else %}
unknown
{% endif %}
source_type: router
mode: single
max: 10
I have a few of these, and they can probably be merged into a single automation with templates, but I’m not that proficient yet with jinja.
victoroos
(Victor Roos)
December 1, 2022, 3:29pm
4
sorry for digging this up, I also have ESPresence, I get a UndefinedError: ‘trigger’ is undefined
with this:
alias: Presence Giga Flo based
description: ""
trigger:
- platform: state
entity_id:
- sensor.flo_esp_beacon
condition: []
action:
- service: device_tracker.see
data:
dev_id: giga.flo
location_name: |
{% if trigger.to_state.state == 'home' %}
home
{% elif trigger.to_state.state == 'not_home' %}
not_home
{% else %}
unknown
{% endif %}
mode: single
max: 10
edit: aah wait, it has to change itself…, hmm
@victoroos Not sure why it doesn’t work for you, I use a bluceharm beacon
victoroos
(Victor Roos)
December 20, 2022, 11:32am
6
I was an idiot, I had two sensor “headings” in my yaml. Learning while doing this is called ^^
jimmyeao
(Jimmy White)
July 13, 2023, 1:30pm
7
This fixed my problem, but I track by rooms not if Is_home so I ended up with this:
> alias: "Presence: Beacon Jimmy watch"
> description: ""
> trigger:
> - platform: state
> entity_id:
> - sensor.jimmy_s_watch_ble
> condition: []
> action:
> - service: device_tracker.see
> data:
> dev_id: jimmy_s_watch_ble
> location_name: >
> {% if trigger.to_state.state in ['home', 'office', 'kitchen', 'bedroom',
> 'lounge', 'ryan', 'diningroom','backhall', 'hall'] %}
> home
> {% elif trigger.to_state.state == 'not_home' %}
> not_home
> {% else %}
> unknown_room
> {% endif %}
> source_type: router
> mode: single
> max: 10
Notice every “Room” that I have in espresense is listed in location_name:
So now sensor.jimmy_s_watch_ble
reports the room, and device_traker:jimmy_s_watch_ble
reports if it is home or not. If II add a room and forget to add it here, Ill get a presence of “unknown_room” to remind me when my device is in that room
3 Likes
Hi @jimmyeao ,
Thanks for the great automation. Why do you use
mode: single
I thought about queuing here…
Thanks!
jimmyeao
(Jimmy White)
March 11, 2024, 8:53am
9
I’m not sure I remember why, only that I saw it in an example!