Automation dealing with temperature when lights are on and off

Hello all,

sorry I am a noob at all of this and am getting a little frustrated. Ive read the documentation and the more I read and try to follow, the more complex things tend to get. I would love to have my zigbee temp sensors check every time to see if the lights on or off, if the status of my light is on, and the temperature is below 75f, turn my heater switch on. The same for if the lights off but temperature below 65, turn the heater on. I had one that was semi working but the heater would never turn off:

Trying to improve it I came up with this:

alias: Temperature Control
description: Adjust heater based on light status and temperature
triggers:
  - entity_id: sensor.a48d3723d3a04730169b2441722ad156
    below: 80
    above: 50
    trigger: numeric_state
  - entity_id: sensor.2aaa61136557ecc23bfc7e56a92d4eb8
    below: 80
    above: 50
    trigger: numeric_state
  - entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
            state: "on"
          - condition: numeric_state
            entity_id: sensor.a48d3723d3a04730169b2441722ad156
            below: 80
        sequence:
          - target:
              entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
            action: switch.turn_on
            data: {}
      - conditions:
          - condition: state
            entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
            state: "off"
          - condition: numeric_state
            entity_id: sensor.a48d3723d3a04730169b2441722ad156
            below: 65
        sequence:
          - target:
              entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
            action: switch.turn_on
            data: {}
  - target:
      entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
    action: switch.turn_off
    data: {}
mode: single

Please note, I upped the temperature to 80 to test (as the lights on and the temperature right now is 77):

alias: Temperature control
description: Low 60, high 70
triggers:
  - type: temperature
    device_id: 57dbd068f3a37fd49ae6c158fe7d4143
    entity_id: a48d3723d3a04730169b2441722ad156
    domain: sensor
    below: 73
    above: 50
    trigger: device
  - type: temperature
    device_id: 58b23f6d7d7eb6ae9f21c4d73ca6b704
    entity_id: 2aaa61136557ecc23bfc7e56a92d4eb8
    domain: sensor
    below: 73
    above: 50
    trigger: device
conditions:
  - condition: device
    type: is_on
    device_id: d9f01304fdba20139d0f783b31c41240
    entity_id: e7d17ac9bcc98989d9de963f6aa74feb
    domain: switch
    enabled: false
actions:
  - type: turn_on
    device_id: 75887b41474e0a17ef4c7a528d3c6b11
    entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
    domain: switch
mode: single

You can use empty values for the to key to have the automation trigger on every state change of the two temperature sensors:

alias: Temperature Control
description: Adjust heater based on light status and temperature
triggers:
  - entity_id: 
      - sensor.2aaa61136557ecc23bfc7e56a92d4eb8
      - sensor.a48d3723d3a04730169b2441722ad156
    to: 
    trigger: state
  - entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
    trigger: state
    to:
      - 'on'
      - 'off'
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
            state: "on"
          - condition: numeric_state
            entity_id: sensor.a48d3723d3a04730169b2441722ad156
            below: 80
        sequence:
          - target:
              entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
            action: switch.turn_on
            data: {}
      - conditions:
          - condition: state
            entity_id: switch.e7d17ac9bcc98989d9de963f6aa74feb
            state: "off"
          - condition: numeric_state
            entity_id: sensor.a48d3723d3a04730169b2441722ad156
            below: 65
        sequence:
          - target:
              entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
            action: switch.turn_on
            data: {}
  - target:
      entity_id: switch.fdf1f4f6c68df0f6cbad0e32aed127b3
    action: switch.turn_off
    data: {}
mode: single

Interesting, I am looking at the documentation for the to: section and not sure where I eer would have figured this out.

Thank you, Ill give it a go and let you know how things turn out.

Unfortunately @Didgeridrew this just causes more confusion. I am in the discord and people are telling me to just use the GUI. which isnt working well either