Goodwe rest sensor for multiple json elements

Hello my friend, thank you for your work.

I am unable to get this going. Getting this is the logfile:
Unable to fetch data from SEMS. 0
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 365, in _async_add_entity
await entity.async_update_ha_state()
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 225, in async_update_ha_state
self._async_write_ha_state()
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 248, in _async_write_ha_state
state = self.state
File “/config/custom_components/sems/sensor.py”, line 136, in state
return self._attributes[‘pgrid_w’]
KeyError: ‘pgrid_w’

Any suggestions?

I just checked the raw data coming from the API. Looks like the parameter pgrid_w is changed to out_pac.
@CervDotBe, you can try to change this in your local file sensor.py.

Awesome, works!

Hi, I have created yet another variant of the SEMS custom component, please see here: https://github.com/bouwew/sems2mqtt

My component requires an MQTT broker to be present. MQTT-discovery is used to detect the sensors being presented by this sems-component.

The advantage of this method is that each parameter taken from the API is presented as a separate sensor. In this case there are 9 sensors.

Hi,

Just checking; is your problem resolved? The reference to pgrid_w should work, I store the out_pac value from the api as attribute pgrid_w for HA? Let me know if you need any assistance.

Hi hessel, yes the problem is resolved by the feedback peformed by bouwew.

@hesselonline seems to work great! Thanks.

That is strange! @hesselonline 's code should work out of the box.
I think I made a wrong assumption…

@CervDotBe, what text did you change then to make it work? Can you show the line of code you changed? Before and after the change?

I changed the 2 entries of pgrid_w by out_pac

@hesselonline. Now i’m getting:
2019-06-18 20:53:05 ERROR (SyncWorker_14) [custom_components.sems.sensor] Unable to fetch data from SEMS. 0

I think this happens when no energy is produced, so it should not throw this exception.
Will take al look again tomorrow morning.

I added the status waiting:
self.status = { -1 : ‘Offline’, 0: ‘Waiting’, 1 : ‘Normal’ }
Seems to solve the issue (same status as in the sems android app)

I have one of those as well in my log file -> I think the api is a bit unresponsive some times. This might also explain the issue of CervDotBe; it was probably just a timeout of the API.

I did notice before that I can only login once with my account. When I’m running the sensor on Home Assistant, logging manually becomes practically impossible (constant logouts because HA is using the API every x seconds). Maybe this is causing this issue as well.

this shouldn’t be necesarry, can you change it back and try again?

I will include the ‘Waiting’ status in the Git Repo. Let me know if it fixes your issue.

hi @bouwew,

I have tested your sems2mqtt component. The sensors show up but never get updated. Any ideas?

EDIT: Seems also corresponding due to limited API calls. I had the sems component of hessel still active and he was probably using the API calls. Now it’s disabled and the sensors are getting updated.

Yeah, API calls seem limited. Getting logged out from the sems portal as well when browsing. Hopefully GoodWe fixes this in the near future. :slight_smile:

yep, don’t know if it’s possible to create additional users, I think I saw an invite option in the android app.

I added the ‘waiting’ status to the code in the Git Repo, also changed the dictionary lookup to return ‘unknown’ if a new status code shows up. This should prevent errors on new unknown status codes.

@CervDotBe, thanks for testing!
Also, you should probably revert the change I proposed in hesselonline’s code :slight_smile:

@hassPiUser, nice find! I will update my code as well.

I used the ‘invite’ button in the android app to invite another mailaddress. This resulted in a second account, and no more logon expired isssues. Haven’t tried if this account works with the component yet (but I expect no problems there). So, it might be wise to create a seperate account for the sensor this way.

I’ve updated my sems2mqtt component, I missed the unit of measurement for the grid frequency: Hz.

Hmm, the data being obtained by the sems2mqtt-component from the GoodWe API seems to be frozen. I’m still getting data in but its always the same? @hesselonline, are you seeing this as well? Or am I the only one?