2.5PM automation trouble

Hi,

I’m trying to use a IKEA Vindstyrka to warn me and the children when someone is smoking outside of their bedroom. The room and apartment fills up with smoke so fast and I wan’t to prevent that by lighting up two lamps we can easily notice.

But, how do I fill in the automation to turn the lamps on at one threshold, and then turn of when the sensor goes beneath the threshold?

My code after using the automation fields look like this now:

alias: Smoke warning
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.ikea_pm2_5_pm2_5
    above: 30
  - platform: numeric_state
    entity_id:
      - sensor.ikea_pm2_5_pm2_5
    below: 20
condition: []
action:
  - service: light.turn_on
    metadata: {}
    data:
      color_name: red
      brightness_pct: 100
      flash: long
    target:
      device_id:
        - e19caaf858db4802d92b2bac8271529e
        - 812d97b6b05244de1a6f697051176cf7
mode: single

The lamps turn of, but how to I get them to turn off? The lower threshold has no connection to a “off” code?

As I am reading the code now, I will get the lamps to turn on both when the sensor reads above 30, but also beneath 20?

Helpful for any input! :slight_smile:

Give your triggers and id. Then use a choose on trigger.id to decide what to do when each one happens.

Sounds great! I’m really a noob at code, is there a example of this to see somewhere?
If not, I’ll just google around and search.

Thanks! :slightly_smiling_face:

Add the ids

trigger:
  - platform: numeric_state
    entity_id:
      - sensor.ikea_pm2_5_pm2_5
    above: 30
    id: 'on'
  - platform: numeric_state
    entity_id:
      - sensor.ikea_pm2_5_pm2_5
    below: 20
    id: 'off'

Then, in your action, you can check the id with either if statements, choose, etc. The id can also be added in the UI using the three dot menu on the trigger.

You can build the choose or if in UI. It will give an option for trigger.id in the choose or if condition.

1 Like

Thank you for the help!

1 Like