Invalid data for call_service at pos 1: must contain at least one of temperature, target_temp_high, target_temp_low

I am working on automations to control my thermostat temp when the wife and I leave home and get home. I based them off ones I have to change the temp at night and in the morning. The problem is, I get “Invalid data for call_service at pos 1: must contain at least one of temperature, target_temp_high, target_temp_low.” when trying out the ones I have worked on so far. Here is one of the non-working automations as it sits right now.

alias: CT101 Heat Set Home
initial_state: True
trigger:
  platform: state
  entity_id: group.thermostatdevices
  from: 'not_home'
  to: 'home'
condition:
  - condition: state
    entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
    state: heat
action:
  - service: climate.set_temperature
    data_template:
      data: >
        {% if (strptime((states.sensor.time.state),"%H:%M") >= strptime(("22:00"),"%H:%M") and strptime((states.sensor.time.state),"%H:%M") < strptime(("07:30"),"%H:%M")) %}
          entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
          temperature: "{{ states('input_number.heat_set_point_home_night') }}"
        {% elif (strptime((states.sensor.time.state),"%H:%M") >= strptime(("07:30"),"%H:%M") and strptime((states.sensor.time.state),"%H:%M") < strptime(("22:00"),"%H:%M")) %}
          entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
          temperature: "{{ states('input_number.heat_set_point_home_day') }}"
        {% else %}
          entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
          temperature: "{{ states('input_number.heat_set_point_home_night') }}"
        {% endif %}
  - service: notify.mobile_app_Shaun_iPhone
    data:
      title: "Home"
      message: "Lowering heat due to phones getting home"
  1. You have too many data & data template sections.
  2. You can’t template fields the way you are templating them. Even then you don’t need to template both fields, only the temperature field.
  3. Your time comparisons are a bit over complicated.
  4. Your first if statement is wrong, needs to be ‘or’ not ‘and’
  - service: climate.set_temperature
    data_template:
      entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
      temperature: >
        {% if states('sensor.time') >= '22:00' or states('sensor.time') < '07:30' %}
          {{ states('input_number.heat_set_point_home_night') }}
        {% elif '07:30' <= states('sensor.time') < '22:00' %}
          {{ states('input_number.heat_set_point_home_day') }}
        {% else %}
          {{ states('input_number.heat_set_point_home_night') }}
        {% endif %}

Also, based on your logic, you could simplify this to

  - service: climate.set_temperature
    data_template:
      entity_id: climate.radio_thermostat_company_of_america_ct101_thermostat_mode
      temperature: >
        {% if '07:30' <= states('sensor.time') < '22:00' %}
          {{ states('input_number.heat_set_point_home_day') }}
        {% else %}
          {{ states('input_number.heat_set_point_home_night') }}
        {% endif %}

Thank you. Not sure why my other automations work then (or maybe they don’t now and I just think they do).