Numeric_state and MQTT trigger - beginners question

Hi! I have my own MQTT server which fires me info about intensity of light. It just publishes numeric (int, 0 - no light, >20 some light) data on specific topic. I’m trying to use that value to trigger some event:

- alias: Wentylator on
      above: 20
      entity_id: sensor.swiatlo_w_lazience
      platform: numeric_state
      service: switch.turn_on

and it doesn’t trigger…

Configuration for that is:

sensor 5:
  platform: mqtt
  state_topic: "MyMQTT/26/13/V_LIGHT_LEVEL"
  name: "Światło w łazience"
  qos: 0
  unit_of_measurement: "lx"

How do I do that properly? I was trying to use some templates (both in sensor and in trigger definition) suspecting the problem with JSON payload but it seems I get it wrong. How can I see how exactly JSON data for the even looks like?

Go to the States page (Developer Tools > States), find sensor.swiatlo_w_lazience, and tell me its current state value (it should be a numeric value).

While you are viewing the States page, find automation.wentylator_on and confirm its state is on.

Taras, automation.wentylator_on was off. I was totally mislead by that switch. I I thought it turns on when automation is triggered. Is that documented?!

Thanks for the help!!!

1 Like