DasLetzteEinhorn / AlphaESS_Monitor_Hass

Apache License 2.0
12 stars 1 forks source link

Is this a functioning HA addon? #1

Closed tbgoose closed 3 years ago

tbgoose commented 3 years ago

Hey

Does this work? What are the install steps to get it working?

DasLetzteEinhorn commented 3 years ago

The plugin is just a web scraper based on Selenium. It is very resource intensive and does not work very reliably. Since AlphaEss has announced an API (probably Modbus-TPC), I think this plugin is not very useful, because it breaks from time to time when the website is updated.

If you still want to test it:

Add https://github.com/DasLetzteEinhorn/AlphaESS_Monitor_Hass as a repo and install the addon. My example settings:

log_level: debug
base_topic: alphaess
timeout: 10
username: '!secret alpha_user'
password: '!secret alpha_pass'
mqtt_username: '!secret mqtt_user'
mqtt_password: '!secret mqtt_pass'
mqtt_host: 192.168.42.113

If you run the plugin on the same instance as the MQTT broker, the last three lines can be omitted.

To get the sensors working, I use the following (on my main instance):

sensor:
  - platform: mqtt
    name: "Solar Battery"
    state_topic: "alphaess/battery"
    unit_of_measurement: '%'
    icon: mdi:battery
  - platform: mqtt
    name: "Solar Generation"
    state_topic: "alphaess/pv"
    unit_of_measurement: 'kW'
    icon: mdi:solar-panel-large
  - platform: mqtt
    name: "Solar Feed In"
    state_topic: "alphaess/feed_in"
    unit_of_measurement: 'kW'
    icon: mdi:transmission-tower
  - platform: mqtt
    name: "Solar Grid Consumption"
    state_topic: "alphaess/grid_consumption"
    unit_of_measurement: 'kW'
    icon: mdi:transmission-tower
  - platform: mqtt
    name: "Solar Load"
    state_topic: "alphaess/load"
    unit_of_measurement: 'kW'
    icon: mdi:power-socket-de
tbgoose commented 3 years ago

Cheers

I can't seem to add it as a repo under HACS, it states "Repository structure for master is not compliant".

I have it working via this git instead https://github.com/wooni005/alpha-ess-web_mqtt as a service on my rpi running HA and it is working.

Do you have any more info about the modbus-tcp stuff? I can't find anything about that anywhere...

Would it be possible to fetch some other information or perhaps use the real time power graph on tab 1 to fetch more accurate numbers? You can see here that the real time power graph has values in watts for all of the things we are fetching, giving much more accurate values.

Solar Generation <ul data-v-af771e70="" class="diagram-data diagram-data-Sloar"><li data-v-af771e70="" class="diagram-data-title">Solar Module</li></ul>

<ul data-v-af771e70="" class="diagram-data diagram-data-02"><li data-v-af771e70="" class="" style="color: rgb(255, 149, 0);">897W</li> <li data-v-af771e70="" style="color: rgb(255, 149, 0);"><img data-v-af771e70="" src="../../static/img/dynamic_pv_arrowhead_1.6ecc454.gif" class="diagram-gif"></li></ul>

Feed in <ul data-v-af771e70="" class="diagram-data diagram-data-03"><li data-v-af771e70="" style="color: rgb(135, 202, 22);">1008W</li> <li data-v-af771e70="" style="color: rgb(255, 149, 0);"><img data-v-af771e70="" src="../../static/img/dynamic_pv_arrowhead_2.8c9a690.gif" class="diagram-gif"></li></ul>

<ul data-v-af771e70="" class="diagram-data diagram-data-04"><li data-v-af771e70="" style="" class="diagram-data-title">Feed-in</li></ul>

Flow to Battery <ul data-v-af771e70="" class="diagram-data diagram-data-05" style="width: 50px;"><li data-v-af771e70="" style="" class="diagram-data-title">Battery</li></ul>

<ul data-v-af771e70="" class="diagram-data diagram-data-06"><li data-v-af771e70="" style="color: rgb(135, 202, 22);">108.40W</li> <!----> <!----> <li data-v-af771e70="" style="color: rgb(255, 149, 0);"><img data-v-af771e70="" src="../../static/img/dynamic_battery_arrowhead_2.6e7767b.gif" class="diagram-gif"></li></ul>

Battery Charge <ul data-v-af771e70="" class="diagram-data diagram-data-07"><li data-v-af771e70="" class="diagram-data-title">SOC</li> <li data-v-af771e70="" style="color: rgb(135, 202, 22);">10.8%</li></ul>

House Load <ul data-v-af771e70="" class="diagram-data diagram-data-08"><li data-v-af771e70="" style="color: rgb(87, 152, 209);">811.60W</li> <li data-v-af771e70="" style="color: rgb(255, 149, 0);"><img data-v-af771e70="" src="../../static/img/dynamic_load_arrowhead_1.1c2cca8.gif" class="diagram-gif"></li> <!----> <!----></ul>

<ul data-v-af771e70="" class="diagram-data diagram-data-09"><li data-v-af771e70="" class="diagram-data-title">Load</li></ul>

The same page also has total generation values

<div data-v-af771e70="" class="generation"><div data-v-af771e70="" class="title">Generation</div> <div data-v-af771e70="" class="number" style="padding-top: 10px;"><p data-v-af771e70="" class="word">Today's Generation</p> <p data-v-af771e70="" class="num blue">0.9kWh</p> <p data-v-af771e70="" class="word">Total Generation</p> <p data-v-af771e70="" class="num blue">9226.0kWh</p> <div data-v-af771e70="" class="pic"><img data-v-af771e70="" src="" alt="" class="pic_one"></div></div></div>

