removed source/solar as a sudmodule

This commit is contained in:
Chris Stuurman 2026-03-20 12:24:33 +02:00
parent c19a547f58
commit 29cb34de15
13 changed files with 2506 additions and 2281 deletions

1
.gitignore vendored
View File

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

View File

@ -1,14 +1,14 @@
# ESPHome Config Folder # ESPHome Config Folder
This folder contains configuration files for ESPHome devices. The `solar` directory is specifically used for managing solar-related ESPHome setups. This folder contains configuration files for ESPHome devices. The `solar` directory is specifically used for managing solar-related ESPHome setups.
## Structure ## Structure
- `source/solar/`: Contains source code files and related resources for solar projects. - `source/solar/`: Contains source code files and related resources for solar projects.
## Usage ## Usage
1. Place your ESPHome YAML configuration files in this directory. 1. Place your ESPHome YAML configuration files in this directory.
2. Use the ESPHome CLI or dashboard to validate and upload configurations to your devices. 2. Use the ESPHome CLI or dashboard to validate and upload configurations to your devices.
For more information, visit the [ESPHome documentation](https://esphome.io/). For more information, visit the [ESPHome documentation](https://esphome.io/).

752
backup/sthome-ut3-bak.yaml Normal file
View File

@ -0,0 +1,752 @@
packages:
- !include common/wifi.yaml
- !include common/felicityinverter.yaml
substitutions:
name: sthome-ut3
friendly_name: "sthome-ut3"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
# 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'
esp32:
board: nodemcu-32s #esp32dev
framework:
type: arduino #esp-idf
# Enable logging
logger:
level: VERY_VERBOSE
initial_level: DEBUG
logs:
uart: VERY_VERBOSE
modbus: VERBOSE
modbus_controller: VERBOSE
# Enable Home Assistant API
api:
encryption:
key: "AIoquKPjpcHa2pcJ0aKxvtpM3mwgZuZhpCPtdVitP2Q="
ota:
- platform: esphome
password: "879012af7180c8700cee65fbf18704d1"
wifi:
manual_ip:
static_ip: 10.0.2.3
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${name} Fallback Hotspot"
password: "cGXb2DqkwaOr"
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
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: 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: 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: 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
#
#- 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
#
#- 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

View File

@ -1,102 +1,102 @@
# https://community.home-assistant.io/t/display-manually-set-rtc-ds3231-time-in-esphome-sntp-sync-every-12-hours-need-help-with-web-interface/868801 # https://community.home-assistant.io/t/display-manually-set-rtc-ds3231-time-in-esphome-sntp-sync-every-12-hours-need-help-with-web-interface/868801
# miloit # miloit
time: time:
- platform: sntp - platform: sntp
id: sntp_time id: sntp_time
web_server: web_server:
port: 80 port: 80
custom_component: custom_component:
- lambda: |- - lambda: |-
class DS3231Component : public PollingComponent { class DS3231Component : public PollingComponent {
public: public:
DS3231Component(esphome::time::RealTimeClock *rtc) : PollingComponent(10000), rtc_(rtc) {} DS3231Component(esphome::time::RealTimeClock *rtc) : PollingComponent(10000), rtc_(rtc) {}
void setup() override { void setup() override {
if (!Wire.requestFrom(0x68, 1)) { if (!Wire.requestFrom(0x68, 1)) {
ESP_LOGE("DS3231", "RTC not found at I2C address 0x68"); ESP_LOGE("DS3231", "RTC not found at I2C address 0x68");
return; return;
} }
ESP_LOGI("DS3231", "RTC found at I2C address 0x68"); ESP_LOGI("DS3231", "RTC found at I2C address 0x68");
auto now = this->rtc_->now(); auto now = this->rtc_->now();
if (now.is_valid()) { if (now.is_valid()) {
set_time(now.year, now.month, now.day_of_month, now.hour, now.minute, now.second, now.day_of_week); set_time(now.year, now.month, now.day_of_month, now.hour, now.minute, now.second, now.day_of_week);
ESP_LOGI("DS3231", "RTC time set to %04d-%02d-%02d %02d:%02d:%02d", ESP_LOGI("DS3231", "RTC time set to %04d-%02d-%02d %02d:%02d:%02d",
now.year, now.month, now.day_of_month, now.hour, now.minute, now.second); now.year, now.month, now.day_of_month, now.hour, now.minute, now.second);
} else { } else {
ESP_LOGE("DS3231", "SNTP time is not valid; cannot set RTC"); ESP_LOGE("DS3231", "SNTP time is not valid; cannot set RTC");
} }
} }
void update() override { void update() override {
auto time = get_time(); auto time = get_time();
if (time.year > 0) { if (time.year > 0) {
ESP_LOGI("DS3231", "Current RTC Time: %04d-%02d-%02d %02d:%02d:%02d", ESP_LOGI("DS3231", "Current RTC Time: %04d-%02d-%02d %02d:%02d:%02d",
time.year, time.month, time.day, time.hour, time.minute, time.second); time.year, time.month, time.day, time.hour, time.minute, time.second);
} else { } else {
ESP_LOGE("DS3231", "Failed to read time from RTC"); ESP_LOGE("DS3231", "Failed to read time from RTC");
} }
} }
void set_time(int year, int month, int day, int hour, int minute, int second, int day_of_week) { void set_time(int year, int month, int day, int hour, int minute, int second, int day_of_week) {
Wire.beginTransmission(0x68); Wire.beginTransmission(0x68);
Wire.write(0); // Start at register 0 Wire.write(0); // Start at register 0
Wire.write(dec_to_bcd(second)); // Seconds Wire.write(dec_to_bcd(second)); // Seconds
Wire.write(dec_to_bcd(minute)); // Minutes Wire.write(dec_to_bcd(minute)); // Minutes
Wire.write(dec_to_bcd(hour)); // Hours Wire.write(dec_to_bcd(hour)); // Hours
Wire.write(dec_to_bcd(day_of_week)); // Day of the week Wire.write(dec_to_bcd(day_of_week)); // Day of the week
Wire.write(dec_to_bcd(day)); // Day of the month Wire.write(dec_to_bcd(day)); // Day of the month
Wire.write(dec_to_bcd(month)); // Month Wire.write(dec_to_bcd(month)); // Month
Wire.write(dec_to_bcd(year - 2000)); // Year Wire.write(dec_to_bcd(year - 2000)); // Year
Wire.endTransmission(); Wire.endTransmission();
} }
struct Time { struct Time {
int year; int year;
int month; int month;
int day; int day;
int hour; int hour;
int minute; int minute;
int second; int second;
int day_of_week; int day_of_week;
}; };
Time get_time() { Time get_time() {
Wire.beginTransmission(0x68); Wire.beginTransmission(0x68);
Wire.write(0); // Start at register 0 Wire.write(0); // Start at register 0
Wire.endTransmission(); Wire.endTransmission();
if (Wire.requestFrom(0x68, 7) != 7) { if (Wire.requestFrom(0x68, 7) != 7) {
ESP_LOGE("DS3231", "Failed to read time registers"); ESP_LOGE("DS3231", "Failed to read time registers");
return Time{0, 0, 0, 0, 0, 0, 0}; return Time{0, 0, 0, 0, 0, 0, 0};
} }
uint8_t second = bcd_to_dec(Wire.read()); uint8_t second = bcd_to_dec(Wire.read());
uint8_t minute = bcd_to_dec(Wire.read()); uint8_t minute = bcd_to_dec(Wire.read());
uint8_t hour = bcd_to_dec(Wire.read()); uint8_t hour = bcd_to_dec(Wire.read());
uint8_t day_of_week = bcd_to_dec(Wire.read()); uint8_t day_of_week = bcd_to_dec(Wire.read());
uint8_t day = bcd_to_dec(Wire.read()); uint8_t day = bcd_to_dec(Wire.read());
uint8_t month = bcd_to_dec(Wire.read()); uint8_t month = bcd_to_dec(Wire.read());
uint16_t year = bcd_to_dec(Wire.read()) + 2000; uint16_t year = bcd_to_dec(Wire.read()) + 2000;
return Time{year, month, day, hour, minute, second, day_of_week}; return Time{year, month, day, hour, minute, second, day_of_week};
} }
private: private:
esphome::time::RealTimeClock *rtc_; esphome::time::RealTimeClock *rtc_;
uint8_t dec_to_bcd(int val) { uint8_t dec_to_bcd(int val) {
return ((val / 10 * 16) + (val % 10)); return ((val / 10 * 16) + (val % 10));
} }
int bcd_to_dec(uint8_t val) { int bcd_to_dec(uint8_t val) {
return ((val / 16 * 10) + (val % 16)); return ((val / 16 * 10) + (val % 16));
} }
}; };
auto my_rtc = new DS3231Component(id(sntp_time)); auto my_rtc = new DS3231Component(id(sntp_time));
App.register_component(my_rtc); App.register_component(my_rtc);
return {}; return {};

View File

@ -1,57 +1,57 @@
# ESPHome config/components/ads131m08 # ESPHome config/components/ads131m08
This folder contains source code files and related resources for external ads131m08 component. This folder contains source code files and related resources for external ads131m08 component.
## Example .yaml config ## Example .yaml config
--- ---
```yaml ```yaml
external_components: external_components:
- source: - source:
type: local type: local
path: components # Path relative to this YAML file path: components # Path relative to this YAML file
components: [ ads131m08 ] components: [ ads131m08 ]
ads131m08: ads131m08:
id: highres_adc id: highres_adc
cs_pin: GPIO5 cs_pin: GPIO5
drdy_pin: GPIO10 drdy_pin: GPIO10
vref: 1.25 vref: 1.25
sensor: sensor:
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 0 channel: 0
name: "ADS Channel 0 Voltage" name: "ADS Channel 0 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 1 channel: 1
name: "ADS Channel 1 Voltage" name: "ADS Channel 1 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 2 channel: 2
name: "ADS Channel 2 Voltage" name: "ADS Channel 2 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 3 channel: 3
name: "ADS Channel 3 Voltage" name: "ADS Channel 3 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 4 channel: 4
name: "ADS Channel 4 Voltage" name: "ADS Channel 4 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 5 channel: 5
name: "ADS Channel 5 Voltage" name: "ADS Channel 5 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 6 channel: 6
name: "ADS Channel 6 Voltage" name: "ADS Channel 6 Voltage"
- platform: ads131m08 - platform: ads131m08
ads_hub_id: highres_adc ads_hub_id: highres_adc
channel: 7 channel: 7
name: "ADS Channel 7 Voltage" name: "ADS Channel 7 Voltage"
``` ```
For more information, visit the [ESPHome documentation](https://esphome.io/). For more information, visit the [ESPHome documentation](https://esphome.io/).

View File

@ -1,29 +1,29 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome import pins from esphome import pins
from esphome.components import spi from esphome.components import spi
from esphome.const import ( from esphome.const import (
CONF_ID CONF_ID
) )
CONF_DRDY_PIN = "drdy_pin" CONF_DRDY_PIN = "drdy_pin"
CONF_REFERENCE_VOLTAGE = "reference_voltage" CONF_REFERENCE_VOLTAGE = "reference_voltage"
DEPENDENCIES = ["spi"] DEPENDENCIES = ["spi"]
ads131m08_ns = cg.esphome_ns.namespace("ads131m08") ads131m08_ns = cg.esphome_ns.namespace("ads131m08")
ADS131M08Hub = ads131m08_ns.class_("ADS131M08Hub", cg.Component, spi.SPIDevice) ADS131M08Hub = ads131m08_ns.class_("ADS131M08Hub", cg.Component, spi.SPIDevice)
CONFIG_SCHEMA = cv.Schema({ CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(ADS131M08Hub), cv.GenerateID(): cv.declare_id(ADS131M08Hub),
cv.Required(CONF_DRDY_PIN): pins.internal_gpio_input_pin_schema, cv.Required(CONF_DRDY_PIN): pins.internal_gpio_input_pin_schema,
cv.Optional(CONF_REFERENCE_VOLTAGE, default=1.2): cv.float_range(min=1.1, max=1.3), cv.Optional(CONF_REFERENCE_VOLTAGE, default=1.2): cv.float_range(min=1.1, max=1.3),
}).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema(cs_pin_required=True)) }).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema(cs_pin_required=True))
async def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)
await spi.register_spi_device(var, config) await spi.register_spi_device(var, config)
drdy = await cg.gpio_pin_expression(config[CONF_DRDY_PIN]) drdy = await cg.gpio_pin_expression(config[CONF_DRDY_PIN])
reference_voltage = config[CONF_REFERENCE_VOLTAGE] reference_voltage = config[CONF_REFERENCE_VOLTAGE]
cg.add(var.set_reference_voltage(reference_voltage)) cg.add(var.set_reference_voltage(reference_voltage))
cg.add(var.set_drdy_pin(drdy)) cg.add(var.set_drdy_pin(drdy))

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,34 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.components import sensor from esphome.components import sensor
from esphome.const import ( from esphome.const import (
CONF_ID, CONF_CHANNEL, STATE_CLASS_MEASUREMENT, DEVICE_CLASS_VOLTAGE, UNIT_VOLT, ICON_FLASH CONF_ID, CONF_CHANNEL, STATE_CLASS_MEASUREMENT, DEVICE_CLASS_VOLTAGE, UNIT_VOLT, ICON_FLASH
) )
from . import ADS131M08Hub, ads131m08_ns from . import ADS131M08Hub, ads131m08_ns
AUTO_LOAD = [ AUTO_LOAD = [
"sensor", "sensor",
] ]
CONF_ADS131M08_ID = "ads131m08_id" CONF_ADS131M08_ID = "ads131m08_id"
ADS131M08Sensor = ads131m08_ns.class_("ADS131M08Sensor", sensor.Sensor, cg.Component) ADS131M08Sensor = ads131m08_ns.class_("ADS131M08Sensor", sensor.Sensor, cg.Component)
CONFIG_SCHEMA = sensor.sensor_schema( CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT, unit_of_measurement=UNIT_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=DEVICE_CLASS_VOLTAGE,
icon=ICON_FLASH, icon=ICON_FLASH,
state_class=STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
).extend({ ).extend({
cv.GenerateID(): cv.declare_id(ADS131M08Sensor), cv.GenerateID(): cv.declare_id(ADS131M08Sensor),
cv.Required(CONF_ADS131M08_ID): cv.use_id(ADS131M08Hub), cv.Required(CONF_ADS131M08_ID): cv.use_id(ADS131M08Hub),
cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=7), cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=7),
}).extend(cv.COMPONENT_SCHEMA) }).extend(cv.COMPONENT_SCHEMA)
async def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)
await sensor.register_sensor(var, config) await sensor.register_sensor(var, config)
hub = await cg.get_variable(config[CONF_ADS131M08_ID]) hub = await cg.get_variable(config[CONF_ADS131M08_ID])
cg.add(hub.register_sensor(config[CONF_CHANNEL], var)) cg.add(hub.register_sensor(config[CONF_CHANNEL], var))

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- 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" <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"> viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css"> <style type="text/css">
.st0{fill:#FF0000;} .st0{fill:#FF0000;}
</style> </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 <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-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 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 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 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"/> 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> </svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,6 +1,5 @@
packages: packages:
- !include common/wifi.yaml - !include common/wifi.yaml
- !include common/felicityinverter.yaml
substitutions: substitutions:
name: sthome-ut3 name: sthome-ut3
@ -9,30 +8,25 @@ substitutions:
esphome: esphome:
name: "${name}" name: "${name}"
friendly_name: "${friendly_name}" friendly_name: "${friendly_name}"
# on_boot: includes:
# - priority: 600 # This is where most sensors are set up (higher number means higher priority) - source # copies folder with files to relevant to be included in esphome compile
# then: - <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
# - uart.write: - <source/solar/cbf_store.h>
# id: inv_uart1 - <source/solar/cbf_pylon.h>
# data: [0x0D, 0x0A] - <source/solar/cbf_store_pylon.h>
# - uart.write: - <source/solar/cbf_sthome.h>
# id: inv_uart2 - <source/solar/cbf_store_sthome.h>
# data: [0x0D, 0x0A] - <source/solar/cbf_cache.h>
#external_components:
# - source: github://pr#8103
# components: [uart]
# - source: github://pr#8032
# components: [modbus, modbus_controller] #, growatt_solar]
# refresh: 1h
globals: globals:
- id: geyser_relay_status - id: geyser_relay_status
type: bool type: bool
restore_value: yes restore_value: yes
initial_value: 'false' initial_value: 'false'
debug:
update_interval: 10s
esp32: esp32:
board: nodemcu-32s #esp32dev board: nodemcu-32s #esp32dev
framework: framework:
@ -67,34 +61,8 @@ wifi:
captive_portal: captive_portal:
uart: #preferences:
- id: inv_uart1 # flash_write_interval: 30s
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: sun:
id: sun_sensor id: sun_sensor
@ -103,650 +71,154 @@ sun:
time: time:
- platform: homeassistant - platform: homeassistant
id: time_source
text_sensor:
- platform: debug
device:
name: "Device Info"
reset_reason:
name: "Reset Reason"
# human readable update text sensor from sensor:uptime
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
update_interval: 10s
switch: switch:
- platform: restart - platform: restart
name: "${name} Restart" name: "${name} Restart"
id: "restart_switch" id: "restart_switch"
modbus: - platform: gpio
- id: modbus1 pin:
uart_id: inv_uart1 number: GPIO16
# flow_control_pin: GPIO4 inverted: true
send_wait_time: 1200ms #250ms id: relay1
disable_crc: false name: "Floodlights Backyard"
role: server icon: "mdi:light-flood-down"
restore_mode: RESTORE_DEFAULT_OFF
# the backyard floodlight auto turns off in 4min 14 sec. So we need to switch relay off just before or at this time
# TODO: remove or extend auto turn off to >= 10min
on_turn_on:
- delay: 250s
- switch.turn_off: relay1
# - id: modbus2 - platform: gpio
# uart_id: inv_uart2 pin:
# #flow_control_pin: GPIO27 number: GPIO17
# send_wait_time: 1200ms #250ms inverted: true
# disable_crc: false id: relay2
# role: server name: "Relay 2"
icon: "mdi:run-fast"
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- delay: 1000ms
- switch.turn_off: relay2
modbus_controller: - platform: gpio
# - id: modbus_device1 pin:
# modbus_id: modbus1 number: GPIO18
# address: 0x01 inverted: true
# allow_duplicate_commands: False id: relay3
# command_throttle: 0ms name: "Relay 3"
# update_interval: 10s #30s icon: "mdi:run-fast"
# offline_skip_updates: 2 restore_mode: RESTORE_DEFAULT_OFF
# max_cmd_retries: 0 on_turn_on:
# setup_priority: -10 - delay: 1000ms
# - id: modbus_device2 - switch.turn_off: relay3
# modbus_id: modbus2
# address: 0x01 - platform: gpio
# allow_duplicate_commands: False pin:
# command_throttle: 0ms number: GPIO19
# update_interval: 60s #30s inverted: true
# offline_skip_updates: 2 id: relay4
# max_cmd_retries: 0 name: "Alarm Zone 4"
# setup_priority: -10 icon: "mdi:alarm-light-outline"
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- if:
condition:
- lambda: |-
double sun_elevation = id(sun_sensor).elevation();
return (sun_elevation <= -6); // -6° = civil twilight, -12° = nautical twilight, -18° = astronomical twilight
#- sun.is_below_horizon:
then:
- switch.turn_on: relay1
- if:
condition:
- binary_sensor.is_on: floodlight_test
then:
- switch.turn_on: relay1
- delay: 30s
- switch.turn_off: relay4
- 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 # define DIGITAL_D1 04
# server_registers: binary_sensor:
# - address: 0x1100 - platform: gpio
# value_type: U_WORD # device_class: light
# read_lambda: |- id: floodlight_test
# return 0x01; pin:
# - address: 0x1101 number: GPIO04
# value_type: U_WORD mode:
# read_lambda: |- input: true
# 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 pullup: true
# - address: 0x1102 filters:
# value_type: U_WORD - delayed_off: 100ms
# read_lambda: |- name: "Floodlights Test Mode"
# return 0x02; // No charge 1=Constant current charge/Bulk charge 2=Constant voltage charge/Absorption charge 3=Float charge/Float charge icon: "mdi:lightbulb-on-outline"
# - address: 0x1103 # Fault Code
# value_type: U_WORD sensor:
# read_lambda: |- - platform: adc
# return 0x0; pin: 35
# - address: 0x1104 # PowerFlowMsg name: "Alarm Signal"
# value_type: U_WORD id: alarm_signal
# read_lambda: |- update_interval: 2000ms
# return 0x0; attenuation: 12db
# - address: 0x1105 # dummy sampling_mode: avg
# value_type: U_WORD filters:
# read_lambda: |- - lambda:
# return 0x0; if (x >= 3.11) {
# - address: 0x1106 # dummy return x * 1.60256;
# value_type: U_DWORD } else if (x <= 0.25) {
# read_lambda: |- return 0;
# return 0x0; } else {
# - address: 0x1108 # Battery voltage return x * 1.51;
# value_type: U_WORD }
# read_lambda: |- on_value:
# return 0x3A; then:
# - address: 0x1109 # Battery current # switch on floodlights
# value_type: S_WORD lambda: |-
# read_lambda: |- if (id(alarm_signal).state > 1.5) {
# return 0xFFC4; // -60A id(relay1).turn_on();
# - 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: # human readable uptime sensor output to the text sensor above
#- platform: modbus_controller - platform: uptime
# modbus_controller_id: modbus_device1 name: Uptime in Days
# name: "Inverter1 SerialNo" id: uptime_sensor_days
# register_type: holding update_interval: 10s
# address: ${Felicity_Inv_SerialNo} # 0xF804 on_raw_value:
# response_size: 7 then:
# register_count: 7 - text_sensor.template.publish:
# raw_encode: HEXBYTES id: uptime_human
# state: !lambda |-
##- platform: modbus_controller int seconds = round(id(uptime_sensor_days).raw_state);
## modbus_controller_id: modbus_device2 int days = seconds / (24 * 3600);
## name: "Inverter2 SerialNo" seconds = seconds % (24 * 3600);
## register_type: holding int hours = seconds / 3600;
## address: ${Felicity_Inv_SerialNo} # 0xF804 seconds = seconds % 3600;
## response_size: 7 int minutes = seconds / 60;
## register_count: 7 seconds = seconds % 60;
## raw_encode: HEXBYTES auto days_str = std::to_string(days);
# auto hours_str = std::to_string(hours);
#sensor: auto minutes_str = std::to_string(minutes);
#- platform: modbus_controller auto seconds_str = std::to_string(seconds);
# modbus_controller_id: modbus_device1 return (
# name: "Inverter1 Type" (days ? days_str + "d " : "") +
# id: inverter1_type (hours ? hours_str + "h " : "") +
# register_type: holding (minutes ? minutes_str + "m " : "") +
# address: ${Felicity_Inv_Type} # 0xF800 (seconds_str + "s")
# value_type: U_WORD ).c_str();
# 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_WORD
# 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_WORD
# 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_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