Automation - trigger with FOR X minutes

Hello!

I’m trying to make an automation to detect if server CPU is above 85% for 5minutes. If that happens, notify my via telegram bot. The script works if i comment out the FOR part.

This is the error:

ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->trigger->0->for. (See /home/hass/.homeassistant/automation.yaml:0). Please check the docs at Automation - Home Assistant

The code:

   - alias: Server Overloaded
  hide_entity: false

  trigger:
    platform: numeric_state
    entity_id: sensor.cpu_use
    above: '85'
    for:
      hours: "0"
      minutes: "10"
      seconds: "0"
  action:
    - service: notify.vollarisnotifier
      data:
        message: Server is overloaded!

Any help would be appreciated!

Try taking the quotes off of your numbers. Quoting them has them interpreted as strings.

Not sure that numeric trigger has time conditions. You can use intermediate Boolean input. Change it’s state to on/off depends on CPU usage and another trigger with state on for X minutes

It doesn’t but there is a feature request you can vote on and the post lists some alternative approaches:

1 Like