I don't know how easy it would be to parse these values as well as / instead of the ones from the power diagram but they are far more accurate and hence useful for real time visualisation. Plus it includes house load which would be very useful for automations.

Also capturing these values would be helpful, as static glances at generation likely isn't as useful (in my mind) compared with totals for a 24 hr period for some things, like consumption

<div data-v-af771e70="" class="options">Today's Generation</div>
<div data-v-af771e70="" class="options">1.10kWh</div>
<div data-v-af771e70="" class="options">Today's Consumption</div>
<div data-v-af771e70="" class="options">3.84kWh</div>
<div data-v-af771e70="" class="options">Today's Grid Consumption</div>
<div data-v-af771e70="" class="options">2.74kWh</div>
MarioCakeDev commented 3 years ago

It may be possible to parse these more accurate values, but what would you gain from that? In my opinion you would gain effectively nothing because I think that even the measurements aren't accurate enough to represent the reality. You would also not need the real-time data because you would only fetch the data every minute or so. So in worst case you would be off by one minute on the data. If you really want to see the data in real-time you can visit the website.

We also don't want to fetch the data too often or the account might get blocked or banned. Don't know the rules here but better safe than sorry.

It's a long time ago I implemented that stuff, but it seems like the house load is the only new data which we could grab from the website, isn't it?

Maybe we could add more data for the sensors. Which would have a befinifit compare to the more accurate or real-time data.

@DasLetzteEinhorn do we want to implement getting more data?

tbgoose commented 3 years ago

That is true, I just feel if you're parsing values from the website you may as well grab the most accurate. I feel like my system is very responses to changes in load, I do think the measurements are quite representative on the real time power graph. I understand that they are not real-time by the time I look at them in HA though. It would be cool, and certainly make for prettier graphs if the data had more granularity.

I am not a programmer, so I have no idea how hard it would be to implement what I am asking of you. I've had a look at the code of the .py script and obviously played around in the dev console on the website to see how it works, but as the data is presented in a different format its not an easy swap to scrape these other values.

I would particularly be interested in the totals, as I think they tell an important part of the solar battery story.

TBH I use the app a lot if I want real time info, having this in HA is just a fun luxury, like most home automation :)

MarioCakeDev commented 3 years ago

@tbgoose We reverse engineered the API from AlphaEss an succeeded to add a variety of new metrics. The metrics aren't as pretty as the metrics before, but it is still possible to get the data from these metrics.

Here is an example:

{
    "_id": "<some_id>",
    "createtime": "2021-05-25 18:42:01",
    "uploadtime": "2021-05-25 20:41:25",
    "sn": "<some_serial_number>",
    "ppv1": 31,
    "ppv2": 32,
    "ppv3": null,
    "preal_l1": 703,
    "preal_l2": 0,
    "preal_l3": 0,
    "pmeter_l1": 172,
    "pmeter_l2": -512,
    "pmeter_l3": 349,
    "pmeter_dc": 0,
    "soc": 91.2,
    "factory_flag": 0,
    "pbat": 728.566,
    "sva": 777,
    "varac": 0,
    "vardc": 0,
    "ev1_power": 0,
    "ev1_chgenergy_real": 0,
    "ev1_mode": 0,
    "ev2_power": 0,
    "ev2_chgenergy_real": 0,
    "ev2_mode": 0,
    "ev3_power": 0,
    "ev3_chgenergy_real": 0,
    "ev3_mode": 0,
    "ev4_power": 0,
    "ev4_chgenergy_real": 0,
    "ev4_mode": 0,
    "poc_meter_l1": 0,
    "poc_meter_l2": 0,
    "poc_meter_l3": 0
}

Properties translated to old metrics: soc -> State of Charge pbat -> Battery usage (positive -> using battery, negative -> charging battery) pmeber_l1/l2/l3 -> Negative: Feed-in, Positive: Grid Consumption preal_l1/l2/l3 -> Power generation

We need to check if those really relate to the old metrics. So take this info with a grain of salt. I need to look into what exactly represents the Load. And I currently have no clue what all the other properties reprecent exactly.

@DasLetzteEinhorn will prepare the sensors and how to use the metrics and we will update the documentation in the following days.

We have improved the performance and stability greatly with the new method! Thank you for your interest in this project. The addon was very unstable and wasn't really that usable. Now it is much better.

There might be a even more performant method, but this is something we might not tackle for now. You can have a look into this repository which is currently under work in progress but might be the base for a faster method to gather the data.

tbgoose commented 3 years ago

Very cool :) can't wait to see what you end up with.

Is this addon only for hassio? I am running HA in docker on an rpi4, so do not have the addon store. I have HACS but it wouldn't install with that.

Cheers

DasLetzteEinhorn commented 3 years ago

Yup, this addon is for Home Assistant (formerly called Hass.io), not just Home Assistant Core. In my case it runs on a supervised installation on my RasPi 4. And you are right, it is not available in HACS. We just updated the readme so you can try it if you want to switch to Home Assistant (not only Core).

tbgoose commented 3 years ago

So it is possible to install this on a HA instance running on docker? I don't have the addon's store when you run it this way, and cloning the git into the custom components folder doesn't seem to achieve anything...

DasLetzteEinhorn commented 3 years ago

I don't think, this addon would run just in docker as it is. And also it's not a custom component (so it's not available in HACS etc.), but maybe we will turn it into an integration later. For now, it's just an addon.