Browse Source

Merge pull request #352 from geronet1/main

MQTT last will with uptime
pull/357/head
lumapu 2 years ago
committed by GitHub
parent
commit
1160672e29
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 69
      .github/ISSUE_TEMPLATE/report-ahoy.md
  2. 155
      .github/ISSUE_TEMPLATE/report.yaml
  3. 7
      .github/workflows/compile_esp8266.yml
  4. 2
      tools/esp8266/User_Manual.md
  5. 4
      tools/esp8266/app.cpp
  6. 10
      tools/esp8266/mqtt.h
  7. BIN
      tools/homeassistant/HomeAssistantDashboardAhoy.png
  8. 3
      tools/homeassistant/README.md
  9. 99
      tools/homeassistant/dashboard.yaml
  10. 341
      tools/homeassistant/manual.yaml
  11. BIN
      tools/pcb/nRF24L01_ESP_Wemos_D1.T3001
  12. BIN
      tools/pcb/pcb_1.JPG
  13. BIN
      tools/pcb/pcb_2.JPG
  14. 8
      tools/pcb/readme.md
  15. 5
      tools/rpi/hoymiles/__init__.py
  16. 8
      tools/rpi/hoymiles/__main__.py
  17. 5
      tools/rpi/hoymiles/decoders/__init__.py
  18. 14
      tools/rpi/hoymiles/outputs.py

69
.github/ISSUE_TEMPLATE/report-ahoy.md

@ -0,0 +1,69 @@
---
name: Report Ahoy
about: question about Ahoy
title: ''
labels: ''
assignees: ''
---
## Hardware
* [ ] ESP8266
* [ ] ESP32
* [ ] Raspberry Pi
Modelname: ______
Retailer URL: ______
### nRF24L01+ Module
* [ ] nRF24L01+ you verified this is a **Plus model** capable of the required 256kBit/s mode
* [ ] **square dot** indicates original Nordic Semicon chip
* [ ] **round dot** indicates copy-cat / counterfeit SI labs chip
### Antenna:
* [ ] circuit board
* [ ] external antenna
### Power Stabilization:
* [ ] 100uF Electrolytic Capacitor
connected between +3.3V and GND (Pin 1 & 2) of the NRF Module
* [ ] Voltage stabilizing motherboard
### Connection diagram:
* [ ] Image of the your wiring attached
### Connection diagram I used:
| nRF24L01+ Pin | ESP8266/32 GPIO |
| ------------- | --------------- |
| Pin 1 GND [] | GND |
| Pin 2 +3.3V | +3.3V |
| Pin 3 CE | GPIO_2/_4 CE |
| Pin 4 CSN | GPIO15/_5 CS |
| Pin 5 SCK | GPIO14/18 SCLK |
| Pin 6 MOSI | GPIO13/23 MOSI |
| Pin 7 MISO | GPIO12/19 MISO |
| Pin 8 IRQ | GPIO_0/0 IRQ |
Note: [] GND Pin 1 has a square mark on the nRF24L01+ module
## Software
* [ ] AhoyDTU
* [ ] OpenDTU
### Version / Git SHA:
Version: _._.__
Github Hash: _______
### Build & Flash Method:
* [ ] Arduino
* [ ] ESP Tools
* [ ] Platform IO
### Desktop OS:
* [ ] Linux
* [ ] Windows
* [ ] Mac OS
### Debugging:
* [ ] USB Serial Log (attached)
* [ ] Setup settings (use our templates ... to be added)

155
.github/ISSUE_TEMPLATE/report.yaml

