Template sensor using an input text as parameter

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?

    value_template: >-
      {{ is_state(states('input_text.parameter_main_mobile_device'), 'work') }}

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”:

Screenshot 2024-08-09 at 14.14.53

Do you know if I need to enter it differently when doing it via the UI?

Thanks so much!