Hello everyone. I have an mqtt entity called sensor.movimiento_pasillo this returns a json with several values
{"illuminance":25,"illuminance_lux":25,"linkquality":72,"occupancy":true}
I can’t put together a template to be able to have, for example, occupancy as a new entity.
Could you explain to me how to do it?
Thank you so much
Troon
(Troon)
2
This template sensor config should work. It uses the bool
function described in this section:
template:
- binary_sensor:
- name: Occupancy Pasillo
state: "{{ bool(state_attr('sensor.movimiento_pasillo', 'occupancy')) }}"
device_class: occupancy
- sensor:
- name: Illuminance Pasillo
state: "{{ state_attr('sensor.movimiento_pasillo', 'illuminance_lux') }}"
unit_of_measurement: 'lx'
device_class: illuminance
- name: Link quality Pasillo
state: "{{ state_attr('sensor.movimiento_pasillo', 'linkquality') }}"
That goes into configuration.yaml
— make sure you only have one template:
heading.
Thanks my friend. It was very helpful