Core: Speedtest shows Unknown until first scheduled run.

Created on 27 Jul 2016  路  7Comments  路  Source: home-assistant/core

Speedtest component is currently configured to run at a few set hours each day. Great.

It would be useful (really just prettier in the GUI) if it ALSO ran once when first loaded (Home Assistant starts up) so that the Gui doesn't show unknown until the set time arrives. As it stands now, a user is not sure if it's working or not after initially setting it up.

Most helpful comment

I use MQTT to show the last Speedtest results, to avoid "unknown" after a HASS restart. I still get "unknown" if I reboot my RPi, though, but I could probably fix that by looking into persistence for Mosquitto running on my RPi.

My setup includes the following automation:

- alias: "Publish Speedtest results to MQTT"
  trigger:
    platform: state
    entity_id: sensor.speedtest_ping, sensor.speedtest_download, sensor.speedtest_upload
  condition:
    - condition: template
      value_template: '{{ trigger.to_state.state != "unknown" }}'
  action:
    service: mqtt.publish
    data_template:
      topic: "hass/sensor/speedtest/{{ trigger.entity_id.split('_')[1] }}"
      payload: "{{ trigger.to_state.state }}"
      qos: 0
      retain: true

So anytime the values of the default Speedtest sensors change (which means the Speedtest ran), I publish the results to MQTT. I then show those results stored in MQTT with the following sensors:

- platform: mqtt
  name: "Speedtest ping MQTT"
  state_topic: "hass/sensor/speedtest/ping"
  qos: 0
  unit_of_measurement: "ms"

- platform: mqtt
  name: "Speedtest download MQTT"
  state_topic: "hass/sensor/speedtest/download"
  qos: 0
  unit_of_measurement: "Mbps"

- platform: mqtt
  name: "Speedtest upload MQTT"
  state_topic: "hass/sensor/speedtest/upload"
  qos: 0
  unit_of_measurement: "Mbps"

All 7 comments

image

I can see some potential speedtest spamming there, when you restart often, to test stuff.

When I wrote this platform I tried to have the speedtest run on startup but it slows down the Home Assistant startup time significantly. @ktpx also makes a great point.

You can always use the service sensor.update_speedtest to run a manual speedtest.

I didn't realize you could trigger the test manually. That's all that is necessary then.

Could the last speedtest results be cached somewhere? So when HASS restarts the last values are used instead.

@philhawthorne I do like the caching idea. That would solve the unknowns in the GUI and the SPAM problem. @nkgilley , did you ever explore the idea of caching the results?

I use MQTT to show the last Speedtest results, to avoid "unknown" after a HASS restart. I still get "unknown" if I reboot my RPi, though, but I could probably fix that by looking into persistence for Mosquitto running on my RPi.

My setup includes the following automation:

- alias: "Publish Speedtest results to MQTT"
  trigger:
    platform: state
    entity_id: sensor.speedtest_ping, sensor.speedtest_download, sensor.speedtest_upload
  condition:
    - condition: template
      value_template: '{{ trigger.to_state.state != "unknown" }}'
  action:
    service: mqtt.publish
    data_template:
      topic: "hass/sensor/speedtest/{{ trigger.entity_id.split('_')[1] }}"
      payload: "{{ trigger.to_state.state }}"
      qos: 0
      retain: true

So anytime the values of the default Speedtest sensors change (which means the Speedtest ran), I publish the results to MQTT. I then show those results stored in MQTT with the following sensors:

- platform: mqtt
  name: "Speedtest ping MQTT"
  state_topic: "hass/sensor/speedtest/ping"
  qos: 0
  unit_of_measurement: "ms"

- platform: mqtt
  name: "Speedtest download MQTT"
  state_topic: "hass/sensor/speedtest/download"
  qos: 0
  unit_of_measurement: "Mbps"

- platform: mqtt
  name: "Speedtest upload MQTT"
  state_topic: "hass/sensor/speedtest/upload"
  qos: 0
  unit_of_measurement: "Mbps"
Was this page helpful?
0 / 5 - 0 ratings