An absolute Home Assistant noob (thats me ) needs help for accomplish my second goal using Home Assistant.
Already working:
1 - HA connection (client) to a separate MQTT broker, [installed separately] (which was first goal I achieved, https://community.home-assistant.io/t/my-first-steps-discovering-home-assistant-setting-up-a-ha-client-to-an-existing-mqtt-broker) on localhost RasPi 3+
2 - Presence detection by using Ubiquiti Unifi WAP platform
Now I have two residents showing up in my frontend when they are at home.
My goals:
- Write the status of these users to MQTT topics /HomeAssistant/present/<RESIDENT_NAME>/status
- Write a customized value to a MQTT topic /HomeAssistant/present/general/status
The general status should contain who is at home at the moment, like ‘Jane and John’ or just ‘Jane’ or just ‘Joe’.
In the Template frontend I already tested this script which looks like it is working:
{% set my_test_json = {“status”: “ERROR!”} -%}
{% if is_state(“device_tracker.mobile_john”, “home”) and is_state(“device_tracker.mobile_jane”, “home”) -%}
{% set my_test_json = {“status”: “Jane and John”} -%}
{% elif is_state(“device_tracker.mobile_john”, “not_home”) and is_state(“device_tracker.mobile_jane”, “home”) -%}
{% set my_test_json = {“status”: “Jane”} -%}
{% elif is_state(“device_tracker.mobile_john”, “home”) and is_state(“device_tracker.mobile_jane”, “not_home”) -%}
{% set my_test_json = {“status”: “John”} -%}
{% else -%}
{% set my_test_json = {“status”: “Nobody”} -%}
{%- endif -%}
Status: {{ my_test_json.status }}'
As mentioned before, I’m just starting to explore Home Assistant and HA coding.
Any help to accomplish this would be appreciated!
BTW, I used the ‘old’ way to install Home Assistant (not hass.io). Version 0.77.2.