Update frequency sensor

I have made a sensor that reads the volume* of my AVR from an XML file (with curl via the commandline I can read this XML file several times per second without any problems). It only takes seconds before the sensor is updated. Is there a limit on the sensors?

If set the the sensor on “Scan_interval: 1”, I see that the AVR is requested every second. So that part goes well.
I want that if I raise the volume, the volume number in the sensor also raised. I have a script behind the volume button. This script sets the sound down and does a sensor update at the same time.


part of the button:

      tap_action:
        action: call-service
        service: script.avr_zone2_vol_up
        data: {}



script:

  avr_zone2_vol_up:
    alias: "Script volume up"
    sequence:
      - service: media_player.volume_up
      target:
         entity_id: media_player.denon_avc_x3700h_2
      - service: homeassistant.update_entity
        target:
          entity_id: sensor.avr_zone2_volume



sensor:

  - platform: rest
    scan_interval: 12
    resource: http://<IP-ADDRESS>:8080/goform/formZone2_Zone2XmlStatusLite.xml
    name: avr_zone2_volume
    value_template: "{{ value_json.item.MasterVolume.value }}"

or

  - platform: rest
    name: avr_zone2_volume
    resource: http://<IP-ADDRESS>:8080/goform/formZone2_Zone2XmlStatusLite.xml
    method: GET
    scan_interval: 60  
    value_template: "{{ xml(state).find('.//MasterVolume/value').text }}"
    headers:
      Content-Type: application/xml

*HTTP://:8080/GoForm/Formzone2_Zone2xmlstatuslite.xml

What you see in the GUI is often a few seconds delayed.
Updating the GUI each second would be a huge drain on both server and client.

This delay is not relevant to automations though.

Thx.

So there’s no solution to see real-time the volume change. Force something? It’s only when change the volume.
I am talking about several seconds (sometime more than 5) delay here.

I think the GUI is updated like each 30 seconds.
The GUI is created backend and then sent to the browser that renders it frontend.
That means the entire GUI is re-read each time, because there is no frontend code to just gather a single sensor value from the backend.

Edit: GUI seems to be updating each 10 seconds. :slight_smile:

1 Like

Ok thanks for that.

Apparently there are many limitations in Home Assistant :frowning:

You will find the same in almost any other system that use web pages.
If you have a device that can run independently, then it can get the value from webhooks or one of the many other integrations available and then it can be shown in the speed you like.

The same problem with mute the sound. This sometimes it takes 5 seconds before the button toggled. You can’t unmute the sound again if it is not yet toggled.

7 years ago I made my own system with a web interface for the mobile phone. This is partly client site, with (Ajax) JavaScript. If I press a button in this interface, a reload will be done after sending the post of the corresponding DIV. Is not a huge drain for the server and the client.

A few days earlier someone convinced me to switch everything to Ha… :scream:

I don’t give up yet

The solution might be to make two buttons then. One for mute and one for unmute, so you call the function directly instead of toggling relative to the current state.

I succeeded … the sensor with the same name was placed in rest.yaml and sensor.yaml. It don’t like to fill the var from different places. If it is useful, I can post the part of A-Z.