2022.12: Scrape and scan interval

I cannot speak for others, but I am not against moving from YAML to UI. I dislike having to do things in two places and adding more work and complexity to get to the same end.

The ship has sailed. Move on.

1 Like

Said many others affiliated with other open-source projects that were ultimately forked and withered. Ignore the people that use the product. Brilliant move, if not so arrogant.

Im a moderator, im a glorified babysitter for adults, I don’t make the decisions. Im relaying them to you. So when you single out my posts acting like I made them, you’re gonna get snarky responses.

3 Likes

I’ve suggested your automation (the last one) a few times, especially with the recent changes to the ping sensor. I upgraded my own server only yesterday, so I had to apply this (as I’ve been planning to). I made a small, but important change: Performing these updates can take a bit of time. The repeat executes iterations in series, which means completing it for many sensors will take some time and if the interval is short, a backlog could build up. There’s unfortunately no parallel directive for loops, but one can put the action in a script and call it in a non-blocking way. So, I did this:

script:
  update_entity:
    description: "Update an entity"
    fields:
      entity_id:
        description: "An entity ID"
        example: "binary_sensor.my_sensor"
    mode: parallel
    sequence:
      - service: homeassistant.update_entity
        target:
          entity_id: "{{ entity_id }}"

automation:
  - alias: "Update Ping Sensors"
    initial_state: true
    trigger:
      platform: time_pattern
      # minimum resolution
      seconds: '/15'
    variables:
      entities: >-
        {{ integration_entities('ping') }}
      total_seconds: "{{ now().timestamp() | int(0) }}"
    action:
      repeat:
        for_each: "{{ entities }}"
        sequence:
          if: "{{ total_seconds % (state_attr(repeat.item, 'scan_interval') | int(0)) == 0 }}"
          then:
            # non-blocking call: fire these off in parallel (script also allows parallel execution)
            - service: script.turn_on
              target:
                entity_id: script.update_entity
              data:
                variables:
                  entity_id: "{{ repeat.item }}"