I have exactly the same issue here.
I have exactly the same web interface, running on my local network. This time though, the inverter is branded “Sofar”.
I need to scrape the line:
var webdata_total_e = “23096.0”;
The difference with my requirement is that it’s April 2023, and if I understand things properly, the way that Sensors are defined has changed.
Other than installing Home Assistant onto my RPi 4 yesterday, and trying for most of yesterday and today to get this, I’m a complete HA noob.
I thought that what I needed to my configuration.yaml was:
scrape:
- resource: http://10.1.1.62/index_cn.html
username: admin
password: admin
timeout: 20
scan_interval: 30
sensor:
- select: script:contains('webdata_today_e')
value_template: "{{ value.split('=')[1].strip().replace(';', '') }}"
name: "Sofar Energy Today (kWh)"
unit_of_measurement: "kWh"
state_class: total
icon: mdi:solar-power
NOTE: As it’s only accessible via my home network, I have zero concern that the username and password is open for all to see.
So, the process I am using to set this is:
Modify configuration.yaml
Developer Tools
Check Configuration [OK]
RESTART
Quick reload [Reloading]
Settings
Devices & Services
Entities
Type “sofar” into the “Search Entities”, click on “Sofar Energy Today (kWh)”
The value flicks between “Unknown” and “Unavailable”
The logfile shows the following:
2023-04-21 16:19:56.476 WARNING (MainThread) [homeassistant.components.scrape.sensor] Index ‘0’ not found in sensor.sofar_energy_today_kwh
2023-04-21 16:19:56.479 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘None’ has no attribute ‘split’ when rendering ‘{{ value.split(’=‘)[1].strip().replace(’;‘, ‘’) }}’
What am I doing wrong?