jpcornil-git/HA-sma

changing scan_interval in configuration.yaml does not do anything

Closed this issue · 7 comments

I tried lowering the time and increasing it, yet it stills scans only every 30 seconds

Chapter "4.3 Query Interval" of the Sunny Webbox RPC User Manual specifies that the interval should not be less than 30s ... and more has probably limited value => support for a configurable scan_interval was never enabled.

If you really want to change this, you can modify this line with

    # TODO: Move scan_interval to options ?  pylint: disable=fixme
    interval = timedelta(
        seconds=entry.data.get(CONF_SCAN_INTERVAL, entry.data[CONF_SCAN_INTERVAL])
    )

I should probably remove that from the configuration.yaml example and config flow to avoid confusion.

Were you able modify the file and get desired behavior ?

Also, how do you monitor scan rate ?

I tried it, but it did nothing.

Did you restarted HA after the modification ? Just to make before I look into this.

How do you monitor scan rate ?

Yes i did, I monitor scan rate by looking at how long it takes the sensor to update and it is still 30 s.
DC7DB312-4027-4EC1-BF4A-D9B2A3E68E15

I'll have a look tomorrow (the update time is related to the latest data change not the latest data fetch I believe -> it could be that it is reading faster but that the value is only updated every 30s within the box).

To make sure, you can enable debug log for this integration in your configuration.yaml and watch fetching time in HA logs (parameters -> system -> logs, load full logs):

logger:
  logs:
    custom_components.sma_webbox: debug

ex. for mine (with a 30s scan interval)

