dmslabsbr / hoymiles

Hoymiles ADD-ON for Home Assistant
126 stars 30 forks source link

is possible to add consumption from Grid #111

Closed go2thanawat closed 9 months ago

go2thanawat commented 1 year ago

i see hoymile cloud is has "electric consumption from grid data"
is possible to add consumption from Grid to this add-on

Cosik commented 1 year ago

Yes, it is possible, but I have no access to such installation.

mmz06 commented 1 year ago

Hi @Cosik Shall I provide you with a user account on my plant so you can access this maybe ? I'm not really familiar with this, how can I provide you the credentials, as I can't find any way to send it to you as personal ?

Cosik commented 1 year ago

@mmz06 yes, probably I will need access to your plant. When I will have some spare time I will back to you.

Wind06 commented 1 year ago

Hi @Cosik did you get access to such configuration to get Grid data ? If not I can give you access to my plant, I am interested by getting such information. Thanks,

Cosik commented 1 year ago

sorry for delay. @Wind06 no, I have no access to such installation.

Wind06 commented 1 year ago

Hi @Cosik, yes I know but if I give you access to my plant would it be possible for you to get such data with the Addon ?

Cosik commented 1 year ago

Should be, I need to check responses of requests and adapt code if possible.

Wind06 commented 1 year ago

Can I send you the access on a private mailbox 😉

Cosik commented 1 year ago

Yes, please.

Wind06 commented 1 year ago

hmm not very familiar with GitHub, but cannot find your email address. How can I proceed?

Cosik commented 1 year ago

@Wind06 maybe reach me over discord.

Wind06 commented 1 year ago

Hi Cosik, I think that you send me an invite under discord but I lost it, can you please resend it. Thanks and sorry for that.

ebiancarelli commented 1 year ago

My system returns this block of data { "today_eq": "0.17", "month_eq": "131.1", "year_eq": "1805.07", "total_eq": "1805.07", "real_power": "277.1", "co2_emission_reduction": "1.79966", "plant_tree": "98", "data_time": "2023-10-27 08:15:58", "last_data_time": "2023-10-27T08:15:58-06:00", "capacitor": "2000.0", "is_balance": 0, "is_reflux": 1, "reflux_station_data": { "start_date": "", "end_date": "", "pv_power": "277.1", "grid_power": "-180", "load_power": "457.1", "bms_power": "0", "bms_soc": "0", "inv_num": 0, "meter_location": 2, "pv_to_load_eq": "0", "load_from_pv_eq": "0", "meter_b_in_eq": "5317230.832999999", "meter_b_out_eq": "0", "bms_in_eq": "0", "bms_out_eq": "0", "self_eq": "1805071", "pv_eq_total": "0", "use_eq_total": "0", "flows": [ { "out": 2, "in": 1 }, { "out": 4, "in": 1 } ], "icon_pv": 0, "icon_grid": 1, "icon_load": 1, "icon_bms": 1, "icon_gen": 0, "icon_pvi": 0, "mb_in_eq": { "today_eq": "0", "month_eq": "0", "year_eq": "0", "total_eq": "0" }, "mb_out_eq": { "today_eq": "0", "month_eq": "0", "year_eq": "0", "total_eq": "0" } }, "real_power_measurement": "277.1", "real_power_total_increasing": "277.1", "power_ratio": "13.9", "capacitor_kW": "2.0", "today_eq_Wh": "167.0" }

The grid info is contained in an enclosed json struct here with grid_power and load_power being interesting data points to graph. "reflux_station_data": { "start_date": "", "end_date": "", "pv_power": "277.1", "grid_power": "-180", "load_power": "457.1", "bms_power": "0", "bms_soc": "0", "inv_num": 0, "meter_location": 2, "pv_to_load_eq": "0", "load_from_pv_eq": "0", "meter_b_in_eq": "5317230.832999999", "meter_b_out_eq": "0", "bms_in_eq": "0", "bms_out_eq": "0", "self_eq": "1805071", "pv_eq_total": "0", "use_eq_total": "0", "flows": [ { "out": 2, "in": 1 }, { "out": 4, "in": 1 } ], "icon_pv": 0, "icon_grid": 1, "icon_load": 1, "icon_bms": 1, "icon_gen": 0, "icon_pvi": 0, "mb_in_eq": { "today_eq": "0", "month_eq": "0", "year_eq": "0", "total_eq": "0" }, "mb_out_eq": { "today_eq": "0", "month_eq": "0", "year_eq": "0", "total_eq": "0" } },

Cosik commented 1 year ago

@ebiancarelli but I need requests also to know how to implement it.

ebiancarelli commented 1 year ago

The block of JSON shown is gotten from MQTT using the 'stable' branch of code. If I guess, I think the json to dictionary is only taking the top level of tags, and not recursing into tags with additional elements.

Cosik commented 1 year ago

