Trying to have the hassio react on the UPS

I have a UPS connected to my NAS, and it’s also powering the switch etc.
The homeassistant gets the status fine from the NAS via NUT.
But my automation doesn’t trigger.

The sensors looks like this:

  - platform: nut
    name: UPS Battery backup
    host: 1.2.3.4
    resources:
      - ups.status.display
      - ups.load
      - ups.realpower.nominal
      - ups.mfr
      - ups.model
      - input.voltage
      - battery.charge
      - battery.runtime
  - platform: template
    sensors:
      upsruntimemins:
        friendly_name: "UPS Runtime"
        unit_of_measurement: "m"
        value_template: "{{ ( states('sensor.ups_battery_backup_battery_runtime') | int / 60 ) | round(0) }}"
  - platform: template
    sensors:
      upsstate:
        friendly_name: "UPS State"
        value_template: >-
          {% if is_state('sensor.ups_battery_backup_status', 'Online') %}
            Online
          {% elif is_state('sensor.ups_battery_backup_status', 'On Battery Battery Discharging') %}
            On Battery
          {% endif %}

My automation looks like this:

- id: '1560506535380'
  alias: Alert - Poweroutage
  trigger:
  - entity_id: sensor.upsstate
    for: 00:00:10
    from: Online
    platform: state
    to: On Battery
  condition: []
  action:
  - data:
      message: Der er ikke strøm til serverne i øjeblikket, de lukker ned om 20 min
      title: Strømafbrydelse
    service: notify.webpush
  - data:
      message: Der er ikke strøm til serverne i øjeblikket, de lukker ned om 20 min
      title: Strømafbrydelse
    service: persistent_notification.create

But when I make it go to the battery, the automation doesn’t trigger???
I can see the state is reflecting that it’s on battery, and that it’s online, so why doesn’t it react?

Have you verified that the automation is enabled? Check the states page to make sure it is on. If the automation is on, you might try encapsulating the state from and to with quotes.

It is active, so that’s not the problem. The automation is entered through the webinterface, if I enter single or double quotes, it looks really odd in the automations.yaml file.
I’ve changed the status from ‘On Battery’ to just ‘Battery’, and I’ll do some testing later today.

needs quotes

Ahhaa, I’ll try it out, thanks @petro

@petro if I try and do that in the webinterface, I get a message:
“Message malformed: offset “00:00:10” should be format ‘HH:MM’ or ‘HH:MM:SS’ for dictionary value @ data[‘trigger’][0][‘for’]”

if it wont let you add quotes then use this format

for:
  seconds: 10

It won’t let me do that in the gui either.

I’ll try and enter it directly in the file.

Interesting.
I’ve entered it into the text file and reread the automations.
If I open one of them in the gui, it shows:

2019-07-10_0729