Solarlog string index out of range
The problem
The latest HA update broke my Solar-Log 1000 PM+/GPRS integration.
See the error log below.
What version of Home Assistant Core has the issue?
core-2024.10.0
What was the last working version of Home Assistant Core?
core-2024.9.3
What type of installation are you running?
Home Assistant Container
Integration causing the issue
solarlog
Link to integration documentation on our website
https://www.home-assistant.io/integrations/solarlog/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Unexpected error fetching solarlog data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/solarlog/coordinator.py", line 70, in _async_update_data
data = await self.solarlog.update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/solarlog_cli/solarlog_connector.py", line 89, in update_data
data = await self.client.get_energy(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/solarlog_cli/solarlog_client.py", line 212, in get_energy
data.production_year = raw_data["878"][-1][1]
~~~~~~~~~~~~~~~~~~~^^^
IndexError: string index out of range
### Additional information
_No response_
Hey there @ernst79, @dontinelli, mind taking a look at this issue as it has been labeled with an integration (solarlog) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of solarlog can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign solarlogRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
solarlog documentation solarlog source (message by IssueLinks)
@dontinelli could this be a regression from https://github.com/dontinelli/solarlog_cli/pull/4 ?
curl -X POST -H "Content-Type: application/json" http://solarlog/getjp -d '{ "878": null }'
returns:
{"878":"QUERY IMPOSSIBLE 000"}
curl -X POST -H "Content-Type: application/json" http://solarlog/getjp -d '{ "878": null }'returns:
{"878":"QUERY IMPOSSIBLE 000"}
This is helpful. Is my assumption correct, that all other requests work proprely? What is your setup? Do you use the user password to login or have you deactivated the password?
curl -X POST -H "Content-Type: application/json" http://solarlog/getjp -d '{ "878": null }'returns:
{"878":"QUERY IMPOSSIBLE 000"}
This is helpful. Is my assumption correct, that all other requests work proprely? What is your setup? Do you use the user password to login or have you deactivated the password?
Other query types like 854 work. The API is currently unsecured.
Same problem here, 24.10.0 broke the integration
ray@fedora:~$ curl -X POST -H "Content-Type: application/json" http://solar-log.fritz.box/getjp -d '{ "878": null }'
{"878":"QUERY IMPOSSIBLE 000"}
Just guessing, but my device still has the original SD card. Maybe the flash memory is showing its age and larger aggregate queries are failing?
As long as the live data is still working, I'm reluctant to tinker with it though.
Maybe we can treat the response as "data not available"?
Same problem here, solarlog is broken as of 2024.10 (SolarLog 1000PM):
2024-10-04 13:33:47.431 DEBUG (MainThread) [solarlog_cli.solarlog_client] HTTP-request successful: <ClientResponse(http://192.168.0.195/getjp) [200 OK]> <CIMultiDictProxy('Date': 'Fri, 4 Oct 2024 13:34:07 GMT', 'Server': 'IPC@CHIP', 'Content-Type': 'text/plain', 'Transfer-Encoding': 'chunked')>
2024-10-04 13:33:47.432 DEBUG (MainThread) [solarlog_cli.solarlog_client] Parsing http response: {"801":{"170":{"100":"01.10.24 11:03:45","101":2278,"102":2194,"103":230,"104":510,"105":3471,"106":9559,"107":3471,"108":9097589,"109":10180227,"110":0,"111":0,"112":0,"113":0,"114":0,"115":0,"116":12600}}} 2024-10-04 13:33:47.432 DEBUG (MainThread) [solarlog_cli.solarlog_connector] Basic data updated: SolarlogData(consumption_ac=0, consumption_day=0, consumption_month=0, consumption_total=0, consumption_yesterday=0, consumption_year=0, last_updated=datetime.datetime(2024, 10, 1, 11, 3, 45, tzinfo=zoneinfo.ZoneInfo(key='Europe/Berlin')), power_ac=2278, power_dc=2194, total_power=12600, voltage_ac=230, voltage_dc=510, yield_day=3471, yield_yesterday=9559, yield_month=3471, yield_year=9097589, yield_total=10180227, alternator_loss=0, capacity=None, efficiency=None, power_available=0, usage=None, inverter_data={}, production_year=None, self_consumption_year=None) 2024-10-04 13:33:47.432 DEBUG (MainThread) [solarlog_cli.solarlog_client] HTTP-request header: {'Content-Type': 'text/html'} 2024-10-04 13:33:47.432 DEBUG (MainThread) [solarlog_cli.solarlog_client] HTTP-request body: { "878": null } 2024-10-04 13:33:47.442 DEBUG (MainThread) [solarlog_cli.solarlog_client] HTTP-request successful: <ClientResponse(http://192.168.0.195/getjp) [200 OK]> <CIMultiDictProxy('Date': 'Fri, 4 Oct 2024 13:34:07 GMT', 'Server': 'IPC@CHIP', 'Content-Type': 'text/plain', 'Transfer-Encoding': 'chunked')>
2024-10-04 13:33:47.442 DEBUG (MainThread) [solarlog_cli.solarlog_client] Parsing http response: {"878":"QUERY IMPOSSIBLE 000"} 2024-10-04 13:33:47.442 ERROR (MainThread) [homeassistant.components.solarlog.coordinator]
Unexpected error fetching solarlog data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/solarlog/coordinator.py", line 70, in _async_update_data data = await self.solarlog.update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/solarlog_cli/solarlog_connector.py", line 89, in update_data data = await self.client.get_energy(data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/solarlog_cli/solarlog_client.py", line 212, in get_energy data.production_year = raw_data["878"][-1][1] ~~~~~~~~~~~~~~~~~~~^^^ IndexError: string index out of range
@dontinelli Think it's line 131 in https://github.com/dontinelli/solarlog_cli/commit/bd1459811d05a63da2d614b0bffb16a86d9c2212#diff-d7bf0ad6f2d0b35bfa9f39baf0fcc8b3b495fd86385da2c426df4c3d6960961bR10 - should be
if text.count('QUERY IMPOSSIBLE 000'):
instead of
if text.count('{"QUERY IMPOSSIBLE 000"}'):
cause the later doesn't match the response
{"878":"QUERY IMPOSSIBLE 000"}
@dontinelli Think it's line 131 in https://github.com/dontinelli/solarlog_cli/commit/bd1459811d05a63da2d614b0bffb16a86d9c2212#diff-d7bf0ad6f2d0b35bfa9f39baf0fcc8b3b495fd86385da2c426df4c3d6960961bR10 - should be
if text.count('QUERY IMPOSSIBLE 000'):instead of
if text.count('{"QUERY IMPOSSIBLE 000"}'):cause the later doesn't match the response
{"878":"QUERY IMPOSSIBLE 000"}
I guess you are right. Will have a look at it in more detail and hopefully fix over the WE.
Hi there, I can confirm this issue too. It occurred with HA 24.10.0 and shows the "string index out of range" error.
@dontinelli - thanks for the helpful integration by the way, great work! And thanks for trying to spend time in it on the weekend!
stan
As the bug is related to the library, I opened an issue in that repo and suggest to move the technical discussion there: https://github.com/dontinelli/solarlog_cli/issues/5