Added folders. Many updates since last commit

This commit is contained in:
Chris Stuurman 2025-10-10 17:10:30 +02:00
parent 28e1253fc0
commit 83cf1954b9
20 changed files with 42846 additions and 2321 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/.esphome.bak/
/fonts/

32
archive/sthome-ut10.yaml Normal file
View File

@ -0,0 +1,32 @@
esphome:
name: sthome-ut10
friendly_name: sthome-ut10
esp32:
board: esp32-s3-devkitc-1
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "90D2UGF/r4Ue8wCj025x2+eYBFOnYWYTrJCZbxDcx6E="
ota:
- platform: esphome
password: "800020c868628ce68704c5f641888ffe"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Sthome-Ut10 Fallback Hotspot"
password: "GQjN3Mc7x5m1"
captive_portal:

View File

@ -0,0 +1,58 @@
substitutions:
# modbus addresses
# Information Data register definition
Felicity_Inv_Type: 0xF800
Felicity_Inv_SubType: 0xF801
Felicity_Inv_SerialNo: 0xF804
Felicity_Inv_CPU1_FW_Version: 0xF80B
Felicity_Inv_CPU2_FW_Version: 0xF80C
# Realtime Data register definition
Felicity_Inv_SettingDataSn: 0x1100
Felicity_Inv_WorkingMode: 0x1101
Felicity_Inv_BatteryChargingStage: 0x1102
Felicity_Inv_FaultCode: 0x1103
Felicity_Inv_PowerFlowMsg: 0x1104
Felicity_Inv_BatteryVoltage: 0x1108
Felicity_Inv_BatteryCurrent: 0x1109
Felicity_Inv_BatteryPower: 0x110A
Felicity_Inv_ACOutputVoltage: 0x1111
Felicity_Inv_ACInputVoltage: 0x1117
Felicity_Inv_ACInputFrequency: 0x1119
Felicity_Inv_ACOutputActivePower: 0x111E
Felicity_Inv_ACOutputApparentPower: 0x111F
Felicity_Inv_LoadPercentage: 0x1120
Felicity_Inv_PVInputVoltage: 0x1126
Felicity_Inv_PVInputPower: 0x112A
# Setting Data register definition
Felicity_Inv_SetBatteryCutOffVoltage: 0x211F
Felicity_Inv_SetBatteryBulkChargingVoltage: 0x2122
Felicity_Inv_SetBatteryFloatChargingVoltage: 0x2123
Felicity_Inv_SetACOutputFrequency: 0x2129
Felicity_Inv_SetOutputSourcePriority: 0x212A
Felicity_Inv_SetApplicationMode: 0x212B
Felicity_Inv_SetChargingSourcePriority: 0x212C
Felicity_Inv_SetBatteryType: 0x212D
Felicity_Inv_SetMaxChargingCurrent: 0x212E
Felicity_Inv_SetMaxUtilityChargingCurrent: 0x2130
Felicity_Inv_SetBuzzerEnable: 0x2131
Felicity_Inv_SetOverLoadRestartEnable: 0x2133
Felicity_Inv_SetOverTemperatureRestartEnable: 0x2134
Felicity_Inv_SetLCDBacklightEnable: 0x2135
Felicity_Inv_SetOverLoadToBypass: 0x2137
Felicity_Inv_SetBatteryBackToChargeVoltage: 0x2156
Felicity_Inv_SetBatteryBackToDischargeVoltage: 0x2159
Felicity_Inv_WorkingMode_POWER: 0
Felicity_Inv_WorkingMode_STANDBY: 1
Felicity_Inv_WorkingMode_BYPASS: 2
Felicity_Inv_WorkingMode_BATTERY: 3
Felicity_Inv_WorkingMode_FAULT: 4
Felicity_Inv_WorkingMode_LINE: 5
Felicity_Inv_WorkingMode_CHARGING: 6
Felicity_Inv_ChargeMode_NONE: 1
Felicity_Inv_ChargeMode_BULK: 2
Felicity_Inv_ChargeMode_ABSORB: 3
Felicity_Inv_ChargeMode_FLOAT: 4

View File

@ -11,3 +11,4 @@ substitutions:
GM_SATURDAY: 2
GM_PUBLIC_HOLIDAY: 3
GM_SCHOOL_HOLIDAY: 4
LATE_MORNING_END: 10 #10AM, in winter it should be 11AM

14
images/fire-red.svg Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FF0000;}
</style>
<path class="st0" d="M17.7,11.2c-0.2-0.3-0.5-0.6-0.8-0.8c-0.7-0.6-1.4-1-2.1-1.7C13.3,7.3,13,4.8,13.9,3c-0.9,0.2-1.8,0.8-2.5,1.3
c-2.6,2.1-3.6,5.7-2.4,8.9c0,0.1,0.1,0.2,0.1,0.3c0,0.2-0.1,0.4-0.3,0.5c-0.2,0.1-0.5,0-0.7-0.1C8.1,13.9,8,13.8,8,13.8
c-1.1-1.4-1.3-3.5-0.6-5.1C5.8,10,4.9,12.3,5,14.5c0.1,0.5,0.1,1,0.3,1.5c0.1,0.6,0.4,1.2,0.7,1.7c1.1,1.7,2.9,3,5,3.2
c2.1,0.3,4.4-0.1,6.1-1.6c1.8-1.7,2.5-4.3,1.5-6.6l-0.1-0.3C18.2,12,17.7,11.2,17.7,11.2 M14.5,17.5c-0.3,0.2-0.7,0.5-1.1,0.6
c-1.1,0.4-2.2-0.2-2.9-0.8c1.2-0.3,1.9-1.2,2.1-2.1c0.2-0.8-0.1-1.5-0.3-2.2c-0.1-0.7-0.1-1.4,0.2-2.1c0.2,0.4,0.4,0.8,0.6,1.1
c0.8,1,2,1.4,2.2,2.8c0,0.1,0.1,0.3,0.1,0.4C15.5,16,15.1,17,14.5,17.5L14.5,17.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

1
images/fire.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.66 11.2C17.43 10.9 17.15 10.64 16.89 10.38C16.22 9.78 15.46 9.35 14.82 8.72C13.33 7.26 13 4.85 13.95 3C13 3.23 12.17 3.75 11.46 4.32C8.87 6.4 7.85 10.07 9.07 13.22C9.11 13.32 9.15 13.42 9.15 13.55C9.15 13.77 9 13.97 8.8 14.05C8.57 14.15 8.33 14.09 8.14 13.93C8.08 13.88 8.04 13.83 8 13.76C6.87 12.33 6.69 10.28 7.45 8.64C5.78 10 4.87 12.3 5 14.47C5.06 14.97 5.12 15.47 5.29 15.97C5.43 16.57 5.7 17.17 6 17.7C7.08 19.43 8.95 20.67 10.96 20.92C13.1 21.19 15.39 20.8 17.03 19.32C18.86 17.66 19.5 15 18.56 12.72L18.43 12.46C18.22 12 17.66 11.2 17.66 11.2M14.5 17.5C14.22 17.74 13.76 18 13.4 18.1C12.28 18.5 11.16 17.94 10.5 17.28C11.69 17 12.4 16.12 12.61 15.23C12.78 14.43 12.46 13.77 12.33 13C12.21 12.26 12.23 11.63 12.5 10.94C12.69 11.32 12.89 11.7 13.13 12C13.9 13 15.11 13.44 15.37 14.8C15.41 14.94 15.43 15.08 15.43 15.23C15.46 16.05 15.1 16.95 14.5 17.5H14.5Z" /></svg>