@ -0,0 +1,155 @@
name: "AhoyDTU bug"
description: "File a bug report"
title: "[ESP8266/ESP32/RaspberryPi] Problem Description / Beschreibung"
labels: ["bug", "needs-triage"]
assignees:
- stefan123t
body:
- type: markdown
attributes:
value: |
Bitte die Posting Guide lines lesen, Vorlage kopieren und ausfüllen und in Eurem Support Forum Eintrag posten.
Wir lesen auch gerne Deutsch, bitte fülle die u.a. Fragen aus damit wir Dir bestmöglich helfen können Danke!
Please read, copy & fill in the template from our Posting Guide lines into your Support Forum post.
We do enjoy the english language, but we need a couple of things to best support you in your goal, please fill in all / most of the details given below. Thanks!
- type: markdown
attributes:
value: "## Hardware"
- type: dropdown
id: platform
attributes:
label: Platform
description: Which Hardware are you using to run AhoyDTU on ?
options:
- ESP8266
- ESP32
- RaspberryPi
validations:
required: true
- type: input
id: model
attributes:
label: Model name
description: Please give us a precise description of your hardware and/or a link to the vendor
placeholder:
validations:
required: false
- type: dropdown
id: nrf24l01-module
attributes:
label: nRF24L01+ Module
description: |
What type of nRF24L01+ chip is on your nRF24L01+ module ?
* you verified this is a **nRF24L01+ plus** model capable of the required 256kBit/s mode ?
* **square dot** indicates original Nordic Semicon chip ?
* **round dot** indicates copy-cat / counterfeit SI labs chip
multiple: true
options:
- nRF24L01+ plus
- square dot
- round dot
- type: dropdown
id: antenna
attributes:
label: Antenna
description: What type of antenna has your nRF24L01+ module ?
options:
- circuit board
- external antenna
validations:
required: true
- type: dropdown
id: power-stabilization
attributes:
label: Power Stabilization
description: |
What kind of voltage / power stabilization have you used for your nRF24L01+ module ?
* **~100uF Elko** (Electrolytic Capacitor) connected between +3.3V and GND (Pin 1 & 2) of the nRF24L01+ Module
* special **voltage stabilizing board**
* **nothing** (yet)
options:
- ~100uF Elko
- board
- nothing
validations:
required: true
- type: textarea
id: connection-diagram
attributes:
label: Connection diagram
description: Tell us which connection diagram you used?
value: |
## Connection diagram I used:
| nRF24L01+ Pin | ESP8266/32 GPIO |
| ------------- | --------------- |
| Pin 1 GND [] | GND |
| Pin 2 +3.3V | +3.3V |
| Pin 3 CE | GPIO_2/_4 CE |
| Pin 4 CSN | GPIO15/_5 CS |
| Pin 5 SCK | GPIO14/18 SCLK |
| Pin 6 MOSI | GPIO13/23 MOSI |
| Pin 7 MISO | GPIO12/19 MISO |
| Pin 8 IRQ | GPIO_0/0 IRQ |
Note: [] GND Pin 1 has a square mark on the nRF24L01+ module
validations:
required: true
- type: checkboxes
id: connection-picture
attributes:
label: Connection picture
description:
options:
- label: I will attach/upload an Image of my wiring
validations:
required: true
- type: markdown
attributes:
value: "## Software"
- type: input
id: software-version
attributes:
label: Version
description: What version of our software are you running ?
placeholder: 0.5.17
validations:
required: true
- type: input
id: software-githash
attributes:
label: Github Hash
description: Which GitHub hash has the build of our software ?
placeholder: 5402e9b
validations:
required: true
- type: dropdown
id: build-and-flash-method
attributes:
label: Build & Flash Method
description: What software do you use to flash / build & flash our firmware images ?
options:
- ESP Tools (flash)
- Platform IO (build & flash)
validations:
required: true
- type: dropdown
id: desktop-os
attributes:
label: Desktop
description: Which operating system are you using on your desktop to build & flash ?
options:
- Linux
- Mac OS
- Windows
validations:
required: true
- type: textarea
id: debugging
attributes:
label: Debug Serial Log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
placeholder: |
- USB Serial Log (attached)
- Setup settings (use our templates ... to be added)
render: shell

7
.github/workflows/compile_esp8266.yml

@ -3,8 +3,11 @@ name: Ahoy Release for ESP8266
on:
push:
branches: main
paths-ignore:
- '**.md' # Do no build on *.md changes
paths:
- 'tools/esp8266/**' # build only when changes occur here
- '!tools/esp8266/README.md'
- '!tools/esp8266/CHANGES.md'
- '!tools/esp8266/User_Manual.md'
jobs:
build:
runs-on: ubuntu-latest

2
tools/esp8266/User_Manual.md

