u/DeadDog818

Hi all. I'm a bit new to esphome and looking for advice and tips from people who are better at this than I am.

I want to control an electric fireplace using esphome. This involves an effect light and a heater. The heater has two stages which I'm going to control using two SSRs.

On the software side - I want to ensure that the SSRs and heater elements are not racked on and off rapidly by accident. I'm trying to ensure that there is at least a 3 second delay between operations on the relays. In my config the relays will be controled by level1 and level2.

The closest I've come to acheiving what I want is to use a script in single mode. This nicely blockes other calls while the delay is running. The biggest problem with it is that the slider control can be left out of sync with the state of the relays.

Is anyone able to help me up my esphome game?

number:
  - platform: template
    id: heater_state
    name: Heater
    icon: mdi:radiator
    min_value: 0
    max_value: 2
    step: 1
    mode: SLIDER
    optimistic: True
    on_value:   
      - script.execute: heater_set


script:
  - id: heater_set
    mode: single
    then:
      - lambda: |-
          if (id(heater_state).state == 2){
            id(level1).turn_on();
            id(level2).turn_on();
          } 
          else if (id(heater_state).state == 1){
            id(level1).turn_on();
            id(level2).turn_off();
          } else {
            id(level1).turn_off();
            id(level2).turn_off();
          }
      - delay: 3s   


light:
  - platform: binary
    name: fireplace_light
    icon: mdi:fireplace
    id: light_1
    output: fireplace_light_output


output:
  - platform: gpio
    pin: GPIO32
    id: level1
  - platform: gpio
    pin: GPIO33
    id: level2
  - platform: gpio
    pin: GPIO25
    id: fireplace_light_output
reddit.com
u/DeadDog818 — 7 days ago