Creat automation

I want to creat automation to run every 30 seconds.
By taking the power value from the smart meter to turn on and off other devices According to the following conditions
if smart meter value between 100-200 w
open device 1
else <100
off device 1
endif

How do I need to create it? Please advise me.

Thank you.

trigger:

platform: time_pattern
seconds: /30
1 Like

and this condition ?
if smart meter value between 100-200 w
open device 1
else <100
off device 1
endif

That is not a condition. That is an action. Easiest way will be two automations.

trigger:
  - platform: numeric_state
    entity_id: sensor.your_power_meter_here
    above: 99
    below: 201
action:
  - service: switch.turn_on
    entity_id: switch.your_switch_here
trigger:
  - platform: numeric_state
    entity_id: sensor.your_power_meter_here
    below: 100
action:
  - service: switch.turn_off
    entity_id: switch.your_switch_here
1 Like