But need more info, current implementation based on pvm/station_select_device_of_tree which defined how installation looks like. On this list has to be meter also. Then I could add it as other stuff.

ebiancarelli commented 1 year ago

I sent you a friend request on Discord.

ebiancarelli commented 1 year ago

Does this help?

2023-10-27 12:14:28,888 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree

2023-10-27 12:14:28,890 - HoymilesAdd-on.hoymilesapi.Hoymiles - DEBUG - {'Content-Type': 'application/json;charset=UTF-8', 'Cache-Control': 'no-cache', 'Host': 'global.hoymiles.com', 'Connection': 'keep-alive', 'Accept': 'application/json, text/plain, /', 'Accept-Encoding': 'gzip, deflate, br', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36', 'Accept-Language': 'pt-BR,pt;q=0.9,it-IT;q=0.8,it;q=0.7,es-ES;q=0.6,es;q=0.5,en-US;q=0.4,en;q=0.3', 'Cookie': "'uid=fff9c382-389f-4a47-8dc9-c5486fc3d9f5; hm_token=1.wPHrxCR7XZ8DK7p2Lx7asgCp200MhDHPv9iBs2irrgL69YYUMj9url4yZ47MDvw9vwSuntubZ4JZi5CK3IkjVf; Path=/; Domain=.global.hoymiles.com;Expires=Sat, 30 Mar 2024 22:11:48 GMT;'", 'Content-Length': '69'}

2023-10-27 12:14:30,313 - HoymilesAdd-on.hoymilesapi.Hoymiles - DEBUG - content: b'{"status":"0","message":"success","data":[{"id":980570,"sn":"10FD81844117","vc":"","dtu_sn":"10FD81844117","type":1,"version":3,"replace_num":0,"model_no":"DTU-Pro-S","soft_ver":"V00.02.14","hard_ver":"H09.06.01","extend_data":{},"warn_data":{"_rw":"","connect":true,"warn":false},"children":[{"id":4457570,"sn":"116481038963","vc":"","dtu_sn":"10FD81844117","type":3,"version":3,"replace_num":0,"model_no":"HMS-1800-4T","soft_ver":"V01.00.14","hard_ver":"H00.04.00","extend_data":{"grid_name":"","port_array":[1,2,3,4],"grid_id":0,"grid_version":""},"warn_data":{"warn":false,"connect":true},"children":[]}]}],"systemNotice":null}'

Wind06 commented 1 year ago

I sent you a friend request on Discord.

Hmm are you sure I did not get any request .... check wind0613 instead of wind06

ebiancarelli commented 1 year ago

I sent you a friend request on Discord.

Hmm are you sure I did not get any request .... check wind0613 instead of wind06

I sent the request to @Cosik .

Wind06 commented 1 year ago

Ah ok :-)

Cosik commented 1 year ago

@ebiancarelli no sorry it not help, I didn't see meter on this request. About discord, I realized that it changed user identyfication so I will be Cosik#6329

Cosik commented 1 year ago

@ebiancarelli and @Wind06 I'm looking in to code, and what is send and I realized that data could be added by manual configuration of mqtt entities.

Cosik commented 1 year ago

@ebiancarelli and @Wind06 please check #119 and test it.

Wind06 commented 1 year ago

@Cosik Many thanks for your help and quick update. I will test it tomorrow and give an update

Wind06 commented 1 year ago

Hello, all data seems to be reported correctly. A big THANKS to @Cosik for his quick help and new version of the Addon.

ebiancarelli commented 1 year ago

How do I test? Do I need to run the 'edge' version of the addon?

Cosik commented 1 year ago

it is on edge version

ebiancarelli commented 1 year ago

I'm not seeing anything different after waiting for the sensor data to be updates (I can see MQTT messages). I can't seem to get the edge version to show me DEBUG logs either so I can't troubleshoot

image
Wind06 commented 1 year ago

Maybe need to reload the Sensors view, or delete it and recreate it. check also the version of the Addon it must be

HoyMiles Solar Gateway Edge Addon Current version: 1.2.1

Cosik commented 1 year ago

@ebiancarelli did you check configuration?

ebiancarelli commented 1 year ago

My addon version is 1.1.1 (edge)...

Wind06 commented 1 year ago

you need to update it :-)

ebiancarelli commented 1 year ago

Yes... How do I force that to happen?

@Cosik , I have

DEVELOPERS_MODE: true
LOG_LEVEL: DEBUG
Wind06 commented 1 year ago

When selecting the Addon on top of your screen you should be prompted for new version update. You can try selecting the "Additional modules shop" and select top right "Check for updates"

ebiancarelli commented 1 year ago

don't see it when I run ha addons info 44349f66_hoymiles_solardata_edge

version: 1.1.1
version_latest: 1.1.1

Troubleshooting: I've nuked the install, removed the repo from AddOn Store. Then, added the repo back to the Addon Store, selected Edge Reinstalled, reconfigured.

