dmslabsbr / hoymiles

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

Improvement on installation description #123

Closed TiPunch69 closed 7 months ago

TiPunch69 commented 9 months ago

I tried to install you add-on, but the readme seems to be a little bare bone. I followed it to the end and checked the protocol tab - all seems to be working, or at least there are no errors. But how do I get my solar system in the devices? The frontend tab says "Bad Gateway" but I am not sure if this is ok.

Could you extend the installation and usage instructions.

Thanks and Best Regards

therealpanse commented 9 months ago

got the same error. I guess it's something requiring additional configuration of MQTT?

[19:48:30] INFO: /data/secrets.ini not exists! Getting mqtt data... [19:48:30] ERROR: Got unexpected response from the API: Service not enabled [19:48:31] INFO: null [19:48:31] INFO: {"supervisor":"2023.11.6","homeassistant":"2023.12.0","hassos":"11.2","docker":"24.0.7","hostname":"homeassistant","operating_system":"Home Assistant OS 11.2","features":["reboot","shutdown","services","network","hostname","timedate","os_agent","haos","resolved","journal","disk","mount"],"machine":"generic-x86-64","arch":"amd64","state":"running","supported_arch":["amd64","i386"],"supported":true,"channel":"stable","logging":"info","timezone":"Europe/Berlin"} [19:48:31] INFO: {"supervisor":"2023.11.6","homeassistant":"2023.12.0","hassos":"11.2","docker":"24.0.7","hostname":"homeassistant","operating_system":"Home Assistant OS 11.2","features":["reboot","shutdown","services","network","hostname","timedate","os_agent","haos","resolved","journal","disk","mount"],"machine":"generic-x86-64","arch":"amd64","state":"running","supported_arch":["amd64","i386"],"supported":true,"channel":"stable","logging":"info","timezone":"Europe/Berlin"} dmslabs - Home Assistant HoyMiles Solar Data Gateway Add-on 2023-12-07 19:48:31,296 - HoymilesAdd-on - INFO - ********** dmslabs&Cosik Hoymiles Gateway v.1.0.8 2023-12-07 19:48:31,296 - HoymilesAdd-on - INFO - Starting up... 2023-12-07 19:48:31 2023-12-07 19:48:31,296 - HoymilesAdd-on - INFO - Using Internal MQTT Server: 2023-12-07 19:48:31,296 - HoymilesAdd-on - INFO - Using Internal MQTT User: 2023-12-07 19:48:31,296 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/iam/auth_login 2023-12-07 19:48:32,695 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - I got the token!! :-) 2023-12-07 19:48:32,695 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_find 2023-12-07 19:48:32,980 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree 2023-12-07 19:48:33,846 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_find_details 2023-12-07 19:48:34,743 - HoymilesAdd-on.mqttapi.Mqtt - INFO - Starting MQTT 2023-12-07 19:48:34,743 - HoymilesAdd-on.mqttapi.Mqtt - ERROR - Invalid host.

Cosik commented 9 months ago

Hi, what do you expect from instruction?

therealpanse commented 9 months ago

well, I guess since at least 2 people got the same "invalid host" error, at least how to deal with that. that MQTT thingy in your code seems not to play well with Cloudflare. Maybe it's a route back thing? Also, is it supposed to produce entities that you can add to your energy dashboard? because those don't show up on my end.

Cosik commented 9 months ago

@therealpanse only you got invalid host and sorry, without debug logs and more details about your configuration I'm not able to do anything. Also topic is "Improvement on installation description". Maybe at weekend I will have some time to do it, because I don't have installed this addon

therealpanse commented 9 months ago

image that error is the same. It's just represented in different terms. I just assume the original TO got the same error, since that's what I got visually, complementing the log entry of "invalid host". I guess somewhere along the way there's some routing out and back that provokes that issue

therealpanse commented 9 months ago

just to be clear: that Host is working, since I tried to connect from it.

Cosik commented 9 months ago

If it is UI - it is not working and was asked many times. In logs you have 19:48:34,743 - HoymilesAdd-on.mqttapi.Mqtt - ERROR - Invalid host. and it is different issue what was described in the first post. So it mean that you provide wrongly mqtt broker address.

Please try to use any mqtt script which is using paho lib and try to connect to the broker from device on which HA is running.

