ESPHome no automatic state update to dashboard

Hi, I’m having a problem,

I’m using ESPHome and everything works fine, I can control my relay from the HA dashboard, but when the relay change its state from the device itself, it doesn’t update the new state to the dashboard.
Could anyone help please?

It seems like it’s a one way communication, wich is false since I can get the temperature on my dashboard.

Her’s my config (on a pico w)

#Temperature
dallas:
  - pin: GPIO22
    update_interval: 5s

sensor:
  - platform: dallas
    address: 0x6b0301a279658b28
    name: "temp_in" #with resistance
    id: "temp_in"
  - platform: dallas
    address: 0x8d0301a279dd0728
    name: "temp_out"
    id: "temp_out"
    on_value:
        then:
          - script.execute: ventilation


#Ventilation
output:
  - id: fan_output
    platform: gpio
    pin: GPIO21

fan:
  - platform: binary
    output: fan_output
    name: "Ventilation Cave"


script:
  - id: ventilation
    then:
      - if:
          condition:
            lambda: |-
              return id(temp_in).state >= id(temp_out).state + 0.5;
          then:
            - output.turn_on: fan_output
      - if:
          condition:
            lambda: |-
              return id(temp_in).state <= id(temp_out).state;
          then:
            - output.turn_off: fan_output

image
Here i clicked to toogle the fan relay, the relay turns on correctly, then it turns off because of my config (wich is normal) but stays on here, same problem the other way

Thanks to Sebastian from the ESPHome Discord, i’ve been able to make it work
Here’s the new code if it can help anyone!

#Temperature
dallas:
  - pin: GPIO22
    update_interval: 5s

sensor:
  - platform: dallas
    address: 0x6b0301a279658b28
    name: "temp_in" #with resistance
    id: "temp_in"
  - platform: dallas
    address: 0x8d0301a279dd0728
    name: "temp_out"
    id: "temp_out"
    on_value:
        then:
          - script.execute: ventilation


#Ventilation
output:
  - id: fan_output
    platform: gpio
    pin: GPIO21

fan:
  - platform: binary
    output: fan_output
    name: "Ventilation Cave"
    id: "fan1"





script:
  - id: ventilation
    then:
      - if:
          condition:
            lambda: |-
              return id(temp_in).state >= id(temp_out).state + 0.5;
          then:
            - fan.turn_on: fan1
      - if:
          condition:
            lambda: |-
              return id(temp_in).state <= id(temp_out).state;
          then:
            - fan.turn_off: fan1