After

Width:  |  Height:  |  Size: 946 B

BIN
images/loading.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
images/thermometer2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
images/thermometer2a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

20
secrets.yaml.txt Normal file
View File

@ -0,0 +1,20 @@
# Wi-Fi SSID and password (default - used with new device setups)
# for multi network
wifi_ssid1: ""
wifi_ssid2: ""
wifi_ssid3: ""
wifi_ssid4: ""
wifi_ssid5: ""
wifi_password1: ""
wifi_password2: ""
wifi_password3: ""
wifi_password4: ""
wifi_password5: ""
# default Wi-Fi SSID and password
wifi_ssid: ""
wifi_password: ""
# latitude & longitude
latitude:
longitude:

1
source/solar Submodule

@ -0,0 +1 @@
Subproject commit d44b60f637daeb43088e64eecc33932d1f52d030

View File

@ -23,6 +23,7 @@ globals:
type: char[1 + ${DD_MAX_YEARS} * 5]
restore_value: yes
# initial_value: "{2022\n2023\n2024\n2025\n2026}"
# CAN BUS
- id: can_msgctr
type: int
@ -46,6 +47,7 @@ esphome:
on_boot:
- priority: 600 # This is where most sensors are set up (higher number means higher priority)
then:
- ds1307.read_time: # read the RTC time
- lambda: |-
id(can_msgctr) = 0;
id(update_heating_display).execute(false);
@ -65,9 +67,14 @@ psram:
# Enable logging
logger:
level: very_verbose
initial_level: INFO
initial_level: very_verbose
logs:
canbus: INFO
touchscreen: INFO
xpt2046: INFO
script: INFO
lvgl: INFO
ili9xxx: INFO
# Enable Home Assistant API
api:
@ -91,11 +98,17 @@ wifi:
captive_portal:
time:
- platform: ds1307
# repeated synchronization is not necessary unless the external RTC
# is much more accurate than the internal clock
update_interval: never
- platform: homeassistant
id: time_source
update_interval: 360min # Change sync interval from default 5min to 6 hours
# on_time_sync:
# then:
#update_interval: 360min # Change sync interval from default 5min to 6 hours
on_time_sync:
then:
- ds1307.write_time:
# - if: # Publish the time the device was last restarted, but only once.
# condition:
# lambda: 'return id(device_last_restart).state == "";'
@ -215,6 +228,12 @@ spi:
miso_pin: GPIO20
interface: any
i2c:
- id: i2c_bus0
sda: GPIO8
scl: GPIO9
scan: true
#one_wire:
# - platform: gpio
# pin: GPIO4
@ -236,6 +255,7 @@ canbus:
id(can_msgctr)++;
using namespace solar;
auto time_obj = id(time_source).now();
//ESP_LOGI("CB REC", "%s", id(time_source).now().strftime("%a %d %b %Y - %I:%M:%S %p"));
if(time_obj.is_valid()) {
if(can_id >= 0x350 && can_id < 0x380) {
auto cbitem = cbf_store_pylon(id(can_msgctr), can_id, x, remote_transmission_request, time_obj.timestamp);
@ -257,7 +277,7 @@ canbus:
bool publish = id(g_cb_cache).additem(cbitem);
//ESP_LOGI(cbitem.tag().c_str(), "%s P[%s]", cbitem.to_string().c_str(), publish ? "Y" : "N");
if(publish) {
//ESP_LOGI(cbitem.tag().c_str(), "%s", cbitem.to_string().c_str());
ESP_LOGI(cbitem.tag().c_str(), "%s", cbitem.to_string().c_str());
switch (can_id) {
case cbf_sthome::CB_CONTROLLER_STATES:
{

262
sthome-ut11.yaml Normal file
View File

@ -0,0 +1,262 @@
packages:
- !include common/wifi.yaml
- !include common/felicityinverter.yaml
substitutions:
name: sthome-ut11
friendly_name: "sthome-ut11"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
external_components:
- source: github://pr#8103
components: [uart]
- source: github://pr#8032
components: [modbus, modbus_controller, growatt_solar]
refresh: 1h
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
level: VERY_VERBOSE
initial_level: DEBUG
logs:
uart: VERY_VERBOSE
modbus: VERY_VERBOSE
modbus_controller: VERY_VERBOSE
# Enable Home Assistant API
api:
encryption:
key: "00DjAYGOMycWGWLC8J8XbOzwFcptjKQxOtzh+jKY8SQ="
ota:
- platform: esphome
password: "b9ce27902daee1bc1dda748d0c8c68ef"
wifi:
manual_ip:
static_ip: 10.0.2.11
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${name} Fallback Hotspot"
password: "CUcx85qCyekn"
captive_portal:
uart:
- id: inv_uart1
rx_pin: GPIO16
tx_pin: GPIO17
baud_rate: 2400
stop_bits: 1
parity: NONE
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\r"
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ',');
sun:
id: sun_sensor
latitude: !secret latitude
longitude: !secret longitude
time:
- platform: homeassistant
id: time_source
switch:
- platform: restart
name: "${name} Restart"
id: "restart_switch"
modbus:
- id: modbus1
uart_id: inv_uart1
flow_control_pin: GPIO4
send_wait_time: 1000ms #250ms
disable_crc: false
role: client
modbus_controller:
- id: modbus_device1
modbus_id: modbus1
address: 0x01
allow_duplicate_commands: False
command_throttle: 0ms
update_interval: 4s #30s
offline_skip_updates: 2
max_cmd_retries: 0
setup_priority: -10
sensor:
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Type"
register_type: holding
address: ${Felicity_Inv_Type} # 0xF800
value_type: U_DWORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Sub Type"
register_type: holding
address: ${Felicity_Inv_SubType} # 0xF801
value_type: U_DWORD
register_count: 3
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 CPU1 F/W Version"
register_type: holding
address: ${Felicity_Inv_CPU1_FW_Version} # 0xF80B
value_type: U_DWORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 CPU2 F/W Version"
register_type: holding
address: ${Felicity_Inv_CPU2_FW_Version} # 0xF80C
value_type: U_DWORD
register_count: 3
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Working Mode"
register_type: holding
address: ${Felicity_Inv_WorkingMode} # 0x1101
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Charge Mode"
register_type: holding
address: ${Felicity_Inv_BatteryChargingStage} # 0x1102
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Fault Code"
register_type: holding
address: ${Felicity_Inv_FaultCode} # 0x1103
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Power Flow"
register_type: holding
address: ${Felicity_Inv_PowerFlowMsg} # 0x1104
value_type: U_WORD
register_count: 4
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Battery Voltage"
register_type: holding
address: ${Felicity_Inv_BatteryVoltage} # 0x1108
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Battery Current"
register_type: holding
address: ${Felicity_Inv_BatteryCurrent} # 0x1109
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 BatteryPower"
register_type: holding
address: ${Felicity_Inv_BatteryPower} # 0x110A
value_type: U_WORD
register_count: 7
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 AC Output Voltage"
register_type: holding
address: ${Felicity_Inv_ACOutputVoltage} # 0x1111
value_type: U_WORD
register_count: 6
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 AC Input Voltage"
register_type: holding
address: ${Felicity_Inv_ACInputVoltage} # 0x1117
value_type: U_WORD
register_count: 2
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 AC Input Frequency"
register_type: holding
address: ${Felicity_Inv_ACInputFrequency} # 0x1119
value_type: U_WORD
register_count: 5
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 AC Output Active Power"
register_type: holding
address: ${Felicity_Inv_ACOutputActivePower} # 0x111E
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 AC Output Apparent Power"
register_type: holding
address: ${Felicity_Inv_ACOutputApparentPower} # 0x111F
value_type: U_WORD
register_count: 1
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 Load Percentage"
register_type: holding
address: ${Felicity_Inv_LoadPercentage} # 0x1120
value_type: U_WORD
register_count: 6
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 PV Input Voltage"
register_type: holding
address: ${Felicity_Inv_PVInputVoltage} # 0x1126
value_type: U_WORD
register_count: 4
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 PV Input Power"
register_type: holding
address: ${Felicity_Inv_PVInputPower} # 0x112A
value_type: U_WORD
register_count: 1
text_sensor:
- platform: modbus_controller
modbus_controller_id: modbus_device1
name: "Inverter1 SerialNo"
register_type: holding
address: ${Felicity_Inv_SerialNo} # 0xF804
response_size: 14
register_count: 7
raw_encode: HEXBYTES

View File

@ -1,27 +1,35 @@
packages:
- !include common/wifi.yaml
- !include common/felicityinverter.yaml
substitutions:
name: sthome-ut2
friendly_name: "sthome-ut2"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
# - priority: 200 # Network connections like MQTT/native API are set up at this priority.
# then:
# - lambda: |-
external_components:
- source: github://pr#8103
components: [uart]
- source: github://pr#8032
components: [modbus, modbus_controller, growatt_solar]
refresh: 1h
esp32:
board: esp32dev
framework:
type: arduino
#type: esp-idf
#debug:
# update_interval: 5s
type: esp-idf
# Enable logging
logger:
level: DEBUG
level: VERY_VERBOSE
initial_level: INFO
logs:
uart: VERY_VERBOSE
modbus: DEBUG
modbus_controller: DEBUG
# Enable Home Assistant API
api:
@ -33,30 +41,9 @@ ota:
password: "cb8a82d04c2f4dcf9bd273f903c7c378"
wifi:
#ssid: !secret wifi_ssid
#password: !secret wifi_password
# we will use local dns server for local dns resolution
power_save_mode: none
domain: ".sthome.org"
networks:
- ssid: !secret wifi_ssid1
password: !secret wifi_password1
- ssid: !secret wifi_ssid2
password: !secret wifi_password2
- ssid: !secret wifi_ssid3
password: !secret wifi_password3
- ssid: !secret wifi_ssid4
password: !secret wifi_password4
- ssid: !secret wifi_ssid5
password: !secret wifi_password5
manual_ip:
# For faster connection startup, set a static IP address
# Set this to the IP of the ESP
static_ip: 10.0.2.2
gateway: 10.0.0.2
subnet: 255.255.240.0
dns1: 10.0.0.1
dns2: 1.1.1.1
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${name} Fallback Hotspot"
@ -64,155 +51,20 @@ wifi:
captive_portal:
one_wire:
- platform: gpio
pin: GPIO4
id: temperature_sensors
#i2c:
# sda: GPIO21
# scl: GPIO22
font:
- file: "fonts/Windows/comic.ttf"
id: my_font
size: 20
bpp: 2
- file: "fonts/misc/tom-thumb.bdf"
id: tomthumb
# gfonts://family[@weight]
- file: "gfonts://Roboto"
id: roboto_20
size: 20
- file:
type: gfonts
family: Roboto
weight: 900
id: roboto_16
size: 16
- file: "fonts/Windows/arial.ttf"
id: arial_14
size: 14
# gfonts://family[@weight]
- file: "gfonts://Roboto"
id: roboto
size: 20
- file: "gfonts://Carrois Gothic"
id: Carrois_Gothic
size: 20
- file: "gfonts://Kdam Thmor Pro"
id: Kdam_Thmor_Pro
size: 40
- file: "gfonts://Merriweather"
id: Merriweather
size: 30
- file: "gfonts://Material+Symbols+Outlined"
id: icons_50
size: 50
glyphs: ["\U0000e425"] # mdi-timer
- file: "fonts/roboto/Roboto-Condensed.ttf"
id: roboto_special_28
size: 28
bpp: 4
glyphs: [
0123456789aAáÁeEéÉ,
(,),+,-,_,.,°,•,µ,
"\u0020", # space
"\u002C", # ,
"\u0021", # !
"\u0022", # "
"\u0027", # '
"\u003A", # :
]
- file: "fonts/roboto/Roboto-Condensed.ttf"
id: roboto_special_32
size: 32
bpp: 4
glyphs: [
0123456789aAáÁeEéÉ,
(,),+,-,_,.,°,•,µ,
"\u0020", # space
"\u002C", # ,
"\u0021", # !
"\u0022", # "
"\u0027", # '
"\u003A", # :
]
- file: "fonts/roboto/Roboto-Condensed.ttf"
id: roboto_special_36
size: 36
bpp: 4
glyphs: [
0123456789aAáÁeEéÉ,
(,),+,-,_,.,°,•,µ,
"\u0020", # space
"\u002C", # ,
"\u0021", # !
"\u0022", # "
"\u0027", # '
"\u003A", # :
]
# - file: "fonts/RobotoCondensed-Regular.ttf"
# id: my_font_with_icons
# size: 20
# bpp: 4
# extras:
# - file: "fonts/misc/materialdesignicons-webfont.ttf"
# glyphs: [
# "\U000F02D1", # mdi-heart
# "\U000F05D4", # mdi-airplane-landing
# ]
- file:
type: gfonts
family: Roboto
id: roboto_european_core
size: 16
glyphsets:
- GF_Latin_Core
- GF_Greek_Core
- GF_Cyrillic_Core
- file: "https://github.com/IdreesInc/Monocraft/releases/download/v3.0/Monocraft.ttf"
id: web_font
size: 20
- file:
url: "https://github.com/IdreesInc/Monocraft/releases/download/v3.0/Monocraft.ttf"
type: web
id: web_font2
size: 24
#ads1115:
# - address: 0x48
# id: ads1115_48
# continuous_mode: true
# - address: 0x49
# id: ads1115_49
# continuous_mode: true
# - address: 0x4A
# id: ads1115_4A
# continuous_mode: true
# # - address: 0x4B
# # id: ads1115_4B
spi:
- id: spi_bus0
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
interface: any
psram:
uart:
- id: inv_uart1
rx_pin: GPIO16
tx_pin: GPIO17
baud_rate: 2400
stop_bits: 1
parity: NONE
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\r"
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ',');
sun:
id: sun_sensor
@ -220,175 +72,336 @@ sun:
longitude: !secret longitude
time:
# - platform: sntp
# timezone: Africa/Johannesburg
# servers:
# - ntp1.meraka.csir.co.za # 146.64.24.58
# - ntp.as3741.net # 196.4.160.4
# - ntp1.inx.net.za # 196.10.52.57
- platform: homeassistant
id: time_source
# on_time_sync:
# - lambda: |-
# id(time_synched) = true;
# id(init_holidays).execute(); // we need valid time to calculate holidays
# - logger.log: "Synchronized system clock"#
display:
- platform: ili9xxx
model: ili9341
id: tft_display
color_palette: 8BIT
data_rate: 40MHz
#dc_pin: GPIO02
#reset_pin: GPIO27
#cs_pin: GPIO15
reset_pin: GPIO32
dc_pin: GPIO27
invert_colors: false
show_test_card: true
dimensions:
width: 480
height: 320
# - platform: ssd1306_i2c
# model: "SSD1306 128x64"
## reset_pin: GPIO32
# address: 0x3C
# id: oled_display
# pages:
# - id: page1
# lambda: |-
# auto time_obj = id(time_source).now();
# auto date = time_obj.strftime("%Y-%m-%d");
# auto time = time_obj.strftime("%H:%M:%S");
# it.print(0, 0, id(roboto_16), date.c_str());
# it.print(0, 20, id(roboto_special_36), time.c_str());
# - id: page2
# lambda: |-
# // Print WiFi Signal
# it.printf(0, 26, id(arial_14), "Wi-Fi: %.1fdBm", id(wifi_sig).state);
# // Print time in HH:MM format
# it.strftime(0, 0, id(roboto), TextAlign::TOP_LEFT, "%H:%M", id(time_source).now());
# //// Print Room humidity"(from xiaomi sensor)
# //if (id(room_humidity).has_state()) {
# // it.printf(127,62, id(roboto), TextAlign::BOTTOM_RIGHT, "%.1f%%", id(room_humidity).state);
# //}
# // Print Study temperature(from dallas sensor)
# if (id(study_temperature).has_state()) {
# it.printf(127, 0, id(Carrois_Gothic), TextAlign::TOP_RIGHT, "%.1f°C", id(study_temperature).state);
# }
# - id: page3
# lambda: |-
# // Print 29Gal temperature(from dallas sensor)
# if (id(study_temperature).has_state()) {
# it.printf(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%.1f°C", id(study_temperature).state);
# }
# - id: page4
# lambda: |-
# // Print time in HH:MM format
# it.strftime(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(time_source).now());
#interval:
#- interval: 5s
# then:
# - display.page.show_next: oled_display
# - component.update: oled_display
switch:
- platform: restart
name: "${name} Restart"
id: "restart_switch"
sensor:
- platform: dallas_temp
address: 0xfe00000037b3d528
name: "Study Temperature"
id: study_temperature
update_interval: "60s"
resolution: 12
one_wire_id: temperature_sensors
unit_of_measurement: "°C"
#icon: "mdi:water-thermometer"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
filters:
- filter_out: nan
# - sliding_window_moving_average:
# window_size: 120 # averages over 120 update intervals
# send_every: 60 # reports every 60 update intervals
modbus:
- id: modbus1
uart_id: inv_uart1
flow_control_pin: GPIO4
send_wait_time: 1000ms #250ms
disable_crc: false
role: server
# Report wifi signal strength every 5 min if changed
- platform: wifi_signal
name: WiFi Signal
id: wifi_sig
update_interval: 300s
filters:
- delta: 10%
# human readable uptime sensor output to the text sensor above
- platform: uptime
name: Uptime in Days
id: uptime_sensor_days
update_interval: 10s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor_days).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
auto days_str = std::to_string(days);
auto hours_str = std::to_string(hours);
auto minutes_str = std::to_string(minutes);
auto seconds_str = std::to_string(seconds);
return (
(days ? days_str + "d " : "") +
(hours ? hours_str + "h " : "") +
(minutes ? minutes_str + "m " : "") +
(seconds_str + "s")
).c_str();
# number of seconds since midnight
- platform: template
id: time_of_day
name: "Time of day"
accuracy_decimals: 0
unit_of_measurement: "s"
lambda: |-
auto currenttime = id(time_source).now();
ESPTime time_obj = currenttime;
time_obj.second = 0;
time_obj.minute = 0;
time_obj.hour = 0;
time_obj.recalc_timestamp_local();
return currenttime.timestamp - time_obj.timestamp;
update_interval: 10s
text_sensor:
- platform: template
id: module_time
name: "Module time"
icon: mdi:clock
lambda: |-
auto time_obj = id(time_source).now();
return time_obj.strftime("%Y-%m-%d %H:%M:%S");
update_interval: 1s
# Expose WiFi information as sensors
- platform: wifi_info
ip_address:
name: IP
mac_address:
name: Mac Address
# human readable update text sensor from sensor:uptime
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
modbus_controller:
- id: modbus_device1
modbus_id: modbus1
address: 0x1
allow_duplicate_commands: False
command_throttle: 0ms
update_interval: 4s #30s
offline_skip_updates: 2
max_cmd_retries: 04
setup_priority: -10
server_registers:
- address: ${Felicity_Inv_WorkingMode} # 0x1101
value_type: U_WORD
read_lambda: |-
return 0x0001;
- address: ${Felicity_Inv_BatteryChargingStage} # 0x1102
value_type: U_WORD
read_lambda: |-
return 0x0002;
- address: ${Felicity_Inv_FaultCode} # 0x1103
value_type: U_WORD
read_lambda: |-
return 0x0003;
- address: ${Felicity_Inv_PowerFlowMsg} # 0x1104
value_type: U_DWORD_R
read_lambda: |-
return 0x0004;
- address: 0x1106
value_type: U_DWORD_R
read_lambda: |-
return 0;
- address: ${Felicity_Inv_BatteryVoltage} # 0x1108
value_type: U_WORD
read_lambda: |-
return 0x0005;
- address: ${Felicity_Inv_BatteryCurrent} # 0x1109
value_type: U_WORD
read_lambda: |-
return 0x0006;
- address: ${Felicity_Inv_BatteryPower} # 0x110A
value_type: U_DWORD_R
read_lambda: |-
return 0x0007;
- address: 0x110C
value_type: U_QWORD_R
read_lambda: |-
return 0;
- address: 0x1110
value_type: U_WORD
read_lambda: |-
return 0;
- address: ${Felicity_Inv_ACOutputVoltage} # 0x1111
value_type: U_QWORD_R
read_lambda: |-
return 0x0008;
- address: 0x1115
value_type: U_DWORD_R
read_lambda: |-
return 0;
- address: ${Felicity_Inv_ACInputVoltage} # 0x1117
value_type: U_DWORD_R
read_lambda: |-
return 0x0009;
- address: ${Felicity_Inv_ACInputFrequency} # 0x1119
value_type: U_QWORD_R
read_lambda: |-
return 0x000A;
- address: 0x111D
value_type: U_WORD
read_lambda: |-
return 0;
- address: ${Felicity_Inv_ACOutputActivePower} # 0x111E
value_type: U_WORD
read_lambda: |-
return 0x000B;
- address: ${Felicity_Inv_ACOutputApparentPower} # 0x111F
value_type: U_WORD
read_lambda: |-
return 0x000C;
- address: ${Felicity_Inv_LoadPercentage} # 0x1120
value_type: U_QWORD_R
read_lambda: |-
return 0x000D;
- address: 0x1124
value_type: U_DWORD_R
read_lambda: |-
return 0;
- address: ${Felicity_Inv_PVInputVoltage} # 0x1126
value_type: U_QWORD_R
read_lambda: |-
return 0x000E;
- address: ${Felicity_Inv_PVInputPower} # 0x112A
value_type: U_WORD
read_lambda: |-
return 0x0010;
- address: 0x112C
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0xF800
value_type: S_DWORD_R
read_lambda: |-
return 0x400D;
- address: 0xF802
value_type: S_DWORD_R
read_lambda: |-
return 0x500E;
- address: 0xF804
value_type: S_DWORD_R
read_lambda: |-
return 0x4142;
- address: 0xF806
value_type: S_DWORD_R
read_lambda: |-
return 0x4344;
- address: 0xF808
value_type: S_DWORD_R
read_lambda: |-
return 0x4546;
- address: 0xF80A
value_type: S_DWORD_R
read_lambda: |-
return 0x4748;
- address: 0xF80C
value_type: S_DWORD_R
read_lambda: |-
return 0x494A;
- address: 0xF80E
value_type: S_DWORD_R
read_lambda: |-
return 0x4B4C;
- address: 0xF810
value_type: S_DWORD_R
read_lambda: |-
return 0;
#modbus:
# - id: modbus1
# uart_id: inv_uart1
# flow_control_pin: GPIO4
# send_wait_time: 1000ms #250ms
# disable_crc: false
# role: client
#
#modbus_controller:
# - id: modbus_device1
# modbus_id: modbus1
# address: 0x01
# allow_duplicate_commands: False
# command_throttle: 0ms
# update_interval: 4s #30s
# offline_skip_updates: 2
# max_cmd_retries: 0
# setup_priority: -10
#
#sensor:
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Type"
# register_type: holding
# address: ${Felicity_Inv_Type} # 0xF800
# value_type: U_DWORD
# register_count: 1
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Sub Type"
# register_type: holding
# address: ${Felicity_Inv_SubType} # 0xF801
# value_type: U_DWORD
# register_count: 3
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 CPU1 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU1_FW_Version} # 0xF80B
# value_type: U_DWORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 CPU2 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU2_FW_Version} # 0xF80C
# value_type: U_DWORD
# register_count: 3
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Working Mode"
# register_type: holding
# address: ${Felicity_Inv_WorkingMode} # 0x1101
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Charge Mode"
# register_type: holding
# address: ${Felicity_Inv_BatteryChargingStage} # 0x1102
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Fault Code"
# register_type: holding
# address: ${Felicity_Inv_FaultCode} # 0x1103
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Power Flow"
# register_type: holding
# address: ${Felicity_Inv_PowerFlowMsg} # 0x1104
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Battery Voltage"
# register_type: holding
# address: ${Felicity_Inv_BatteryVoltage} # 0x1108
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Battery Current"
# register_type: holding
# address: ${Felicity_Inv_BatteryCurrent} # 0x1109
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 BatteryPower"
# register_type: holding
# address: ${Felicity_Inv_BatteryPower} # 0x110A
# value_type: U_WORD
# register_count: 7
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACOutputVoltage} # 0x1111
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACInputVoltage} # 0x1117
# value_type: U_WORD
# register_count: 2
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Input Frequency"
# register_type: holding
# address: ${Felicity_Inv_ACInputFrequency} # 0x1119
# value_type: U_WORD
# register_count: 5
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Active Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputActivePower} # 0x111E
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Apparent Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputApparentPower} # 0x111F
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Load Percentage"
# register_type: holding
# address: ${Felicity_Inv_LoadPercentage} # 0x1120
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 PV Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_PVInputVoltage} # 0x1126
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 PV Input Power"
# register_type: holding
# address: ${Felicity_Inv_PVInputPower} # 0x112A
# value_type: U_WORD
# register_count: 1
#
#text_sensor:
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 SerialNo"
# register_type: holding
# address: ${Felicity_Inv_SerialNo} # 0xF804
# response_size: 14
# register_count: 7
# raw_encode: HEXBYTES
#

35296
sthome-ut3.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
packages:
- !include common/wifi.yaml
- !include common/canbus.yaml
- !include common/felicityinverter.yaml
substitutions:
name: sthome-ut3
@ -9,49 +9,43 @@ substitutions:
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
includes:
- source # copies folder with files to relevant to be included in esphome compile
- <source/solar/cb_frame.h> # angle brackets ensure file is included above globals in main.cpp. Make sure to use include GUARDS in the file to prevent double inclusion
- <source/solar/cbf_store.h>
- <source/solar/cbf_pylon.h>
- <source/solar/cbf_store_pylon.h>
- <source/solar/cbf_sthome.h>
- <source/solar/cbf_store_sthome.h>
- <source/solar/cbf_cache.h>
on_boot:
- priority: 600 # This is where most sensors are set up (higher number means higher priority)
then:
- lambda: |-
id(can_msgctr) = 0;
# on_boot:
# - priority: 600 # This is where most sensors are set up (higher number means higher priority)
# then:
# - uart.write:
# id: inv_uart1
# data: [0x0D, 0x0A]
# - uart.write:
# id: inv_uart2
# data: [0x0D, 0x0A]
#external_components:
# - source: github://pr#8103
# components: [uart]
# - source: github://pr#8032
# components: [modbus, modbus_controller] #, growatt_solar]
# refresh: 1h
globals:
- id: geyser_relay_status
type: bool
restore_value: yes
initial_value: 'false'
# CANBUS
- id: can_msgctr
type: int
restore_value: no
- id: g_cb_cache
type: solar::cbf_cache
restore_value: no
esp32:
board: nodemcu-32s #esp32dev
framework:
type: arduino
# Example configuration entry
#debug:
# update_interval: 5s
type: arduino #esp-idf
# Enable logging
logger:
level: VERY_VERBOSE
initial_level: INFO
initial_level: DEBUG
logs:
canbus: INFO
uart: VERY_VERBOSE
modbus: VERBOSE
modbus_controller: VERBOSE
# Enable Home Assistant API
api:
@ -73,6 +67,35 @@ wifi:
captive_portal:
uart:
- id: inv_uart1
rx_pin: GPIO16
tx_pin: GPIO17
baud_rate: 2400
stop_bits: 1
parity: NONE
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\r"
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ',');
# - id: inv_uart2
# rx_pin: GPIO25
# tx_pin: GPIO26
# baud_rate: 2400
# stop_bits: 1
# parity: NONE
# debug:
# direction: BOTH
# dummy_receiver: false
# after:
# delimiter: "\r"
# sequence:
# - lambda: UARTDebug::log_hex(direction, bytes, ' ');
sun:
id: sun_sensor
latitude: !secret latitude
@ -81,214 +104,649 @@ sun:
time:
- platform: homeassistant
id: time_source
update_interval: 360min # Change sync interval from default 5min to 6 hours
on_time_sync:
then:
- if: # Publish the time the device was last restarted, but only once.
condition:
lambda: 'return id(device_last_restart).state == "";'
then:
- text_sensor.template.publish:
id: device_last_restart
state: !lambda 'return id(time_source).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
interval:
- interval: 30s
then:
- lambda: |-
using namespace solar;
std::vector<uint8_t> data(cbf_sthome::heartbeat.begin(), cbf_sthome::heartbeat.end());
for (int i = 0; i < 5; i++) {
id(canbus_sthome)->send_data(cbf_sthome::CB_CANBUS_ID03, false, data);
}
ESP_LOGI("SND:${CB_CANBUS_ID03}", "%s", cbf_sthome::heartbeat.c_str());
spi:
- id: spi_bus0
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
interface: any
# CAN BUS
canbus:
- platform: mcp2515
cs_pin: GPIO16
spi_id: spi_bus0
mode: NORMAL
id: canbus_sthome
can_id: ${CB_CANBUS_ID03}
bit_rate: 500KBPS #20KBPS
on_frame:
- can_id: 0
can_id_mask: 0
then:
- lambda: |-
id(can_msgctr)++;
using namespace solar;
auto time_obj = id(time_source).now();
if(time_obj.is_valid()) {
auto cbitem = cbf_store_sthome(id(can_msgctr), can_id, x, remote_transmission_request, time_obj.timestamp);
bool publish = id(g_cb_cache).additem(cbitem);
if(publish) {
ESP_LOGI(cbitem.tag().c_str(), "%s", cbitem.to_string().c_str());
}
}
# Define a PWM output on the ESP32
output:
- platform: ledc
pin: GPIO26
id: backlight_pwm
# Define a monochromatic, dimmable light for the backlight
light:
- platform: monochromatic
output: backlight_pwm
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_ON
switch:
- platform: restart
name: "${name} Restart"
id: "restart_switch"
modbus:
- id: modbus1
uart_id: inv_uart1
# flow_control_pin: GPIO4
send_wait_time: 1200ms #250ms
disable_crc: false
role: server
# - id: modbus2
# uart_id: inv_uart2
# #flow_control_pin: GPIO27
# send_wait_time: 1200ms #250ms
# disable_crc: false
# role: server
modbus_controller:
# - id: modbus_device1
# modbus_id: modbus1
# address: 0x01
# allow_duplicate_commands: False
# command_throttle: 0ms
# update_interval: 10s #30s
# offline_skip_updates: 2
# max_cmd_retries: 0
# setup_priority: -10
# - id: modbus_device2
# modbus_id: modbus2
# address: 0x01
# allow_duplicate_commands: False
# command_throttle: 0ms
# update_interval: 60s #30s
# offline_skip_updates: 2
# max_cmd_retries: 0
# setup_priority: -10
- modbus_id: modbus1
address: 0x1
server_registers:
- address: 0x1100
value_type: U_WORD
read_lambda: |-
return 0x01;
- address: 0x1101
value_type: U_WORD
read_lambda: |-
return 0x02; // b0=power-on mode/PowerOnMode 1=standby mode/StandbyMode 2=bypass mode/BypassMode 3=battery mode/BatteryMode 4=fault mode/FaultMode 5=mains mode/LineMode 6=charging mode/PVChargeMode 0=no
- address: 0x1102
value_type: U_WORD
read_lambda: |-
return 0x02; // No charge 1=Constant current charge/Bulk charge 2=Constant voltage charge/Absorption charge 3=Float charge/Float charge
- address: 0x1103 # Fault Code
value_type: U_WORD
read_lambda: |-
return 0x0;
- address: 0x1104 # PowerFlowMsg
value_type: U_WORD
read_lambda: |-
return 0x0;
- address: 0x1105 # dummy
value_type: U_WORD
read_lambda: |-
return 0x0;
- address: 0x1106 # dummy
value_type: U_DWORD
read_lambda: |-
return 0x0;
- address: 0x1108 # Battery voltage
value_type: U_WORD
read_lambda: |-
return 0x3A;
- address: 0x1109 # Battery current
value_type: S_WORD
read_lambda: |-
return 0xFFC4; // -60A
- address: 0x110A # Battery power
value_type: S_WORD
read_lambda: |-
return 0xED40; // -4800W
- address: 0x110B # dummy
value_type: U_QWORD
read_lambda: |-
return 0;
- address: 0x110F # dummy
value_type: U_DWORD
read_lambda: |-
return 0;
- address: 0x1111 # AC Output voltage
value_type: U_WORD
read_lambda: |-
return 0xE7; // 231V
- address: 0x1112 # dummy
value_type: U_QWORD
read_lambda: |-
return 0;
- address: 0x1116 # dummy
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0x1117 # AC Input voltage
value_type: U_WORD
read_lambda: |-
return 0xE6; // 230V
- address: 0x1118 # dummy
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0x1119 # AC Input frequency
value_type: U_WORD
read_lambda: |-
return 50; // 50Hz
- address: 0x111A # dummy
value_type: U_QWORD
read_lambda: |-
return 0;
- address: 0x111B # dummy
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0x111C # dummy
value_type: U_DWORD
read_lambda: |-
return 0;
- address: 0x111E
value_type: S_WORD
read_lambda: |-
return 100; // 100W
- address: 0x111F
value_type: U_WORD
read_lambda: |-
return 120; // 120VA
- address: 0x1120
value_type: U_WORD
read_lambda: |-
return 50; // 50%
- address: 0x1121 # dummy
value_type: U_QWORD
read_lambda: |-
return 0;
- address: 0x1125 # dummy
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0x1126
value_type: U_WORD
read_lambda: |-
return 450; // 450V
- address: 0x1127 # dummy
value_type: U_WORD
read_lambda: |-
return 0;
- address: 0x1128 # dummy
value_type: U_DWORD
read_lambda: |-
return 0;
- address: 0x112A
value_type: S_WORD
read_lambda: |-
return 4812; // 4812W
# - modbus_id: modbus2
# server_registers:
# - address: 0x1100
# value_type: U_WORD
# read_lambda: |-
# return 0x01;
# - address: 0x1101
# value_type: U_WORD
# read_lambda: |-
# return 0x02; // b0=power-on mode/PowerOnMode 1=standby mode/StandbyMode 2=bypass mode/BypassMode 3=battery mode/BatteryMode 4=fault mode/FaultMode 5=mains mode/LineMode 6=charging mode/PVChargeMode 0=no
# - address: 0x1102
# value_type: U_WORD
# read_lambda: |-
# return 0x02; // No charge 1=Constant current charge/Bulk charge 2=Constant voltage charge/Absorption charge 3=Float charge/Float charge
# - address: 0x1103 # Fault Code
# value_type: U_WORD
# read_lambda: |-
# return 0x0;
# - address: 0x1104 # PowerFlowMsg
# value_type: U_WORD
# read_lambda: |-
# return 0x0;
# - address: 0x1105 # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0x0;
# - address: 0x1106 # dummy
# value_type: U_DWORD
# read_lambda: |-
# return 0x0;
# - address: 0x1108 # Battery voltage
# value_type: U_WORD
# read_lambda: |-
# return 0x3A;
# - address: 0x1109 # Battery current
# value_type: S_WORD
# read_lambda: |-
# return 0xFFC4; // -60A
# - address: 0x110A # Battery power
# value_type: S_WORD
# read_lambda: |-
# return 0xED40; // -4800W
# - address: 0x110B # dummy
# value_type: U_QWORD
# read_lambda: |-
# return 0;
# - address: 0x110F # dummy
# value_type: U_DWORD
# read_lambda: |-
# return 0;
# - address: 0x1111 # AC Output voltage
# value_type: U_WORD
# read_lambda: |-
# return 0xE7; // 231V
# - address: 0x1112 # dummy
# value_type: U_QWORD
# read_lambda: |-
# return 0;
# - address: 0x1116 # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0;
# - address: 0x1117 # AC Input voltage
# value_type: U_WORD
# read_lambda: |-
# return 0xE6; // 230V
# - address: 0x1118 # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0;
# - address: 0x1119 # AC Input frequency
# value_type: U_WORD
# read_lambda: |-
# return 50; // 50Hz
# - address: 0x111A # dummy
# value_type: U_QWORD
# read_lambda: |-
# return 0;
# - address: 0x111B # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0;
# - address: 0x111C # dummy
# value_type: U_DWORD
# read_lambda: |-
# return 0;
# - address: 0x111E
# value_type: S_WORD
# read_lambda: |-
# return 100; // 100W
# - address: 0x111F
# value_type: U_WORD
# read_lambda: |-
# return 120; // 120VA
# - address: 0x1120
# value_type: U_WORD
# read_lambda: |-
# return 50; // 50%
# - address: 0x1121 # dummy
# value_type: U_QWORD
# read_lambda: |-
# return 0;
# - address: 0x1125 # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0;
# - address: 0x1126
# value_type: U_WORD
# read_lambda: |-
# return 450; // 450V
# - address: 0x1127 # dummy
# value_type: U_WORD
# read_lambda: |-
# return 0;
# - address: 0x1128 # dummy
# value_type: U_DWORD
# read_lambda: |-
# return 0;
# - address: 0x112A
# value_type: S_WORD
# read_lambda: |-
# return 4812; // 4812W
#text_sensor:
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 SerialNo"
# register_type: holding
# address: ${Felicity_Inv_SerialNo} # 0xF804
# response_size: 7
# register_count: 7
# raw_encode: HEXBYTES
#
##- platform: modbus_controller
## modbus_controller_id: modbus_device2
## name: "Inverter2 SerialNo"
## register_type: holding
## address: ${Felicity_Inv_SerialNo} # 0xF804
## response_size: 7
## register_count: 7
## raw_encode: HEXBYTES
#
#sensor:
# - platform: homeassistant
# name: "Geyser Top Temperature"
# entity_id: sensor.sthome_ut8_geyser_top_temperature
# id: geyser_top_temperature
# on_raw_value:
# then:
# - script.execute: canbus_send_temperatures
## - canbus.send:
## canbus_id: canbus_sthome
## can_id: ${CB_GEYSER_TOP_TEMPERATURE}
## data: !lambda |-
## double temp = id(geyser_top_temperature).raw_state;
## int value = (int) (temp * 16777216);
## std::vector<uint8_t> byte_stream(sizeof(value));
## memcpy(byte_stream.data(), &value, sizeof(value));
## ESP_LOGI("SND:${CB_GEYSER_TOP_TEMPERATURE}", "Geyser TOP temp: %d (%f)", value, temp);
## //ESP_LOGI("SND:0x400", "Geyser TOP temp: %f, x3: %d, x2: %d, x1: %d, x0: %d, xSize: %d", temp, byte_stream[3],byte_stream[2], byte_stream[1], byte_stream[0], byte_stream.size());
## return byte_stream;
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Type"
# id: inverter1_type
# register_type: holding
# address: ${Felicity_Inv_Type} # 0xF800
# value_type: U_WORD
# register_count: 1
#
# - platform: homeassistant
# name: "Geyser Bottom Temperature"
# entity_id: sensor.sthome_ut8_geyser_bottom_temperature
# id: geyser_bottom_temperature
# on_raw_value:
# then:
# - script.execute: canbus_send_temperatures
## - canbus.send:
## canbus_id: canbus_sthome
## can_id: ${CB_GEYSER_BOTTOM_TEMPERATURE}
## data: !lambda |-
## double temp = id(geyser_bottom_temperature).raw_state;
## int value = (int) (temp * 16777216);
## std::vector<uint8_t> byte_stream(sizeof(value));
## memcpy(byte_stream.data(), &value, sizeof(value));
## ESP_LOGI("SND:${CB_GEYSER_BOTTOM_TEMPERATURE}", "Geyser BOTTOM temp: %d (%f)", value, temp);
## //ESP_LOGI("SND:0x401", "Geyser BOTTOM temp: %f", temp, byte_stream[3],byte_stream[2], byte_stream[1], byte_stream[0], byte_stream.size());
## return byte_stream;
#
# - platform: homeassistant
# name: "Ambient Temperature"
# entity_id: sensor.sthome_ut8_ambient_temperature
# id: ambient_temperature
# on_raw_value:
# then:
# - script.execute: canbus_send_temperatures
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Sub Type"
# register_type: holding
# address: ${Felicity_Inv_SubType} # 0xF801
# value_type: U_WORD
# register_count: 3
#
# # Report wifi signal strength every 5 min if changed
# - platform: wifi_signal
# name: WiFi Signal
# id: wifi_sig
# update_interval: 300s
# filters:
# - delta: 10%
text_sensor:
# - platform: template
# id: module_time
# name: "Module time"
# icon: mdi:clock
# lambda: |-
# auto time_obj = id(time_source).now();
# return time_obj.strftime("%Y-%m-%d %H:%M:%S");
# update_interval: 60s
# Expose WiFi information as sensors
- platform: wifi_info
ip_address:
name: IP
update_interval: 10s
mac_address:
name: Mac Address
entity_category: diagnostic
ssid:
name: "Connected SSID"
id: ssid
entity_category: diagnostic
# human readable update text sensor from sensor:uptime
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
- platform: template
name: 'Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
#script:
# - id: canbus_send_data
# then:
# - script.execute: canbus_send_temperatures
# - canbus.send:
# canbus_id: canbus_sthome
# can_id: ${CB_GEYSER_ENERGISED}
# data: !lambda |-
# if (id(geyser_heating).state) {
# std::vector<uint8_t> byte_stream = ${v_ON};
# ESP_LOGI("SND:${CB_GEYSER_ENERGISED}", "Geyser state: %c%c", byte_stream[0], byte_stream[1]);
# return byte_stream;
# }
# else {
# std::vector<uint8_t> byte_stream = ${v_OFF};
# ESP_LOGI("SND:${CB_GEYSER_ENERGISED}", "Geyser state: %c%c%c", byte_stream[0], byte_stream[1], byte_stream[2]);
# return byte_stream;
# }
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 CPU1 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU1_FW_Version} # 0xF80B
# value_type: U_WORD
# register_count: 1
#
# - id: canbus_send_temperatures
# then:
# - if:
# condition:
# lambda: 'return !isnan(id(geyser_top_temperature).raw_state) || !isnan(id(geyser_bottom_temperature).raw_state) || !isnan(id(ambient_temperature).raw_state);'
# then:
# - canbus.send:
# canbus_id: canbus_sthome
# can_id: ${CB_GEYSER_TEMPERATURES}
# data: !lambda |-
# double temp_top = isnan(id(geyser_top_temperature).raw_state) ? 0 : id(geyser_top_temperature).raw_state;
# double temp_bot = isnan(id(geyser_bottom_temperature).raw_state) ? 0 : id(geyser_bottom_temperature).raw_state;
# double temp_amb = isnan(id(ambient_temperature).raw_state) ? 0 : id(ambient_temperature).raw_state;
# int temp_top_int = (int)(temp_top * 256);
# int temp_bot_int = (int)(temp_bot * 256);
# int temp_amb_int = (int)(temp_amb * 256);
# std::vector<uint8_t> byte_stream(8, 0);
# byte_stream[0] = temp_top_int % 256;
# byte_stream[1] = (temp_top_int >> 8) % 256;
# byte_stream[2] = temp_bot_int % 256;
# byte_stream[3] = (temp_bot_int >> 8) % 256;
# byte_stream[4] = temp_amb_int % 256;
# byte_stream[5] = (temp_amb_int >> 8) % 256;
# ESP_LOGI("SND:${CB_GEYSER_TEMPERATURES}", "Geyser temps: %04X %04X %04X (%f, %f, %f)", byte_stream[0] + 256 * byte_stream[1], byte_stream[2] + 256 * byte_stream[3], byte_stream[4] + 256 * byte_stream[5], temp_top, temp_bot, temp_amb);
# return byte_stream;
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 CPU2 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU2_FW_Version} # 0xF80C
# value_type: U_WORD
# register_count: 3
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 SettingDataSn"
# register_type: holding
# address: ${Felicity_Inv_SettingDataSn} # 0x1100
# value_type: U_WORD
# register_count: 1
## lambda: |-
## if (!isnan(id(inverter1_type).state)) {
## return x; // Update the sensor's value if the condition is true
## } else {
## return NAN; // Return NaN to skip updating if the condition is false
## }
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Working Mode"
# register_type: holding
# address: ${Felicity_Inv_WorkingMode} # 0x1101
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Charge Mode"
# register_type: holding
# address: ${Felicity_Inv_BatteryChargingStage} # 0x1102
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Fault Code"
# register_type: holding
# address: ${Felicity_Inv_FaultCode} # 0x1103
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Power Flow"
# register_type: holding
# address: ${Felicity_Inv_PowerFlowMsg} # 0x1104
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Battery Voltage"
# register_type: holding
# address: ${Felicity_Inv_BatteryVoltage} # 0x1108
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Battery Current"
# register_type: holding
# address: ${Felicity_Inv_BatteryCurrent} # 0x1109
# value_type: S_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 BatteryPower"
# register_type: holding
# address: ${Felicity_Inv_BatteryPower} # 0x110A
# value_type: S_WORD
# register_count: 7
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACOutputVoltage} # 0x1111
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACInputVoltage} # 0x1117
# value_type: U_WORD
# register_count: 2
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Input Frequency"
# register_type: holding
# address: ${Felicity_Inv_ACInputFrequency} # 0x1119
# value_type: U_WORD
# register_count: 5
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Active Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputActivePower} # 0x111E
# value_type: S_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 AC Output Apparent Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputApparentPower} # 0x111F
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 Load Percentage"
# register_type: holding
# address: ${Felicity_Inv_LoadPercentage} # 0x1120
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 PV Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_PVInputVoltage} # 0x1126
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device1
# name: "Inverter1 PV Input Power"
# register_type: holding
# address: ${Felicity_Inv_PVInputPower} # 0x112A
# value_type: S_WORD
# register_count: 1
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Type"
# register_type: holding
# address: ${Felicity_Inv_Type} # 0xF800
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Sub Type"
# register_type: holding
# address: ${Felicity_Inv_SubType} # 0xF801
# value_type: U_WORD
# register_count: 1
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Dummy"
# register_type: holding
# address: 0xF802
# value_type: U_WORD
# register_count: 2
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 CPU1 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU1_FW_Version} # 0xF80B
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 CPU2 F/W Version"
# register_type: holding
# address: ${Felicity_Inv_CPU2_FW_Version} # 0xF80C
# value_type: U_WORD
# register_count: 3
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 SettingDataSn"
# register_type: holding
# address: ${Felicity_Inv_SettingDataSn} # 0x1100
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Working Mode"
# register_type: holding
# address: ${Felicity_Inv_WorkingMode} # 0x1101
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Charge Mode"
# register_type: holding
# address: ${Felicity_Inv_BatteryChargingStage} # 0x1102
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Fault Code"
# register_type: holding
# address: ${Felicity_Inv_FaultCode} # 0x1103
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Power Flow"
# register_type: holding
# address: ${Felicity_Inv_PowerFlowMsg} # 0x1104
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Battery Voltage"
# register_type: holding
# address: ${Felicity_Inv_BatteryVoltage} # 0x1108
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Battery Current"
# register_type: holding
# address: ${Felicity_Inv_BatteryCurrent} # 0x1109
# value_type: S_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 BatteryPower"
# register_type: holding
# address: ${Felicity_Inv_BatteryPower} # 0x110A
# value_type: S_WORD
# register_count: 7
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 AC Output Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACOutputVoltage} # 0x1111
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 AC Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_ACInputVoltage} # 0x1117
# value_type: U_WORD
# register_count: 2
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 AC Input Frequency"
# register_type: holding
# address: ${Felicity_Inv_ACInputFrequency} # 0x1119
# value_type: U_WORD
# register_count: 5
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 AC Output Active Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputActivePower} # 0x111E
# value_type: S_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 AC Output Apparent Power"
# register_type: holding
# address: ${Felicity_Inv_ACOutputApparentPower} # 0x111F
# value_type: U_WORD
# register_count: 1
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 Load Percentage"
# register_type: holding
# address: ${Felicity_Inv_LoadPercentage} # 0x1120
# value_type: U_WORD
# register_count: 6
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 PV Input Voltage"
# register_type: holding
# address: ${Felicity_Inv_PVInputVoltage} # 0x1126
# value_type: U_WORD
# register_count: 4
#
#- platform: modbus_controller
# modbus_controller_id: modbus_device2
# name: "Inverter2 PV Input Power"
# register_type: holding
# address: ${Felicity_Inv_PVInputPower} # 0x112A
# value_type: S_WORD
# register_count: 1

File diff suppressed because it is too large Load Diff

1529
sthome-ut9-bak.yml Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1227
sthome-ut9_bak.yml Normal file

File diff suppressed because it is too large Load Diff