2022.12: Scrape and scan interval

There is no step back. The method to change scan interval on UI based integrations has been stated multiple times now. Once again, if you want to change the default polling frequency, turn off polling. Then create an automation using any trigger you want with an homeassitant.update_entity service call.

3 Likes

No good reason, I just forgot about defined lol. But I just tested and that works fine as well. I’m not sure if there’s a performance difference.

1 Like

Ah .timestamp(), right. That’s the one I was looking for. Yea that’s much better.

I wasn’t aware of the differences between the two although I’m not sure it matters in this spot since the whole point is simply to call it every x minutes. In this particular context it doesn’t really matter if it’s truly a multiple of x minutes since the epoch with accuracy. But I do like that I don’t have to do a string to int conversion with that.

Sorry I literally just typed that automation out on my phone in response to all this so I didn’t do a lot of editing and review. Probably would’ve caught stuff like that on my computer but I was pinned down by a tiny sleeping human so my options were limited :blush:

I haven’t had the time to debug, but… creating automations to update scrape sensors will it not simply create two variants of update?

For instance:
update - default - 10 min
update - default - 10 min

update - automation - 480 min
update - default - 10 min
… and so on…

No

1 Like

I’d also like to point out that the only people who are against this change is always veterans. Every time HA moves an integration from Yaml to the UI, veterans voice displeasure. Beginners LOVE It. Scrape isn’t the first integration to move this direction with scan interval and it won’t be the last.

2 Likes

…and as soon as as the beginners, who initially loved it (because of its simplicity) become experts, they will begin to dislike it too (because of its inflexibility, inability for proper version control, having passwords in JSON files etc. - there has been enough discussion about this).
I still think that these kind of changes are a very bad idea. And there are much more important issues in HA to tackle than to implement such changes that nobody had asked for…

5 Likes

You are arguing this response without reading what the discussion was about because you saw “Move to yaml from the UI”. All your points have nothing to do with the topic we were discussing. Please don’t cherry pick my responses to push some agenda.

A volunteer made the change, not the main dev team. You can’t force volunteers to work on something they don’t want to work on… because then just just won’t provide updates at all.

Please don’t come back with some response to Yaml to UI shifts. We were discussing scan_interval. If you have complains about the YAML to UI changes, make a Social topic and leave me out of it. Thank you.

6 Likes

in addition: I’ve searched the forum a bit for “tomorrowio” - this seems to be integrated per “rest api” - which is different from scrape…

I don’t use any REST api nor do I use Scrape atm…
So I cannot confirm the behave for the rest integration, but I don’t beleive - that the scan intervall was removed completely :slight_smile: [wouldn’t make much sense for such a sensor at all]

So… yes, I think - the whole conversation was somehow built on misleading interpretations and misunderstanding of each other :slight_smile:

I see. Simple and streamlined and has feature parity.

And mistakes get deprecated. :wink:

Thanks @Rusty!

1 Like

pretty cool! So now we can add an input number and this way drive the frequency.
High time for someone to develop a HACS integration to manage scan intervals :slight_smile:

1 Like

:rofl: and reinvent the wheel again!

2 Likes

I just tried your automation and it gave me an error.

I think you forgot the “repeat:” in the for_each sequence:

trigger:
  platform: time_pattern
  minutes: '*'
variables:
  entities:
    sensor.entity_1: 5
    sensor.entity_2: 10
    sensor.entity_3: 100
    sensor.entity_4: 2880
    ...
  total_mins: "{{ (now().timestamp() / 60) | int }}"
action:
  repeat:
    for_each: "{{ entities | dictsort }}"
    sequence:
      if: "{{ total_mins % repeat.item[1] == 0 }}"
      then:
        service: homeassistant.update_entity
        data:
          entity_id: "{{ repeat.item[0] }}"

Once I added that then it seems to work.

1 Like

Huh. Yea I did, sorry about that. Good catch, will update my post

1 Like

Gotta laugh at the whole assertion that moving away from YAML is the right thing to do, only to see people posting examples of the work-around in YAML. Yes, editing YAML is easier. But adding the automation through the UI is not as straightforward…not by a longshot.

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 }}"