Input number as variable for condition based time value for presence detection


I have some presence detection units which after a period of time of inactivity, switch off devices like lights etc… So far I have 2 automations, 1 for during the day and another for evening times where the rule for how long to wait for inactivity varies between the two.

what I wanted to do is add in more granularity for times across the day to vary this even more.

I have created input_numbers to hold the specific values of change for minutes and seconds for the 5 conditions but it seems the code I have written does not work. Im not sure why as am new to the template scene.

Any pointers on what I can do to achieve the desired output?

Here is what I have now.

type: no_motion
platform: device
device_id: 65ggccc01234kjdvfc60a140900dff
entity_id: binary_sensor.hall_sensor
domain: binary_sensor
  hours: 0
  {% if is_state('binary_sensor.Morning', 'on') %}
  minutes: '{{ states('input_number.hall_noactivity_morning_min')|float }}'
  seconds: '{{ states('input_number.hall_noactivity_morning_sec')|float }}'
  {%  elif is_state('binary_sensor.Late_Morning', 'on')%}
  minutes: '{{ states('input_number.hall_noactivity_latemorning_min')|float }}'
  seconds: '{{ states('input_number.hall_noactivity_latemorning_sec')|float }}'
  {%  elif is_state('binary_sensor.Afternoon', 'on')%}
  minutes afternoon: '{{ states('input_number.hall_noactivity_afternoon_min')|float }}'
  seconds: '{{ states('input_number.hall_noactivity_afternoon_sec')|float }}'
  {%  elif is_state('binary_sensor.Evening', 'on')%}
  minutes evening: '{{ states('input_number.hall_noactivity_evening_min')|float }}'
  seconds: '{{ states('input_number.hall_noactivity_evening_sec')|float }}'
  {% endif %} 
  milliseconds: 0


I’m no templating expert, but you’ve got a lot of single quotes inside single quotes there which won’t render correctly. Try using double quotes at the start and end and single quotes inside. I also don’t think you can have minutes afternoon and minutes evening. Has to just be minutes.