Poll a sensor every 5 seconds

Tags: #<Tag:0x00007fc40a081af8>


First of all, thank you very much for your hard work. It is fun to work with home assistant.
Unfortunately, there is one thing that I can’t manage, despite days of research and testing.

It’s about this device:
switch_dryer | AVM FRITZ!DECT 210 | Waschkeller | AVM FRITZ!SmartHome

switch.switch_dryer on
current_power_w: 0
device_locked: false
locked: true
total_consumption: 0.020
total_consumption_unit: kWh
temperature: 19.0
temperature_unit: °C
friendly_name: switch_dryer

I need a query rate of 5 seconds instead of 30 seconds for the value current_power_w.
I tried scan_interval and an automation:

- id: '1614689170463'
  alias: update_dryer_power_data_5_seconds
  description: Wenn der Trockner läuft wird power_consumption alle 5 Sekunden abgerufen
    anstatt alle 30
  - platform: time_pattern
    seconds: /5
  - condition: state
    entity_id: input_boolean.bool_dryer_is_running
    state: 'on'
  - service: homeassistant.update_entity
    entity_id: switch.switch_dryer
  initial_state: true
  mode: single

The automation starts every 5 seconds, only the value is not updated.
Have made numerous attempts, read examples and of course the documentation several times, without success. Do you have a suggestion for me ? Thank you in advance!

Many greetings


it might be that the fritzbox is not updating the values every 5 seconds.

Is there a reason you need this?

yes that can be. If so, do you know if or how that can be changed?

Yes, the reason is that in the last program phase the dryer only rotates the drum for a few seconds every 2-3 minutes. That would overlook the 30-second query and see the program as finished too early.

And how would a 5 second refresh time help that?

Is there realy the same energy cosumption in this last phase?
Our Miele dryer has the same behaviour, but it has higher base energy consumption till the last phase is completely finished.
Also i don’t unterstand how the 5sec Update Intervall would help you in this case

if the machine sporadically only consumes electricity for up to 5 seconds in the final phase, a 5-second query would notice this. Another automation would then know that the machine is still running and there would be no false “finished” message.

how would a 30 second window not notice this? If it’s power output, you’ll still have wattage, that’s all I’m trying to point out here. I think your efforts should be directed at the automation. Not having a polling frequency of 5 seconds (which is impossible on fritzbox it seems).

ok if i just asked for the basic energy, he would immediately say, the machine is ready. The short peaks only reveal that the last program is still running.
How did you solve that or how do you know that the last dryer program is still running?
I am open and grateful for any solution :slight_smile:

oh, you mean the entire last program consumes more energy than when the dryer is finished. I would have to measure whether that is also the case at Bosch.

I would probably generate a statistic sensor to determine the average energy consumption over a period of time and see if you can get clos: Statistics - Home Assistant (home-assistant.io)

Otherwise, as I said, our dryer basically has a higher base energy consumption, even in the last drying phase until it goes into standby.
This allowed me to do something relatively simple along these lines:

  - platform: template
        friendly_name: 'Trockner'
        value_template: >-
          {% if states('sensor.stromverbrauch_trockner')|float <= 0 %}
          {% elif states('sensor.stromverbrauch_trockner')|float <= 7 %}
          {% elif states('sensor.stromverbrauch_trockner')|float > 7 %}
          {% else %}
          {% endif %}

Statistics sensor … A good approach, I have to look at that too. I also look again at the values ​​in the areas whether I can catch that. Unfortunately, I do not know whether the statistics sensor is recording the peaks or whether the sensor only receives them by chance. I will probably have to deal with the source code a little more to understand the behavior better. I hope these google translations make sense for you :slight_smile:

In any case, thank you very much for your time and I think the whole project is great!

You’re welcome, if you need any other kind of help, feel free to PM me in German.
As it looks to me, you are a German, or at least German-speaking user :wink:

Ahh a compatriot :slight_smile: That’s really very friendly, thank you! If things don’t go on for days, it’s nice to be able to ask such a nice community. Thank you!
OK. For now, I’ve given away enough flowers here :grin: