axydas
(Andreas)
February 13, 2024, 10:59am
1
Hi guys,
I want to have a binary sensor that is on if a person is at work and off if he is not. But i want the script to be based on an input text parameter.
I created an input text parameter:
input_text.parameter_main_mobile_device equal to device_tracker.samsung_z_fold
The template sensor that i created is the following:
platform: template
sensors:
person_work:
friendly_name: "Person Work"
icon_template: hass:account-multiple-check
value_template: >-
{{ is_state('input_text.parameter_main_mobile_device', 'work') }}
But the sensor is always off. Can you please help me?
koying
(Chris B)
February 13, 2024, 12:14pm
2
value_template: >-
{{ is_state(states('input_text.parameter_main_mobile_device'), 'work') }}
Troon
(Troon)
February 13, 2024, 1:04pm
3
Also, that should be a binary sensor.
platform: template
binary_sensors:
person_work:
friendly_name: "Person Work"
icon_template: hass:account-multiple-check
value_template: "{{ is_state(states('input_text.parameter_main_mobile_device'), 'work') }}"
Or better still, in modern configuration :
template:
- binary_sensor:
- name: "Person Work"
icon: hass:account-multiple-check
state: "{{ is_state(states('input_text.parameter_main_mobile_device'), 'work') }}"
1 Like
Hey @Troon this looks exactly like what I’m trying to do but I am creating the Template Binary Sensor from the UI and when I enter your line of code into the “State Template” field it still always shows the sensor as “off” even though my input_text.kitchendeckllm is set to “yes”:
Do you know if I need to enter it differently when doing it via the UI?
Thanks so much!