2018-06-23 19:02:01 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template goodweinverter_inventersn: UndefinedError: ‘mappingproxy object’ has no attribute ‘result’
I guess for the rest sensor the relation of the value template is directly for the template sensor.
Looking at the JSON data: “code” is on the same level, so I changed the sensor to “result[0]”
Before adding json_attributes in the rest sensor, it complained:
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.goodweinverter. State max length is 255 characters.
With this feedback, I think the data-set capture is correct.
I’ve added two attributes to the rest sensor: “inventersn” and “vpv1”, and the error is gone.
next the template sensor need to be configured correctly.
Clone the repo (github.com/Sprk-nl/goodwe_sems_portal_scraper) somewhere.
Edit the file to have your user and password for the SEMS portal.
I also added some print statements for debugging.
Also change: mqtt_host = "localhost"
and add after line client =mqtt.Client(mqtt_client_name): client.username_pw_set('homeassistant', password='hello')
In automation.yaml:
# needed by gsps_beta
mqtt:
password: hello # this starts an embedded MQTT server
discovery: true
discovery_prefix: homeassistant
Now you can run the python file: python gsps_beta.py
It should add a gazillion sensors to home assistant. I hope they can somehow be grouped.
I now run the python file using crontab every 5 mins: crontab -e
in my current (to be fixed) case: */5 * * * * /opt/homeassistant/bin/python /home/homeassistant/.homeassistant/custom_components/gsps_beta.py >> /var/log/gsps_beta.py.log 2>&1
I’m using home assistant.
Unfortunately the script itself runs outside of home assistant and I just call it using Python.
Home assistant just runs the MQTT bus that the script connects to.
I’ve just ran the script within VSC and it connected with HA, and i can see on MQTT.FX that it was sending all the info through. However i cannot see the new sensors which should have appeared?
Managed to get it working now on my Mac running it on visual studio. Need to try and work my Nuc so i can run this as a cron task within the server instead of my manually deploying
I’m now trying to convert @sprk-nl’s code into a custom home assistant component. It will not use the MQTT stuff anymore then.
Any comments or ideas I should take into account?
I noticed that it pulls through the information, but without cross checking the info and the web page its hard to tell where the information has come from! If i can help let me know
I don’t have a clue how often it updates. If I look in my grafana dashboard which shows the data that home assistant exports to influxdb, i have a data point around every 2/3 minutes for this day. If you have a clue how to control it, please let me know.
Hi there,
Nice to see this progress on a Goodwe integration.
I have also received info about native access instead of web scraping for which I’ll update the code… Soon ish