CharlesGillanders / homeassistant-alphaESS

Monitor your energy generation, storage, and usage data using the official API from Alpha ESS.
MIT License
94 stars 22 forks source link

EV charger readings #12

Closed Tupsi closed 2 years ago

Tupsi commented 2 years ago

I was wondering if it is possible to have a new entity for what is going into the wallbox if one is installed. The AlphaESS Monitoring shows something there, so I was hoping it exists on the api as well you pull.

image
CharlesGillanders commented 2 years ago

Just had to lookup what a wallbox is - that's an EV charger is that right? I don't have one of those so I'd need support from you or someone else who does have one to see how it shows up in the API. If someone can grab a capture (using whatever proxy software you like) of the web service call between your browser and AlphaESS that would likely be enough.

Tupsi commented 2 years ago
image

I am still trying to figure this out, but could it be the "EChargingPile"? At least the number fits. For clarification, I changed to time frame for the readout to include yesterday and today in order to get something other then 0 there (only had a car loading yesterday), so the numbers do not all match from the first to second screenshot.

Tupsi commented 2 years ago

I tried to be super clever and added two lines to your sensor.py myself with the appropiate entry (EChargingPile). While that seemed to have worked in general (new entity shows up in HA), it doesnt report anything and even shows a nasty red symbol under "status". So I guess, you need to work a bit more magic when you add a sensor.

image

So I still need you help if you can find the time. I forked your stuff, so you have an easier look what I changed.

https://github.com/Tupsi/homeassistant-alphaESS/commit/45ce87f91969b8ced7ef029983edffff1c04759d

CharlesGillanders commented 2 years ago

Thank you! the API result is perfect and I think you are right about what data I need to grab. Home Assistant doesn't let automations interact with services directly themselves, everything needs to go through a separate library. So I first need to update that library and then I can update the home assistant integration to actually display the sensor. I'll try to get time this week to do that.

Tupsi commented 2 years ago

May I ask where this library is located in an HA installation? I can see you have another repo here on github with it, but I am puzzled on how this alphaess library repo make its way into my HA installation as I can not find any reference in the installation or anywhere on my computer where I installed HA.

CharlesGillanders commented 2 years ago

It's part of how home assistant works. If you look in manifest.json for every integration (including this one for AlphaESS) you'll see a requirements entry - that tells home assistant which PyPI modules it should grab to support the integration. In my case there's only one module that's needed.

HomeAssistant code standards requires all interaction with external services to be done through pypi modules and not directly in code within HA integrations.

Tupsi commented 2 years ago

found that line thanks, but how does HA knows where to get the library from? Does it get fetched automatically from your repo? Then it should be some sort of config, or do you have to request that your lib be included in HA at some point? Also I went over your lib and I do not see anything which has to be changed there; you grap the whole data field from the json, so the charger entry should already be in there, when this addon requests it, no?

Tupsi commented 2 years ago

I made a pull request for you to check out. https://github.com/CharlesGillanders/homeassistant-alphaESS/pull/15 This change works for me.

CharlesGillanders commented 2 years ago

PyPi is an existing large 3rd party repository of Python modules – HA expects to pull any required module from PyPi.

So to get a helper module accessible to HA you need to get it added to PyPi. Thankfully that’s all relatively straightforward but it means the functionality doesn’t come from my Repo it comes from the code that I previously uploaded to PyPi, any time I need to make a change to that library I need to submit the revised version to PyPi.

Charles Charles Gillanders | Personal Account @.**@.> Please consider the environment before printing this e-mail

From: Tupsi @.> Sent: Friday 22 April 2022 13:59 To: CharlesGillanders/homeassistant-alphaESS @.> Cc: Charles Gillanders @.>; Comment @.> Subject: Re: [CharlesGillanders/homeassistant-alphaESS] EV charger readings (Issue #12)

found that line thanks, but how does HA knows where to get the library from? Does it get fetched automatically from your repo? Then it should be some sort of config, or do you have to request that your lib be included in HA at some point? Also I went over your lib and I do not see anything which has to be changed there; you grap the whole data field from the json, so the charger entry should already be in there, when this addon requests it, no?

— Reply to this email directly, view it on GitHubhttps://github.com/CharlesGillanders/homeassistant-alphaESS/issues/12#issuecomment-1106489396, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMWX2MCPXG37QKYVNTGLI3TVGKPBLANCNFSM5SOTO5EA. You are receiving this because you commented.Message ID: @.**@.>>