home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.19k stars 30.22k forks source link

`update_entity` triggers speedtest when used from a button, but not from an automation (edit: at top of hour) #96441

Open jason-curtis opened 1 year ago

jason-curtis commented 1 year ago

The problem

I can't get speedtest to reliably trigger from an automation running at the top of the hour. edit: workaround per @JN-Jones: adjust the minute to not be 0 or 30.

Here's my automation config:

id: '1687990373473'
alias: Speedtest
description: >-
  runs a speed test hourly but only if the internet hasn't been in use in the
  last ~minute
trigger:
  - platform: time_pattern
    minutes: 0
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.xe75pro_kib_s_sent
        below: 500
      - condition: numeric_state
        entity_id: sensor.xe75pro_kib_s_received
        below: 100
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.speedtest_download
mode: single

Here's an example trace from 8am on July 10: image

Looks like it worked, right? But when I actually check the data, there is no speed test conducted at that time: image I included the network activity in that view so you can see there was a successful test at 10 AM but nothing happened at 8 AM.

Usage with a lovelace button is working

At the same time, I have a lovelace button set up that successfully triggers a speed test every time:

  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: call-service
      service: homeassistant.update_entity
      target:
        entity_id: sensor.speedtest_download
      data: {}

What version of Home Assistant Core has the issue?

core-2023.7.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

speedtestdotnet

Link to integration documentation on our website

https://www.home-assistant.io/integrations/speedtestdotnet/

Diagnostics information

No response

Example YAML snippet

id: '1687990373473'
alias: Speedtest
description: >-
  runs a speed test hourly but only if the internet hasn't been in use in the
  last ~minute
trigger:
  - platform: time_pattern
    minutes: 0
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.xe75pro_kib_s_sent
        below: 500
      - condition: numeric_state
        entity_id: sensor.xe75pro_kib_s_received
        below: 100
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.speedtest_download
mode: single

Anything in the logs that might be useful for us?

nothing obvious in the logs. It seems like the `homeassistant.update_entity` fires but then nothing happens. I've tried turning on debug logging.

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @rohankapoorcom, @engrbm87, mind taking a look at this issue as it has been labeled with an integration (speedtestdotnet) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `speedtestdotnet` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign speedtestdotnet` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


speedtestdotnet documentation speedtestdotnet source (message by IssueLinks)

davidrustingha commented 1 year ago

Same here. The automation runs smoothly, but doesn't actually update the sensor. Manually triggering the automation does trigger an update.

- alias: Speedtest Check
  id: speed_test_check
  trigger:
    - platform: time_pattern
      minutes: 30
  action:
    - service: homeassistant.update_entity
      data:
        entity_id: sensor.speedtest_download
DarthSonic commented 1 year ago

Gott the very same issue in my HA installation. Using Integration reload to get new measurement.

JN-Jones commented 1 year ago

Looks to me like this, #85375, #80290 and possibly #89854 are all the same issue, updates at full and possibly half hours fail because of an issue in the underlying cli tool. Moving the update check two minutes after the full hour worked for me.

DarthSonic commented 1 year ago

Yes. Triggering every 4 hours on the second minute of the hour works! Thx!

jason-curtis commented 1 year ago

@JN-Jones your workaround works for me too so I added it to the issue description, thank you!

It looks like like sivel/speedtest-cli/#796 would fix this, but in the meantime we can just stop hammering the speedtest servers all at the same time!

dirrgang commented 1 year ago

Ah, sweet. In the meantime this is how I added randomness to the test:

alias: Speedtest
description: ""
trigger:
  - platform: time
    at: "01:00:00"
condition: []
action:
  - delay: "{{ (range(1, 5)|random|int) }}:{{ (range(1, 60)|random|int) }}:00"
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id:
        - sensor.speedtest_ping
mode: single
issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

JN-Jones commented 9 months ago

Yep, still an issue

issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

JN-Jones commented 6 months ago

Can corfirm this issue persists in 2024.03.1

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

jason-curtis commented 3 months ago

The workaround seems to work OK but afaik the issue of speedtest silently failing when run on the hour, still exists.

https://optionzero.co

On Fri, Jun 14, 2024 at 4:08β€―AM issue-triage-workflows[bot] < @.***> wrote:

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

β€” Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/96441#issuecomment-2167793310, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZPVU7FYLONCROSSIHZBI3ZHLFJDAVCNFSM6AAAAAA2HZTO7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRXG44TGMZRGA . You are receiving this because you authored the thread.Message ID: @.***>

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

jason-curtis commented 3 weeks ago

still relevant; good to have this marked as "open" so that folks can find it and the workaround.