Skip to content

Commit

Permalink
Times and Control Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Sep 13, 2023
1 parent f90d6fe commit 263b3df
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
deleted_from_storgae.txt
umodbus_scan.py
ha_solis_modbus.code-workspace
.vscode/settings.json
3 changes: 3 additions & 0 deletions inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ input_boolean:
solis_storage_mode_spontaneous:
name: Solis Storage Mode - Spontaneous

solis_storage_mode_feed_in_priority:
name: Solis Storage Mode - Feed-In Priority

input_datetime:
economy_7_start:
name: Economy 7 Start
Expand Down
32 changes: 32 additions & 0 deletions scripts.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
set_solis_storage_toggles:
alias: Set Solis Storage Toggles
sequence:
- if:
- condition: template
value_template:
"{{states('sensor.solis_energy_storage_control_switch') |
int | bitwise_and(64) == 64}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id:
- input_boolean.solis_storage_mode_feed_in_priority
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.solis_storage_mode_feed_in_priority
- if:
- condition: template
value_template:
Expand Down Expand Up @@ -97,6 +113,22 @@ set_solis_storage_toggles:
- input_boolean.solis_storage_mode_spontaneous
mode: single
icon: mdi:toggle-switch-off-outline
solis_set_time:
alias: Solis Set Time
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43003
register_value: '{{now().hour}}'
- service: script.solis_write_holding_register
data:
register_addr: 43004
register_value: '{{now().minute}}'
- service: script.solis_write_holding_register
data:
register_addr: 43005
register_value: '{{now().second}}'
mode: single
solis_set_energy_storage_mode:
alias: Solis Set Energy Storage Mode
fields:
Expand Down
30 changes: 30 additions & 0 deletions solis-template.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
template:
- sensor:
- name: Solis Date Time (Read Only)
unique_id: solis_date_time_ro
device_class: timestamp
state: >-
{% set y = states('sensor.solis_year_ro')%}
{% set m = states('sensor.solis_month_ro')%}
{% set d = states('sensor.solis_day_ro')%}
{% set h = states('sensor.solis_hour_ro')%}
{% set t = states('sensor.solis_minute_ro')%}
{% set dt = y + "-" + m + "-" + d + " " + h + ":" + t %}
{{as_local(strptime(dt, "%y-%m-%d %H:%M"))}}
- name: Solis Date Time (Read/Write)
unique_id: solis_date_time_rw
device_class: timestamp
state: >-
{% set y = states('sensor.solis_year_rw')%}
{% set m = states('sensor.solis_month_rw')%}
{% set d = states('sensor.solis_day_rw')%}
{% set h = states('sensor.solis_hour_rw')%}
{% set t = states('sensor.solis_minute_rw')%}
{% set s = states('sensor.solis_second_rw')%}
{% set dt = y + "-" + m + "-" + d + " " + h + ":" + t + ":" + s %}
{{as_local(strptime(dt, "%y-%m-%d %H:%M:%S"))}}
- name: "Solis Grid Active Power (Negative)"
unique_id: "Solis Grid Active Power (Negative)"
unit_of_measurement: W
Expand Down Expand Up @@ -53,6 +82,7 @@ template:
+ 8 * (states('input_boolean.solis_storage_mode_wake_up') == 'on') | int
+ 16 * (states('input_boolean.solis_storage_mode_backup') == 'on') | int
+ 32 * (states('input_boolean.solis_storage_mode_grid_charge') == 'on') | int
+ 64 * (states('input_boolean.solis_solis_storage_mode_feed_in_priority') == 'on') | int
}}
- name: "Solis Eco7 Time Remaining"
Expand Down
114 changes: 114 additions & 0 deletions solis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,120 @@
# port: 8899 # for DLS-L sticks

sensors:
- name: Solis Year RO
slave: 1
address: 33022
count: 1
scale: 1
input_type: input
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Month RO
slave: 1
address: 33023
count: 1
scale: 1
input_type: input
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Day RO
slave: 1
address: 33024
count: 1
scale: 1
input_type: input
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Hour RO
slave: 1
address: 33025
count: 1
scale: 1
input_type: input
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Minute RO
slave: 1
address: 33026
count: 1
scale: 1
input_type: input
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement

- name: Solis Year RW
slave: 1
address: 43000
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Month RW
slave: 1
address: 43001
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Day RW
slave: 1
address: 43002
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Hour RW
slave: 1
address: 43003
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Minute RW
slave: 1
address: 43004
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement
- name: Solis Second RW
slave: 1
address: 43005
count: 1
scale: 1
input_type: holding
data_type: uint16
lazy_error_count: 5
scan_interval: 60
state_class: measurement


# Temperature
- name: Solis Temperature
slave: 1
address: 33093
Expand Down
40 changes: 20 additions & 20 deletions umodbus_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#%%
# %%
# This script will test umodbus comms to a Solis Hybrid Inverter with a DLS-L LAN Data Logger
#
# It requires the umodbus module
Expand All @@ -11,24 +11,24 @@

# configuration
CFG = {
'Waveshare': {
'IP': "192.168.4.40",
'PORT': 502,
"Waveshare": {
"IP": "192.168.4.40",
"PORT": 502,
},
"S2-WL": {
"IP": "192.168.4.237",
"PORT": 502,
},
"DLS-L": {
"IP": "192.168.4.79",
"PORT": 8899,
},

'S2-WL': {
'IP': "192.168.4.237",
'PORT': 502,
},

'DLS-L': {
'IP': "192.168.4.79",
'PORT': 8899,
}

} # Update with your inverter IP

devices = ['S2-WL', 'Waveshare', ]
devices = [
# 'S2-WL',
"Waveshare",
]

payloads = [
{
Expand Down Expand Up @@ -66,16 +66,16 @@
sock = {}
for device in devices:
sock[device] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock[device].connect((CFG[device]['IP'], CFG[device]['PORT']))
sock[device].connect((CFG[device]["IP"], CFG[device]["PORT"]))
print(f"Device: {device}")
print('-' * 32 + '\n')
print("-" * 32 + "\n")
for payload in payloads:
message = tcp.read_input_registers(slave_id=1, starting_address=payload["addrs"], quantity=payload["len"])
response = tcp.send_message(message, sock[device])
val = float(response[0]) * payload["scale"]
print(f"{(payload['desc']+':'):25s}{val:5.1f} {payload['uom']}")

print("\n\n")
sock[device].close()
sock[device].close()

# %%

0 comments on commit 263b3df

Please sign in to comment.