Passing argument from automation to script issue

I’m new to HA and a bit confused. I’m building a chicken brooder box with a generic thermostat controlling a heat lamp. I’m trying to build a configuration that will decrease the temperature of the thermostat 0.5 degrees a day at a specific time. Here’s the automation & script that I’ve figured out so far - I’m struggling with passing the current climate.brooder_box thermostat temperature to the script so I can make the new temp calculation and set it. Any help would be fantastic - Thank you!

Automation YAML

alias: Brooder Temp Decrease
description: Trigger Brooder Temp Decrease Script
trigger:
    -platform: time
    at: '14:00:00'
condition:
    -condition: state
    entity_id: climate.brooder_box
    state: 'on'
    -condition: and
    conditions:
        -condition: numeric_state
        entity_id: input_nmber.brooder_delay
        below: '1'
    action:
    - service: script.brooder_temp_decrease
    data: 
        entity: climate.brooder_box.temperature
    mode: single

Script YAML

 brooder_temp_decrease:
    alias: Brooder Temp Decrease
    sequence:
    - service: climate.set_temperature
    target:
        entity_id: climate.brooder_box
    data: 
        temperature: {{climate.brooder_box.temperature | float - 0.5}}
    mode: single

Because the scrip is so simple, why not do it all in the automation itself?

Also, there seems to be issues with the indentation and formatting of the automation… Think it should be

alias: Brooder Temp Decrease
description: Trigger Brooder Temp Decrease Script
trigger:
  - platform: time
    at: '14:00:00'
condition:
  - condition: state
    entity_id: climate.brooder_box
    state: 'on'
  - condition: numeric_state
    entity_id: input_number.brooder_delay
    below: '1'
action:
  - service: climate.set_temperature
    target:
      entity_id: climate.brooder_box
    data: 
      temperature: "{{ state_attr('climate.brooder_box', 'temperature')|float - 0.5 }}"
mode: single
``

That’s amazing! Because I’m a noob and thought I could only do calculations in scripts.

@septillion Thanks again!

I have a slider input number in my interface. I’d like to do something like this:

{{ state_attr('climate.brooder_box', 'temperature')|float - (state_attr('input_number.temp_drop_per_week', 'value')|float /7)}}

It’s even simpler :smiley:

{{ state_attr('climate.brooder_box', 'temperature')|float - (states('input_number.temp_drop_per_week')|float /7)}}