DHT sensor to trigger switch automation head scratcher

I don’t understand why I am struggling with this automation, it seems like a really easy, straight forward automation but as so often is the case…it won’t work! :rage:

I am trying to trigger a switch with a sensor and even though I have copied and pasted the YAML entries from the configuration examples I am getting an “Invalid config” message

2017-05-23 17:33:27 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [entity_id] is an invalid option for [automation]. Check: automation->trigger->0->entity_id. (See /home/homeassistant/.homeassistant/configuration.yaml, line 140). Please check the docs at Automation - Home Assistant

Both the sensor and the switch are working well independently.
My YAML entry is:

automation:
trigger:
platform: mqtt
entity_id: sensor.btr_humidity
value_template: ‘{{ value_json.humidity }}’
above: 60
below: 99
action:
service: light.turn_on
entity_id: switch.mvhr

What have I done wrong this time?

Difficult to say without proper spacing, can you use the code blocks <> in the edit box

For MQTT trigger you need a topic, from your setup it looks like you already configured a MQTT sensor (sensor.btr_humidity). If not follow instructions here https://home-assistant.io/components/sensor.mqtt/ . A sensor can be anything that gets data, like from a MQTT topic. i think you are looking for numeric state trigger for a sensor:

automation:
  trigger:
    platform: numeric_state
    entity_id: sensor.btr_humidity
    above: 60
    below: 99
  action:
    service: light.turn_on
    entity_id: switch.mvhr
1 Like

Thank you debsahu! The “numeric_state” platform has resolved the config error so that’s a result.
The sensor readings are being displayed on my HA page and I think I just got the automation to trigger the switch after making the changes to my YAML but my HA is playing up at the moment so I will try reboot everything and do a little testing in the coming days.
Thank you so much for taking the time to respond, very much appreciated!