therealpanse commented 9 months ago

could to provide at least the basics for configurations for any users not familiar? You tell anyone to insert some console commands, but that doesn't include any instructions if anything else has to be configured. I think that is the underlying issue that matches the issue description

Cosik commented 9 months ago

Here is full instruction how to do it using Home Assistant, and should work out of the box and now it is added to main README.md file `## Configuration:

UI is not working and could show "Bad Gateway" which is normal and expected.

Add-on is desigend to use MQTT messages to send data to Home Assistant instance. By default credentials and server name is taken from Home Assistant. If you use other broker or using your own one it is required to make external and fill server and credentials for connection.

To get it proper working you have also pass credentials for Hoymiles Cloud access and your plant ID.

If evrything is set correctly new MQTT entities will be visible on HA.`

But if you run it standalone discussion is different, but I will not guess that some one do something with setting something and something is not working. To less details...

NeonGreenT commented 9 months ago

Hey there, I've installed everything and have it running but no new entities appear. I checked the (mosquitto) MQTT broker via MQTT-Explorer and found all the hoymiles topics. In an desperate act I added them as MQTT sensors to my configuration.yaml which kind of also works. I figure this might be more of a mosquitto issue rather than an hoymiles addon issue, but apart from a 'connection success' I can't pull much information from its log. Have I missed something?