@ -229,6 +229,7 @@ Gather user inverter information here to understand what differs between some in
| isdor | HM-300 | | 1.0.14 | 2021 | 12-09 | 102 | | |
| aschiffler | HM-1500 | | 1.0.12 | 2020 | 06-24 | 100 | | |
| klahus1 | HM-300 | | 1.0.10 | 2020 | 07-07 | 102 | | |
| roku133 | HM-400 | | 1.0.10 | 2020 | 07-07 | 102 | | |
| eeprom23 | HM-1200 | 0.1.0 | 1.0.18 | 2021 | 12-24 | 269619201 | 18:21:00 | HWRev 256 |
| eeprom23 | HM-1200 2t | 0.1.0 | 1.0.16 | 2021 | 10-12 | 269619207 | 17:06:00 | HWRev 256 |
| fila612 | HM-700 | | 1.0.10 | 2021 | 11-01 | 104 | | |
@ -239,6 +240,7 @@ Gather user inverter information here to understand what differs between some in
| lumapu | HM-1200 | 0.1.0 | 1.0.12 | 2020 | 06-24 | | | |
| chehrlic | HM-600 | | 1.0.10 | 2021 | 11-01 | 104 | | |
| chehrlic | TSOL-M800de | | 1.0.10 | 2021 | 11-01 | 104 | | |
| B5r1oJ0A9G | HM-800 | | 1.0.10 | 2021 | | 104 | | |
| | | | | | | | | |
| | | | | | | | | |

4
tools/esp8266/app.cpp

