mbillow / ha-chargepoint

Home Assistant ChargePoint EV Charger Integration
MIT License
44 stars 6 forks source link

Unavailable when charging #14

Closed geoffro10 closed 1 year ago

geoffro10 commented 1 year ago

This just started showing for me but when I'm plugged in and charging, all my entities switch to unavailable. As soon as the charging is stopped, they all come back.

geoffro10 commented 1 year ago

Of course as soon as I post something here, now it seems to be working. Was really weird. Did that for 3 straight days. I'll come back and close it out if it works the next few days.

geoffro10 commented 1 year ago

Working fine now.

crkochan commented 1 year ago

I wonder if this might be due to the type of charging station you were using.

I've noticed that the integration entities regularly go unavailable when I'm using a CP station that is not public. These particular stations are located on the campuses of my company, and are free for employee use.

Today I noticed that the integration is throwing an exception trying to get data on the charging sessions in progress whilst plugged into one of these stations.

I wonder if that might have been happening here.

geoffro10 commented 1 year ago

I don't think it's related because the first time was at my home on a Home Flex and the second was a public charger.

crkochan commented 1 year ago

The code in the underlying python module uses a suboptimal (in my opinion) method for getting the current charging status. It's rigidly coded, so if the status payload differs at all from how the code was written, it breaks with the effect of all entities in HA going unavailable.

This could happen with public chargers, it could also happen with a Home Flex where the station hasn't been configured with utility information.

I opened a PR against the module with fixes.

geoffro10 commented 1 year ago

That's interesting! I wish I knew more about coding so I could help. But FYI, my utility info is in my Home Flex.

mbillow commented 1 year ago

The code in the underlying python module uses a suboptimal (in my opinion) method for getting the current charging status. It's rigidly coded…

I spend a lot of my time writing in strongly typed languages, so I tend to err in that direction even when using Python. I commented on the PR, there is definitely a middle ground.

Happy to spend the time making this work in as many ways as possible. I will note that the HA module itself does some logical check to make sure the charging status it is returning belongs to the home charging device registered. I did that to keep this plugin simple and keep it true to the “Home” in Home Assistant. If you do want to track all your CP charging sessions, I’m not vehemently against a little extra logic to handle that as well.

crkochan commented 1 year ago

I think it's valid to limit the integration to tracking home sessions only.

The contributions against the underlying library is just to keep the integration from emitting errors in the HA logs and having the integration flagged in the UI as having issues or needing to be re-setup when it's receiving session data from other than the home charger.