I have two MQTT sensors, closest_aircraft
and visible aircraft
which are grouped in the same device but which are behaving differently with regard to the logbook. There are frequent state changes to both, but only changes to visible aircraft
are being logged in the logbook.
Any suggestions for how to ensure that both are logged? Could this be an issue of template construction?
Here are the configurations:
sensor:
- name: "Closest Aircraft"
state_topic: "flights/closest_aircraft"
value_template: >
{% set first_key = value_json.keys() | list | first %}
{{ value_json[first_key]['distance_value'] | float }}
unit_of_measurement: "mi"
device_class: distance
unique_id: "flights_closest_aircraft"
icon: "mdi:airplane"
json_attributes_topic: "flights/closest_aircraft"
json_attributes_template: >
{% set first_key = value_json.keys() | list | first %}
{{ value_json[first_key] | tojson }}
device:
identifiers: ["flightrack_device"] # Shared ID for grouping
manufacturer: "RS"
model: "Flights"
name: "Flighttrack"
- name: "Visible Aircraft"
state_topic: "flights/visible"
value_template: "{{ value_json['visible_aircraft'] }}"
icon: "mdi:radar"
unique_id: "flights_visible_aircraft"
json_attributes_topic: "flights/visible"
json_attributes_template: "{{ value_json | tojson }}"
device:
identifiers: ["flightrack_device"]
manufacturer: "RS"
model: "Flights"
name: "Flighttrack"
Here’s what the device view in the UI looks like:
And here is history showing the frequent state changes;