@ -828,8 +828,10 @@ void app::setupMqtt(void) {
if(mMqttActive) {
mMqtt.sendMsg("version", mVersion);
if(mMqtt.isConnected())
if(mMqtt.isConnected()) {
mMqtt.sendMsg("device", mSysConfig.deviceName);
mMqtt.sendMsg("uptime", "0");
}
/*char topic[30];
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) {

10
tools/esp8266/mqtt.h

@ -92,11 +92,15 @@ class mqtt {
// da ein MQTT_CONNECTION_LOST -3 die Werte zerstört hat.
mClient->setServer(mCfg->broker, mCfg->port);
mClient->setBufferSize(MQTT_MAX_PACKET_SIZE);
char lwt[MQTT_TOPIC_LEN + 7 ]; // "/uptime" --> + 7 byte
snprintf(lwt, MQTT_TOPIC_LEN + 7, "%s/uptime", mCfg->topic);
if((strlen(mCfg->user) > 0) && (strlen(mCfg->pwd) > 0))
resub = mClient->connect(mDevName, mCfg->user, mCfg->pwd);
resub = mClient->connect(mDevName, mCfg->user, mCfg->pwd, lwt, 0, false, "offline");
else
resub = mClient->connect(mDevName);
// ein Subscribe ist nur nach einem connect notwendig
resub = mClient->connect(mDevName, lwt, 0, false, "offline");
// ein Subscribe ist nur nach einem connect notwendig
if(resub) {
char topic[MQTT_TOPIC_LEN + 13 ]; // "/devcontrol/#" --> + 6 byte
// ToDo: "/devcontrol/#" is hardcoded

BIN
tools/homeassistant/HomeAssistantDashboardAhoy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

3
tools/homeassistant/README.md

@ -6,4 +6,7 @@ in manual.yaml you will find the setup for manual configuration, adapt your name
in autodiscovery.yaml you will find the setup for automatic discovery of the inverter
in dashboard.yaml you will find the raw configuration of a dashboard:
![Dashboard Image](https://raw.githubusercontent.com/lumapu/ahoy/main/tools/homeassistant/HomeAssistantDashboardAhoy.png)
Note: the config might need adaption to your system (mqtt, homeassistant etc)

99
tools/homeassistant/dashboard.yaml

@ -0,0 +1,99 @@
views:
- title: Home
cards:
- type: horizontal-stack
cards:
- type: gauge
entity: sensor.inverter_ac_power
name: Inverter
max: 800
needle: false
severity:
green: 500
yellow: 100
red: 0
- type: gauge
entity: sensor.inverter_channel_1_ac_power
name: Channel 1
max: 460
- type: gauge
entity: sensor.inverter_channel_2_ac_power
name: Channel 2
max: 460
- show_name: false
show_icon: true
show_state: true
type: glance
entities:
- entity: sensor.inverter_ac_voltage
name: Voltage
- entity: sensor.inverter_frequency
name: Frequency
- entity: sensor.inverter_ac_current
name: Current
- entity: sensor.inverter_ac_power
name: Power
- entity: sensor.inverter_dc_power
name: DC Power
- entity: sensor.inverter_ac_reactive_power
name: Reactive Power
- entity: sensor.inverter_power_factor
- entity: sensor.inverter_day_yield
name: Day Yield
- entity: sensor.inverter_total_yield
name: Total Yield
- entity: sensor.inverter_efficiency
name: Efficiency
- entity: sensor.inverter_temperature
name: Temperature
- entity: sensor.inverter_uptime
name: Uptime
- entity: sensor.inverter_last_alarm
name: Status
- entity: sensor.inverter_power_limit
- entity: sensor.inverter_firmware_version
- entity: sensor.inverter_firmware_build_year
- entity: sensor.inverter_firmware_build_month_and_day
- entity: sensor.inverter_hardware_id
title: Inverter
columns: 4
- type: horizontal-stack
cards:
- show_name: false
show_icon: true
show_state: true
type: glance
entities:
- entity: sensor.inverter_channel_1_ac_voltage
name: Voltage
- entity: sensor.inverter_channel_1_ac_current
name: Current
- entity: sensor.inverter_channel_1_ac_power
name: Power
- entity: sensor.inverter_channel_1_day_yield
name: Day Yield
- entity: sensor.inverter_channel_1_total_yield
name: Total Yield
- entity: sensor.inverter_channel_1_irradiation
name: Irradiation
title: Channel 1
columns: 2
- show_name: false
show_icon: true
show_state: true
type: glance
entities:
- entity: sensor.inverter_channel_2_ac_voltage
name: Voltage
- entity: sensor.inverter_channel_2_ac_current
name: Current
- entity: sensor.inverter_channel_2_ac_power
name: Power
- entity: sensor.inverter_channel_2_day_yield
name: Day Yield
- entity: sensor.inverter_channel_2_total_yield
name: Total Yield
- entity: sensor.inverter_channel_2_irradiation
name: Irradiation
title: Channel 2
columns: 2

341
tools/homeassistant/manual.yaml

@ -1,23 +1,318 @@
sensor:
- platform: mqtt
state_topic: "inverter/Terrasse/ch0/P_AC"
name: "Aktuelle Produktion HM-600"
device_class: energy
unit_of_measurement: "Watt"
value_template: >
{{value|round(2)}}
state_class: total_increasing
unique_id: "current_hm600"
last_reset_topic: "inverter/Terrasse/ch0/P_AC"
last_reset_value_template: "1970-01-01T00:00:00+00:00"
- platform: mqtt
state_topic: "inverter/Terrasse/ch0/YieldTotal"
name: "Gesamtproduktion HM-600"
device_class: energy
unit_of_measurement: "KW/H"
value_template: >
{{value|round(2)}}
state_class: total_increasing
unique_id: "total_hm600"
last_reset_topic: "inverter/Terrasse/ch0/YieldTotal"
last_reset_value_template: "1970-01-01T00:00:00+00:00"
mqtt:
sensor:
- state_topic: "inverter/uptime"
icon: mdi:clock-start
name: "Inverter Uptime"
unique_id: "ahoy_ch0_uptime"
value_template: >
{% set time = value|int %}
{% set minutes = ((time % 3600) / 60) | int %}
{% set hours = ((time % 86400) / 3600) | int %}
{% set days = (time / 86400) | int %}
{%- if time < 60 -%}
Less than a minute
{%- else -%}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{%- endif -%}
{%- if hours > 0 -%}
{%- if days > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if days > 0 or hours > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes == 1 -%}
1 minute
{%- else -%}
{{ minutes }} minutes
{%- endif -%}
{%- endif -%}
{%- endif -%}
- state_topic: "inverter/GardenShed/ch0/Efficiency"
icon: "mdi:trending-up"
name: "Inverter Efficiency"
unique_id: "ahoy_ch0_efficiency"
unit_of_measurement: "%"
- state_topic: "inverter/GardenShed/ch0/P_DC"
device_class: "power"
name: "Inverter DC Power"
unique_id: "ahoy_ch0_p_dc"
unit_of_measurement: "W"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/YieldTotal"
device_class: "energy"
icon: "mdi:lightning-bolt-outline"
name: "Inverter Total Yield"
unique_id: "ahoy_ch0_yield_total"
unit_of_measurement: "kWh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/YieldDay"
device_class: "energy"
name: "Inverter Day Yield"
unique_id: "ahoy_ch0_yield_day"
unit_of_measurement: "Wh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/ALARM_MES_ID"
name: "Inverter Alarm Message ID"
unique_id: "ahoy_ch0_alarm_mes_id"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/LastAlarmCode"
icon: "mdi:message-alert"
name: "Inverter Last Alarm"
unique_id: "ahoy_ch0_last_alarm"
value_template: >
{% set value = value|round(0) %}
{% set mapper = {
0: "Nothing",
1: 'Inverter start',
2: 'DTU command failed',
121: 'Over temperature protection',
125: 'Grid configuration parameter error',
126: 'Software error code 126',
127: 'Firmware error',
128: 'Software error code 128',
129: 'Software error code 129',
130: 'Offline',
141: 'Grid overvoltage',
142: 'Average grid overvoltage',
143: 'Grid undervoltage',
144: 'Grid overfrequency',
145: 'Grid underfrequency',
146: 'Rapid grid frequency change',
147: 'Power grid outage',
148: 'Grid disconnection',
149: 'Island detected',
205: 'Input port 1 & 2 overvoltage',
206: 'Input port 3 & 4 overvoltage',
207: 'Input port 1 & 2 undervoltage',
208: 'Input port 3 & 4 undervoltage',
209: 'Port 1 no input',
210: 'Port 2 no input',
211: 'Port 3 no input',
212: 'Port 4 no input',
213: 'PV-1 & PV-2 abnormal wiring',
214: 'PV-3 & PV-4 abnormal wiring',
215: 'PV-1 Input overvoltage',
216: 'PV-1 Input undervoltage',
217: 'PV-2 Input overvoltage',
218: 'PV-2 Input undervoltage',
219: 'PV-3 Input overvoltage',
220: 'PV-3 Input undervoltage',
221: 'PV-4 Input overvoltage',
222: 'PV-4 Input undervoltage',
301: 'Hardware error code 301',
302: 'Hardware error code 302',
303: 'Hardware error code 303',
304: 'Hardware error code 304',
305: 'Hardware error code 305',
306: 'Hardware error code 306',
307: 'Hardware error code 307',
308: 'Hardware error code 308',
309: 'Hardware error code 309',
310: 'Hardware error code 310',
311: 'Hardware error code 311',
312: 'Hardware error code 312',
313: 'Hardware error code 313',
314: 'Hardware error code 314',
5041: 'Error code-04 Port 1',
5042: 'Error code-04 Port 2',
5043: 'Error code-04 Port 3',
5044: 'Error code-04 Port 4',
5051: 'PV Input 1 Overvoltage/Undervoltage',
5052: 'PV Input 2 Overvoltage/Undervoltage',
5053: 'PV Input 3 Overvoltage/Undervoltage',
5054: 'PV Input 4 Overvoltage/Undervoltage',
5060: 'Abnormal bias',
5070: 'Over temperature protection',
5080: 'Grid Overvoltage/Undervoltage',
5090: 'Grid Overfrequency/Underfrequency',
5100: 'Island detected',
5120: 'EEPROM reading and writing error',
5150: '10 min value grid overvoltage',
5200: 'Firmware error',
8310: 'Shut down',
9000: 'Microinverter is suspected of being stolen' } %}
{{ mapper[value] if value in mapper else "value is unknon" }}
- state_topic: "inverter/GardenShed/ch0/Temp"
device_class: "temperature"
name: "Inverter Temperature"
unique_id: "ahoy_ch0_temp"
unit_of_measurement: "°C"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/Freq"
device_class: "frequency"
name: "Inverter Frequency"
unique_id: "ahoy_ch0_freq"
unit_of_measurement: "Hz"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/P_ACr"
device_class: "power"
name: "Inverter AC Reactive Power"
unique_id: "ahoy_ch0_p_acr"
unit_of_measurement: "VA"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/P_AC"
device_class: "power"
name: "Inverter AC Power"
unique_id: "ahoy_ch0_p_ac"
unit_of_measurement: "W"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/I_AC"
device_class: "current"
name: "Inverter AC Current"
unique_id: "ahoy_ch0_i_ac"
unit_of_measurement: "A"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/U_AC"
device_class: "voltage"
icon: "mdi:current-ac"
name: "Inverter AC Voltage"
unique_id: "ahoy_ch0_u_ac"
unit_of_measurement: "V"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch0/Pct"
device_class: "power_factor"
name: "Inverter Power Factor"
unique_id: "ahoy_ch0_pct"
- state_topic: "inverter/GardenShed/ch0/FWVersion"
icon: "mdi:numeric"
name: "Inverter Firmware Version"
unique_id: "ahoy_ch0_fw_version"
value_template: >
{{ value | round(0) | regex_replace('([0-9]+)([0-9]{2})([0-9]{2})$', '\\1.\\2.\\3') }}
- state_topic: "inverter/GardenShed/ch0/FWBuildYear"
icon: "mdi:calendar-blank"
name: "Inverter Firmware build year"
unique_id: "ahoy_ch0_fw_builid_year"
value_template: >
{{value|round(0)}}
- state_topic: "inverter/GardenShed/ch0/FWBuildMonthDay"
icon: "mdi:calendar-clock"
name: "Inverter Firmware build month and day"
unique_id: "ahoy_ch0_fw_builid_month_day"
- state_topic: "inverter/GardenShed/ch0/HWPartId"
icon: "mdi:identifier"
name: "Inverter Hardware ID"
unique_id: "ahoy_ch0_hw_part_id"
value_template: >
{{value|round(0)}}
- state_topic: "inverter/GardenShed/ch0/PowerLimit"
icon: "mdi:speedometer"
name: "Inverter Power Limit"
unique_id: "ahoy_ch0_power_limit"
unit_of_measurement: "%"
value_template: >
{{value|round(0)}}
- state_topic: "inverter/GardenShed/ch1/Irradiation"
icon: "mdi:weather-partly-cloudy"
name: "Inverter Channel 1 Irradiation"
unique_id: "ahoy_ch1_irradiation"
unit_of_measurement: "%"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch1/YieldTotal"
device_class: "energy"
icon: "mdi:lightning-bolt-outline"
name: "Inverter Channel 1 Total Yield"
unique_id: "ahoy_ch1_yield_total"
unit_of_measurement: "kWh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch1/YieldDay"
device_class: "energy"
name: "Inverter Channel 1 Day Yield"
unique_id: "ahoy_ch1_yield_day"
unit_of_measurement: "Wh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch1/P_DC"
device_class: "power"
name: "Inverter Channel 1 AC Power"
unique_id: "ahoy_ch1_p_dc"
unit_of_measurement: "W"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch1/I_DC"
device_class: "current"
icon: "mdi:current-dc"
name: "Inverter Channel 1 AC Current"
unique_id: "ahoy_ch1_i_dc"
unit_of_measurement: "A"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch1/U_DC"
device_class: "voltage"
icon: "mdi:current-dc"
name: "Inverter Channel 1 AC Voltage"
unique_id: "ahoy_ch1_u_dc"
unit_of_measurement: "V"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/Irradiation"
icon: "mdi:weather-partly-cloudy"
name: "Inverter Channel 2 Irradiation"
unique_id: "ahoy_ch2_irradiation"
unit_of_measurement: "%"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/YieldTotal"
device_class: "energy"
icon: "mdi:lightning-bolt-outline"
name: "Inverter Channel 2 Total Yield"
unique_id: "ahoy_ch2_yield_total"
unit_of_measurement: "kWh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/YieldDay"
device_class: "energy"
name: "Inverter Channel 2 Day Yield"
unique_id: "ahoy_ch2_yield_day"
unit_of_measurement: "Wh"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/P_DC"
device_class: "power"
name: "Inverter Channel 2 AC Power"
unique_id: "ahoy_ch2_p_dc"
unit_of_measurement: "W"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/I_DC"
device_class: "current"
icon: "mdi:current-dc"
name: "Inverter Channel 2 AC Current"
unique_id: "ahoy_ch2_i_dc"
unit_of_measurement: "A"
value_template: >
{{value|round(3)}}
- state_topic: "inverter/GardenShed/ch2/U_DC"
device_class: "voltage"
icon: "mdi:current-dc"
name: "Inverter Channel 2 AC Voltage"
unique_id: "ahoy_ch2_u_dc"
unit_of_measurement: "V"
value_template: >
{{value|round(3)}}

BIN
tools/pcb/nRF24L01_ESP_Wemos_D1.T3001

Binary file not shown.

BIN
tools/pcb/pcb_1.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
tools/pcb/pcb_2.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

8
tools/pcb/readme.md

@ -0,0 +1,8 @@
# PCB for Wemos D1 + nRF24L01+
Simple pcb to plug a nRF24L01+ together with a Wemos D1 Mini / Pro. Thos pcb also leads the UART and the I2C outside. It also allows to easily connect D0 / GPIO16 to RST.
Download Target 3001 schematics [here](nRF24L01_ESP_Wemos_D1.T3001)
## 3D previev
![img](https://github.com/pascaltippelt/ahoy/blob/main/tools/pcb/pcb_1.JPG?raw=true)

5
tools/rpi/hoymiles/__init__.py

@ -203,7 +203,7 @@ class InverterPacketFragment:
# check crc8
if f_crc8(payload[:-1]) != payload[-1]:
raise BufferError('Frame kaputt')
raise BufferError('Frame corrupted - crc8 check failed')
self.ch_rx = ch_rx
self.ch_tx = ch_tx
@ -598,6 +598,9 @@ class InverterTransaction:
wait = True
except TimeoutError:
pass
except BufferError as e:
print(f'Buffer error {e}')
pass
return wait

8
tools/rpi/hoymiles/__main__.py

@ -106,8 +106,9 @@ def poll_inverter(inverter, do_init, retries=4):
result = decoder.decode()
if isinstance(result, hoymiles.decoders.StatusResponse):
data = result.__dict__()
if hoymiles.HOYMILES_DEBUG_LOGGING:
print(f'{c_datetime} Decoded: temp={data["temperature"]}', end='')
print(f'{c_datetime} Decoded: temp={data["temperature"]}, total={data["energy_total"]/1000:.3f}', end='')
if data['powerfactor'] is not None:
print(f', pf={data["powerfactor"]}', end='')
phase_id = 0
@ -169,6 +170,8 @@ def mqtt_send_status(broker, inverter_ser, data, topic=None):
broker.publish(f'{topic}/pf', data['powerfactor'])
broker.publish(f'{topic}/frequency', data['frequency'])
broker.publish(f'{topic}/temperature', data['temperature'])
if data['energy_total'] is not None:
broker.publish(f'{topic}/total', data['energy_total']/1000)
def mqtt_on_command(client, userdata, message):
"""
@ -324,3 +327,6 @@ if __name__ == '__main__':
except KeyboardInterrupt:
sys.exit()
except Exception as e:
print ('Exception catched: %s' % e)
raise

5
tools/rpi/hoymiles/decoders/__init__.py

@ -169,6 +169,11 @@ class StatusResponse(Response):
data['powerfactor'] = self.powerfactor
data['event_count'] = self.event_count
data['time'] = self.time_rx
data['energy_total'] = 0.0
for string in data['strings']:
data['energy_total'] += string['energy_total']
return data
class UnknownResponse(Response):

14
tools/rpi/hoymiles/outputs.py

@ -120,6 +120,8 @@ class InfluxOutputPlugin(OutputPluginFactory):
data_stack.append(f'{measurement},type=pf value={data["powerfactor"]:f} {ctime}')
data_stack.append(f'{measurement},type=frequency value={data["frequency"]:.3f} {ctime}')
data_stack.append(f'{measurement},type=temperature value={data["temperature"]:.2f} {ctime}')
if data['energy_total'] is not None:
data_stack.append(f'{measurement},type=total value={data["energy_total"]/1000:.3f} {ctime}')
self.api.write(self._bucket, self._org, data_stack)
@ -201,6 +203,8 @@ class MqttOutputPlugin(OutputPluginFactory):
self.client.publish(f'{topic}/pf', data['powerfactor'])
self.client.publish(f'{topic}/frequency', data['frequency'])
self.client.publish(f'{topic}/temperature', data['temperature'])
if data['energy_total'] is not None:
self.client.publish(f'{topic}/total', data['energy_total']/1000)
try:
import requests
@ -256,6 +260,9 @@ class VzInverterOutput:
self.try_publish(ts, f'frequency', data['frequency'])
self.try_publish(ts, f'temperature', data['temperature'])
if data['energy_total'] is not None:
self.try_publish(ts, f'total', data['energy_total'])
def try_publish(self, ts, ctype, value):
if not ctype in self.channels:
return
@ -265,7 +272,7 @@ class VzInverterOutput:
r = self.session.get(url)
if r.status_code != 200:
raise ValueError('Could not send request (%s)' % url)
except ConnectionError as e:
except requests.exceptions.ConnectionError as e:
raise ValueError('Could not send request (%s)' % e)
class VolkszaehlerOutputPlugin(OutputPluginFactory):
@ -300,4 +307,7 @@ class VolkszaehlerOutputPlugin(OutputPluginFactory):
serial = data["inverter_ser"]
if serial in self.inverters:
output = self.inverters[serial]
output.store_status(data, self.session)
try:
output.store_status(data, self.session)
except ValueError as e:
print('Could not send data to volkszaehler instance: %s' % e)

Loading…
Cancel
Save