**Addon-Log:**
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Starting add-on container...
Mon Dec 11 10:23:07 CET 2023
total 24
drwxr-xr-x    5 root     root          4096 Dec 11 10:23 .
drwxr-xr-x    1 root     root          4096 Dec 11 10:23 ..
drwxr-xr-x    2 root     root          4096 Dec  3 19:40 __pycache__
drwxr-xr-x    2 root     root          4096 Dec 11 00:26 jsons
-rw-------    1 root     root           387 Dec 11 10:23 options.json
drwxr-xr-x    2 root     root          4096 Dec  3 19:40 templates
[10:23:07] INFO: /data/secrets.ini not exists!
Getting mqtt data...
[10:23:08] INFO: null
[10:23:09] INFO: {"supervisor":"2023.11.6","homeassistant":"2023.12.1","hassos":"11.2","docker":"24.0.7","hostname":"homeassistant","operating_system":"Home Assistant OS 11.2","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":"Europe/Berlin"}
[10:23:09] INFO: {"supervisor":"2023.11.6","homeassistant":"2023.12.1","hassos":"11.2","docker":"24.0.7","hostname":"homeassistant","operating_system":"Home Assistant OS 11.2","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":"Europe/Berlin"}
dmslabs - Home Assistant HoyMiles Solar Data Gateway Add-on
2023-12-11 10:23:10,440 - HoymilesAdd-on - INFO - ********** dmslabs&Cosik Hoymiles Gateway  v.1.1.0
2023-12-11 10:23:10,441 - HoymilesAdd-on - INFO - Starting up... 2023-12-11 10:23:10
2023-12-11 10:23:10,442 - HoymilesAdd-on - INFO - Using External MQTT Server: True
2023-12-11 10:23:10,443 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/iam/auth_login
2023-12-11 10:23:12,123 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - I got the token!!  :-)
2023-12-11 10:23:12,123 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_find
2023-12-11 10:23:12,494 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree
2023-12-11 10:23:12,884 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_find_details
2023-12-11 10:23:13,305 - HoymilesAdd-on.mqttapi.Mqtt - INFO - Starting MQTT 192.168.178.86
2023-12-11 10:23:13,329 - HoymilesAdd-on.mqttapi.Mqtt - INFO - MQTT connected with result code 0
2023-12-11 10:23:13,330 - HoymilesAdd-on.mqttapi.Mqtt - INFO - Connected to 192.168.178.86
2023-12-11 10:23:14,341 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree
2023-12-11 10:23:14,697 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_count_station_real_data
2023-12-11 10:23:15,680 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - last_data_time 2023-12-11T10:14:59+01:00
2023-12-11 10:23:15,681 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_find_details
2023-12-11 10:23:16,078 - HoymilesAdd-on - INFO - Solar data publication...2023-12-11 10:23:16.078775
2023-12-11 10:23:16,080 - HoymilesAdd-on - INFO - _2147260 data publication...2023-12-11 10:23:16.080476
2023-12-11 10:23:16,081 - HoymilesAdd-on - INFO - HMS-800W-2T_8777290 data publication...2023-12-11 10:23:16.081678
2023-12-11 10:23:16,088 - HoymilesAdd-on - INFO - Main loop start!
2023-12-11 10:31:16,088 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree
2023-12-11 10:31:16,761 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_count_station_real_data
2023-12-11 10:31:17,063 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - last_data_time 2023-12-11T10:29:58+01:00
2023-12-11 10:31:17,063 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_find_details
2023-12-11 10:31:18,014 - HoymilesAdd-on - INFO - Solar data publication...2023-12-11 10:31:18.014580
2023-12-11 10:31:18,016 - HoymilesAdd-on - INFO - _2147260 data publication...2023-12-11 10:31:18.016881
2023-12-11 10:31:18,018 - HoymilesAdd-on - INFO - HMS-800W-2T_8777290 data publication...2023-12-11 10:31:18.018219
2023-12-11 10:39:18,020 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm/station_select_device_of_tree
2023-12-11 10:39:20,204 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_count_station_real_data
2023-12-11 10:39:21,720 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - last_data_time 2023-12-11T10:29:58+01:00
2023-12-11 10:39:21,720 - HoymilesAdd-on.hoymilesapi.Hoymiles - INFO - Loading: https://global.hoymiles.com/platform/api/gateway/pvm-data/data_find_details
2023-12-11 10:39:23,254 - HoymilesAdd-on - INFO - Solar data publication...2023-12-11 10:39:23.254434
2023-12-11 10:39:23,256 - HoymilesAdd-on - INFO - _2147260 data publication...2023-12-11 10:39:23.256401
2023-12-11 10:39:23,257 - HoymilesAdd-on - INFO - HMS-800W-2T_8777290 data publication...2023-12-11 10:39:23.257680
** mosquitto-log **
2023-12-11 10:23:13: New connection from 192.168.178.86:50807 on port 1883.
2023-12-11 10:23:13: New client connected from 192.168.178.86:50807 as 6VM2SUGm2XniyVLBuPBcKz (p1, c1, k60, u'mqtt-user').
2023-12-11 10:27:03: Saving in-memory database to /data//mosquitto.db.
** Part of my configuration.yaml **
mqtt:
  sensor:
    - name: "Connection"
      state_topic: "home/solar/json_8777290"
      unit_of_measurement: ""
      value_template: "{{ value_json.connect }}"

    - name: "Alarm Code"
      state_topic: "home/solar/json_8777290"
      unit_of_measurement: ""
      value_template: "{{ value_json.alarm_code }}"

    - name: "Alarm Text"
      state_topic: "home/solar/json_8777290"
      unit_of_measurement: ""
      value_template: "{{ value_json.alarm_string }}"

    - name: "Solar Today Eq"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "kWh"
      value_template: "{{ value_json.today_eq }}"

    - name: "Real Power"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "W"
      value_template: "{{ value_json.real_power }}"

    - name: "Solar Month Eq"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "kWh"
      value_template: "{{ value_json.month_eq }}"

    - name: "Solar Year Eq"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "kWh"
      value_template: "{{ value_json.year_eq }}"

    - name: "Solar CO2 Emission Reduction"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "kg"
      value_template: "{{ value_json.co2_emission_reduction }}"

    - name: "Solar Plant Tree"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "trees"
      value_template: "{{ value_json.plant_tree }}"

    - name: "Solar Data Time"
      state_topic: "home/solar/json_2359680"
      value_template: "{{ value_json.data_time }}"

    - name: "Solar Array Size kW"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "kW"
      value_template: "{{ value_json.array_size_kW }}"

    - name: "Solar Today Eq Wh"
      state_topic: "home/solar/json_2359680"
      unit_of_measurement: "Wh"
      value_template: "{{ value_json.today_eq_Wh }}"
Cosik commented 9 months ago

@NeonGreenT adding them as separate sensors in config is not required. You should see new mqtt devices in HA. Depending on your solar installation it could be few devices. One should be solar installation as main device and inverters with statuses as separate. What is more each entity of device should have correct parameters which allow you to use them. Please check again and let me know.

bridgewatermedia commented 9 months ago

Cosik fixed the "Bad Gateway" error. Thanks Cosik.