Climate Deadband, Overrun with Lambda

I want to use globals to set the deadband and overrun values as I’m using these values in several other places in my configuration. I tried doing this using Lambda but I get a message stating that this is not templatable. Is there another way to acomplish this using globals?

Here’s a snippet from my config code and a snagit of what I see in the editor.

globals:
   - id: gfDeadband
     type: float
     restore_value: yes
     initial_value: '1'
   # Example for global string variable
   - id: gfOverrun
     type: float
     restore_value: yes
     initial_value: '0.5'

climate:
  - platform: thermostat
    id: swamp_controller
    name: "Thermostat Climate Controller"
    sensor: temperature
    humidity_sensor: humidity
    visual:
      min_temperature: 65 °F
      max_temperature: 90 °F
      temperature_step: .1 °F
    on_boot_restore_from: DEFAULT_PRESET
    min_cooling_off_time: 10s
    min_cooling_run_time: 10s
    min_idle_time: 10s
    cool_action:
      - script.execute: cool_low
    idle_action:
      - script.execute: cool_off
    default_preset: "p1_80°F"
    preset:
      - name: "p1_80°F"
        default_target_temperature_high: 80.0 °F
        mode: COOL
      - name: "p2_75°F"
        default_target_temperature_high: 75 °F
        mode: COOL
      - name: "p3_73°F"
        default_target_temperature_high: 73 °F
        mode: COOL
    startup_delay: True
    # cool_deadband: 1 °F
    # cool_overrun: .5 °F
    cool_deadband: !lambda "return id(gfDeadband);"
    cool_overrun: !lambda "return id(gfOverrun);"

2024-09-02_14-22-27

Would substitutions work or do you need to be able to change them during operation?

Great, thanks for the tip. No, I don’t need to change them during operation so I should be able to make Substitutions work.

I put some Substitions in and they worked perfectly. Thanks again.

1 Like