{"supervisor":"2023.10.1","homeassistant":"2023.10.5","hassos":"11.1","docker":"24.0.6","hostname":"homeassistant","operating_system":"Home Assistant OS 11.1","features":["reboot","shutdown","services","network","hostname","timedate","os_agent","haos","resolved","journal","disk","mount"],"machine":"qemux86-64","arch":"amd64","state":"running","supported_arch":["amd64","i386"],"supported":true,"channel":"stable","logging":"info","timezone":"America/Costa_Rica"}

[10:09:59] INFO: {"supervisor":"2023.10.1","homeassistant":"2023.10.5","hassos":"11.1","docker":"24.0.6","hostname":"homeassistant","operating_system":"Home Assistant OS 11.1","features":["reboot","shutdown","services","network","hostname","timedate","os_agent","haos","resolved","journal","disk","mount"],"machine":"qemux86-64","arch":"amd64","state":"running","supported_arch":["amd64","i386"],"supported":true,"channel":"stable","logging":"info","timezone":"America/Costa_Rica"}

Cosik commented 1 year ago

Because you still using stable version... Please show debug logs.

ebiancarelli commented 1 year ago

Let me make sure I'm adding the addon properly. This is what I see in the AddOn Store after adding the repo.

image

Then I select the 'Edge' version.

Is that correct?

Wind06 commented 1 year ago

Yes that's correct and you should see version 1.2.1

ebiancarelli commented 1 year ago

Here are infos from the command line. and a selected snip -

update_available: false
url: https://github.com/dmslabsbr/hoymiles/tree/master/edge
usb: false
version: 1.1.1
version_latest: 1.1.1

➜ ~ ha addons upgrade 44349f66_hoymiles_solardata_edge
Processing... Done.

Error: No update available for add-on 44349f66_hoymiles_solardata_edge ➜ ~ ha addons info 44349f66_hoymiles_solardata_edge advanced: false apparmor: default arch:

Cosik commented 1 year ago

@ebiancarelli please check again. I've found error in configuration files.

ebiancarelli commented 1 year ago

I removed the repo and added it back.

I see that the stable addon is v1.0.8. Edge is v1.1.1.

Does HA cache addon info that I need to purge?

image

------ supervisor logs ------ 23-10-29 12:11:31 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/bropat/hassio-eufy-security-ws repository 23-10-29 12:11:31 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/esphome/home-assistant-addon repository 23-10-29 12:11:31 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/dmslabsbr/hoymiles repository 23-10-29 12:11:31 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/home-assistant/addons repository 23-10-29 12:11:31 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/hassio-addons/repository repository 23-10-29 12:11:32 INFO (MainThread) [supervisor.store] Loading add-ons from store: 75 all - 0 new - 0 remove 23-10-29 12:11:32 INFO (MainThread) [supervisor.store] Loading add-ons from store: 75 all - 0 new - 0 remove 23-10-29 12:11:35 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from a0d7b954_ssh 23-10-29 12:13:23 INFO (MainThread) [supervisor.store.git] Removing custom add-on repository https://github.com/dmslabsbr/hoymiles 23-10-29 12:13:23 INFO (MainThread) [supervisor.store] Loading add-ons from store: 73 all - 0 new - 2 remove 23-10-29 12:13:27 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from a0d7b954_ssh 23-10-29 12:13:32 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from a0d7b954_ssh 23-10-29 12:13:55 INFO (MainThread) [supervisor.store.git] Cloning add-on https://github.com/dmslabsbr/hoymiles repository 23-10-29 12:13:59 INFO (MainThread) [supervisor.store] Loading add-ons from store: 75 all - 2 new - 0 remove 23-10-29 12:14:04 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/bropat/hassio-eufy-security-ws repository 23-10-29 12:14:04 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/esphome/home-assistant-addon repository 23-10-29 12:14:04 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/home-assistant/addons repository 23-10-29 12:14:04 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/hassio-addons/repository repository 23-10-29 12:14:04 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/dmslabsbr/hoymiles repository 23-10-29 12:14:05 INFO (MainThread) [supervisor.store] Loading add-ons from store: 75 all - 0 new - 0 remove 23-10-29 12:14:05 INFO (MainThread) [supervisor.store] Loading add-ons from store: 75 all - 0 new - 0 remove 23-10-29 12:14:08 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from a0d7b954_ssh

Cosik commented 1 year ago

@ebiancarelli sorry there were much more things to fix. I wonder why I didn't noticed that oldStable disappear. Now by removing and adding repo again, you should see 1.2.1 in edge and oldStable version. image

ebiancarelli commented 1 year ago

That did it for me. I was able to install v1.2.1 and see the new meter sensors.

Thanks!!!

mmz06 commented 1 year ago

Works perfectly from my side as well. Thank you @Cosik :-)