Problem with MQTT automation - SWITCH

Hello. First sorry if I speak bad English. I am Spanish.

I have a problem with an automation. The trigger is a value collected from an esp32 - mqtt (SWITCHBOT temperature/humidity sensor)

I can see the values ​​in HA and when the temperature and humidity change, they are displayed in Home Assistant.

Well, when the automation is triggered, it says "turned on - became unavailable"

alias: Humedad Lavadero ON
description: “”
trigger:

  • type: temperature
    platform: device
    device_id: 5bd8ffae72ee56fff3d041147c2ca2d4
    entity_id: sensor.lavadero_temperature
    domain: sensor
    above: 40
    action:
  • type: turn_on
    device_id: 677456cacf3a1ec9a42184dbb4f7db69
    entity_id: switch.deshumificador_lavadero_socket_1
    domain: switch
    mode: single

I have also tried to create the sensor again in configuration.yaml and fire it

alias: Humedad Lavadero ON
description: “”
trigger:

  • platform: mqtt
    topic: switchbot/esp32PASILLO/meter/Lavadero/attributes
    encoding: “”
    condition:
  • “{{ trigger.payload_json.hum | int > 40 }}”
    action:
  • type: turn_on
    device_id: 677456cacf3a1ec9a42184dbb4f7db69
    entity_id: switch.deshumificador_lavadero_socket_1
    domain: switch
    mode: single