2023-04-15 22:44:02.355 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] { " v e r s i o n " : " 1 . 0 " , " p r o c " : " G e t P l a n t O v e r v i e w " , " f o r m a t " : " J S O N " , " i d " : " 9 " } 
2023-04-15 22:44:02.454 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] {'result': {'overview': [{'meta': 'GriPwr', 'name': 'Puissance', 'unit': 'W', 'value': '0'}, {'meta': 'GriEgyTdy', 'name': 'Énergie dégagée jour actuel', 'unit': 'kWh', 'value': '45.845'}, {'meta': 'GriEgyTot', 'name': 'Rendement total', 'unit': 'kWh', 'value': '70973.919'}, {'meta': 'OpStt', 'name': 'État', 'value': 'Ok, Ok'}, {'meta': 'Msg', 'name': 'Message', 'value': ''}]}, 'format': 'JSON', 'proc': 'GetPlantOverview', 'version': '1.0', 'id': '9'}
2023-04-15 22:44:03.359 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] { " v e r s i o n " : " 1 . 0 " , " p r o c " : " G e t P r o c e s s D a t a " , " f o r m a t " : " J S O N " , " i d " : " 1 0 " , " p a r a m s " : { " d e v i c e s " : [ { " k e y " : " 0 0 8 0 : 7 d c 8 9 8 6 f " , " c h a n n e l s " : [ " I p v " , " U p v - I s t " , " F a c " , " P a c " , " R i s o " , " h - O n " , " h - T o t a l " , " E - T o t a l " , " N e t z - E i n " ] } ] } } 
2023-04-15 22:44:03.593 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] {'result': {'devices': [{'channels': [{'meta': 'Ipv', 'name': 'Entrée courant DC', 'unit': 'A', 'value': '---'}, {'meta': 'Upv-Ist', 'name': 'Entrée tension DC', 'unit': 'V', 'value': '---'}, {'meta': 'Fac', 'name': 'Fréquence du réseau', 'unit': 'Hz', 'value': '---'}, {'meta': 'Pac', 'name': 'Puissance', 'unit': 'W', 'value': '---'}, {'meta': 'Riso', 'name': 'Résistance d’isolement', 'unit': 'Ohm', 'value': '---'}, {'meta': 'h-On', 'name': 'Temps d’injection', 'unit': 'h', 'value': '41440.93'}, {'meta': 'h-Total', 'name': 'Temps de service', 'unit': 'h', 'value': '42483.6'}, {'meta': 'E-Total', 'name': 'Rendement total', 'unit': 'kWh', 'value': '70973.92'}, {'meta': 'Netz-Ein', 'name': 'Nombre de connexions au réseau', 'value': '4254'}], 'key': '0080:7dc8986f'}]}, 'format': 'JSON', 'proc': 'GetProcessData', 'version': '1.0', 'id': '10'}
2023-04-15 22:44:03.594 DEBUG (MainThread) [custom_components.sma_webbox] Finished fetching sma_webbox_coordinator data in 1.239 seconds (success: True)
2023-04-15 22:44:33.355 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] { " v e r s i o n " : " 1 . 0 " , " p r o c " : " G e t P l a n t O v e r v i e w " , " f o r m a t " : " J S O N " , " i d " : " 1 1 " } 
2023-04-15 22:44:33.455 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] {'result': {'overview': [{'meta': 'GriPwr', 'name': 'Puissance', 'unit': 'W', 'value': '0'}, {'meta': 'GriEgyTdy', 'name': 'Énergie dégagée jour actuel', 'unit': 'kWh', 'value': '45.845'}, {'meta': 'GriEgyTot', 'name': 'Rendement total', 'unit': 'kWh', 'value': '70973.919'}, {'meta': 'OpStt', 'name': 'État', 'value': 'Ok, Ok'}, {'meta': 'Msg', 'name': 'Message', 'value': ''}]}, 'format': 'JSON', 'proc': 'GetPlantOverview', 'version': '1.0', 'id': '11'}
2023-04-15 22:44:34.355 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] { " v e r s i o n " : " 1 . 0 " , " p r o c " : " G e t P r o c e s s D a t a " , " f o r m a t " : " J S O N " , " i d " : " 1 2 " , " p a r a m s " : { " d e v i c e s " : [ { " k e y " : " 0 0 8 0 : 7 d c 8 9 8 6 f " , " c h a n n e l s " : [ " I p v " , " U p v - I s t " , " F a c " , " P a c " , " R i s o " , " h - O n " , " h - T o t a l " , " E - T o t a l " , " N e t z - E i n " ] } ] } } 
2023-04-15 22:44:34.591 DEBUG (MainThread) [custom_components.sma_webbox.sma_webbox] {'result': {'devices': [{'channels': [{'meta': 'Ipv', 'name': 'Entrée courant DC', 'unit': 'A', 'value': '---'}, {'meta': 'Upv-Ist', 'name': 'Entrée tension DC', 'unit': 'V', 'value': '---'}, {'meta': 'Fac', 'name': 'Fréquence du réseau', 'unit': 'Hz', 'value': '---'}, {'meta': 'Pac', 'name': 'Puissance', 'unit': 'W', 'value': '---'}, {'meta': 'Riso', 'name': 'Résistance d’isolement', 'unit': 'Ohm', 'value': '---'}, {'meta': 'h-On', 'name': 'Temps d’injection', 'unit': 'h', 'value': '41440.93'}, {'meta': 'h-Total', 'name': 'Temps de service', 'unit': 'h', 'value': '42483.6'}, {'meta': 'E-Total', 'name': 'Rendement total', 'unit': 'kWh', 'value': '70973.92'}, {'meta': 'Netz-Ein', 'name': 'Nombre de connexions au réseau', 'value': '4254'}], 'key': '0080:7dc8986f'}]}, 'format': 'JSON', 'proc': 'GetProcessData', 'version': '1.0', 'id': '12'}
2023-04-15 22:44:34.592 DEBUG (MainThread) [custom_components.sma_webbox] Finished fetching sma_webbox_coordinator data in 1.237 seconds (success: True)

With debug level enabled, you should also see in these logs a message mentionning the scan_interval that has been loaded.

Just gave it a try using both configuration.yaml and configflow for integration setup and in both cases, scheduling of requests is taking place at the configured interval using the unmodified code (you can undo the above change, original code was OK already)

-> could you supply your logs ? (add a "default: warning" to the logger to limit debug verbosity to this integration as illustrated below)

logger:
  default: warning
  logs:
    custom_components.sma_webbox: debug