Hi everyone,
I’m fiddling around with espresense and room tracking.
I have all my nodes and my devices setup, i can see the sensor for each Device going from room to room.
IT works really nice.
But I’m stuck! I’m new to this kind of automation.
I’d like to trigger an automation with a condition like “IF sensor is in room1 do this and that, if not
do the other thing”.
The sensors have only one attribute: distance.
How can i setuo a template or helper (thinking about a boolean for each room) to use as trigger and/or condition?
Use a state trigger on the mqtt_room sensor. Here’s an example that triggers when the state changes to “office” and sets the trigger id to “in_office” which I use in a choose action to turn on the fan if it’s over 80 degrees outside.
trigger:
- platform: state
entity_id:
- sensor.example
id: in_office
for:
hours: 0
minutes: 1
seconds: 0
to: office
The sensor in your code is the “template sensor” of the link or the espresense sensor (for the Device that is sending the beacon) i created in configuration.yaml?
Because I’d like to link the automation on one specific Device, not to room occupation.
It is the device sending the beacon. I have not created any template sensors, nor have I used any sensors created by the espresense receivers. Just the beacon sensors like phone, watch, or BLE tag.
Here’s the sensor configuration in configuration.yaml
No problem. The device_id example posted above is using the alias feature of espresense, otherwise it would be the long ibeacon string. I use it to shorten the device id so I can add more of them to the filters configuration of espresense. I find that feature as one of the best features over the ESPHome BLE proxy and iBeacon integrations.
You don’t need to use it at all, if you don’t have a driving need, I wouldn’t bother. It simply is a change of device_id string to Home Assistant. Don’t add complications. I just wanted to explain why my device_id doesn’t say ibeacon:xxxx
The Espresense web site, like many that change features rapidly, don’t keep up with documentation well. There are discussions about the feature in the github repository.
This creates sensor.example who’s state will either be not_home, or the name of the room it’s closest to. This is the sensor you will use to trigger automations.
Please provide your sensor configuration under the mqtt_room key like my example above. Also, what is the state of the sensor as shown in developer tools?
OK, because you didn’t post the developer tools details I can only assume the entity_id is “sensor.tome”. That is what you should be using in the automation, not the device_id. If that isn’t the actual entity_id, post the complete details from developer tools.