Auto Skip Updates template?

Does anyone know how to template every new update event, and auto skip it?

I currently have to create a trigger every add-on, and skip it, but it’s becoming a growing pain.

alias: "HassOS: Auto Skip Updates"
description: ""

trigger:
  - platform: state
    entity_id:
      - update.file_editor_update
    id: file-editor
  ... SNIP ..

condition: []

action:
  - choose:
      - conditions:
          - condition: trigger
            id: file-editor
        sequence:
          - service: update.skip
            data: {}
            target:
              entity_id: update.file_editor_update
   ...SNIP...

mode: single

I do this just to hide the annoying update tooltip, since I have my own updating schedule. image

You could do something like this:

trigger:
  - platform: event
    event_type: state_changed
condition: "{{ trigger.event.data.entity_id is match('update\..*_update') and trigger.event.data.new_state.state == 'on' }}"
action:
  - service: update.skip
    target:
      entity_id: "{{ trigger.event.data.entity_id }}"

Something seems to be wrong with the condition?

But this seems to be accepted:

alias: "HassOS: Auto Skip Updates"
description: ""
trigger:
  - platform: event
    event_type: state_changed
condition:
  - condition: template
    value_template: >-
      "{{ trigger.event.data.entity_id is match('update\..*_update') and
      trigger.event.data.new_state.state == 'on' }}"
action:
  - service: update.skip
    target:
      entity_id: "{{ trigger.event.data.entity_id }}"
mode: single

Haven’t fully tested yet, but just from looking at it, it seems that it will do the job, thanks!

Templating is still the hard thing about HA.

You shouldn’t surround the template in quotes for multiline templates. I don’t think it will work as you’ve written it. Mine should work fine as long as you switch to YAML mode.

Edit: Weird, looks like it needs the \ escaped. So this:

trigger:
  - platform: event
    event_type: state_changed
condition: "{{ trigger.event.data.entity_id is match('update\\..*_update') and trigger.event.data.new_state.state == 'on' }}"
action:
  - service: update.skip
    target:
      entity_id: "{{ trigger.event.data.entity_id }}"

By the way, triggering on every state change event isn’t ideal if you’re running HA on an underpowered platform (like a Pi3B), but there isn’t really another way to do this. If you’re using a faster platform, it won’t be a problem.

You shouldn’t surround the template in quotes for multiline templates. I don’t think it will work as you’ve written it. Mine should work fine as long as you switch to YAML mode.

That’s odd, I copy paste your code, and when I go back to visual mode, and then back to yaml mode, the condition is changed a bit:

trigger:
  - platform: event
    event_type: state_changed
condition:
  - condition: template
    value_template: >-
      {{ trigger.event.data.entity_id is match('update\..*_update') and
      trigger.event.data.new_state.state == 'on' }}
action:
  - service: update.skip
    target:
      entity_id: "{{ trigger.event.data.entity_id }}"

Yeah, I figured it’s not really the most optimized way to do it. I got processing power, but it’s either performance or convenience in this case…

Yes, it (sometimes?) turns single-line templates into multiline. It’s equivalent, but also note that there are no surrounding quotes in the multiline version (which is correct).