I’m trying to get a template sensor to figure out which of my 3 Wifi APs my ESPHome nodes are connected to, using the new wifi_info text sensor in ESPHome. The sensor sensor.basement_bssid retruns the MAC address of the ap which the node is connected to.
Yes of course that should be is_state, however it still doesn’t work, I’m wondering if there is something else that is also missing or wrong in my code, it kinda returns the same error message if I use is_statestate or states.
I have limited experience with templating so it’s not obvious to me where, but likely in the in the if statements somewhere. I see the code highlighting in the forum is not coloring the last is_state text red, not sure if that is significant(?)
Error:
ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token 'end of statement block', got 'is_state') for dictionary value @ data['sensors']['ap_convert']['value_template']. Got "{% if is_state('sensor.basement_bssid', '80:2A:A8:11:95:BF') %}\n AP_AC_LITE\n{% elif is_state('sensor.basement_bssid', 'b4:fb:e4:46:89:53') %}\n AP_AC_PRO\n{% else is_state('sensor.basement_bssid', 'f0:9f:c2:cb:3a:58') %}\n AP_AC_LR\n{% endif %}\n\n# {% if is_state('sensor.sensor.basement_bssid', '80:2A:A8:11:95:BF') %} # AP_AC_LITE # {% else is_state('sensor.basement_bssid', 'b4:fb:e4:46:89:53') %} # AP_AC_PRO # {% elif is_state('sensor.basement_bssid', 'f0:9f:c2:cb:3a:58') %} # A.... (See /config/sensor/template.yaml, line 80). Please check the docs at https://home-assistant.io/components/sensor.template/