Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
basking-in-the-sun2000 committed Jun 25, 2021
1 parent 5fcd15d commit 2c7569b
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 181 deletions.
10 changes: 6 additions & 4 deletions Huawei.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import config
import emails

# Change use to ext for type you won't use or aren't defined by your inverter

_register_map = {
'Model': {'addr': '30000', 'registers': 15, 'name': 'Model', 'scale': 1, 'type': 'str', 'units': '' , 'use': 'info', 'method': 'hold'},
'SN': {'addr': '30015', 'registers': 10, 'name': 'Serial Number', 'scale': 1, 'type': 'str', 'units': '' , 'use': 'info', 'method': 'hold'},
Expand Down Expand Up @@ -278,8 +280,9 @@ def inv_address():
udp_message = bytes([0x5a, 0x5a, 0x5a, 0x5a, 0x00, 0x41, 0x3a, 0x04])

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.connect(("8.8.8.8", 80))
sock.connect(("1.1.1.1", 80))
ip = sock.getsockname()[0]
ip_self = ip
ip = socket.inet_aton(ip)
sock.close()

Expand All @@ -294,9 +297,8 @@ def inv_address():
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.settimeout(3.0)
sock.settimeout(10.0)
sock.bind(("", 6600))
time.sleep(5)
sock.sendto(udp_message, ('<broadcast>', 6600))
i = 0
while True:
Expand All @@ -321,7 +323,7 @@ def inv_address():
return config.inverter_ip
emails.send_mail("can't find inverter" + str(e))

if len(data) == 30:
if addr[0] != ip_self:
addr = str(addr[0])
if config.debug:
print("inverter address: " + addr)
Expand Down
3 changes: 2 additions & 1 deletion config.default.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
supla_api = ""
supla_dev_id = 0
debug = False
daily_reports = True
#emailing info
email_sent = ""
fromaddr = "datalogger@my_domain.com"
Expand All @@ -53,7 +54,7 @@
diverters_io = {0 : ("gpio", 10), 1 : ("gpio", 11)} #replace to reflect the output type and address

# The load won't activate until the day set below. Time is assumed to be 0 hours
diverters_holiday = {0 : "2020-10-25", 1 : "2020-10-25"}
diverters_holiday = {0 : "2020-10-25", 1 : "2020-11-14"}

#Higher priority will be first on and last off. If same priority any can be first or last
#If priority is -1, then it won't activate at that hour
Expand Down
Loading

1 comment on commit 2c7569b

@basking-in-the-sun2000
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dashboard - now goes back to the 18th (my billing date) of 2 months back
Email - changed to plain rather than html
Huawei - should now pickup the inverter’s address
Main - will adjust the time to grab 18 forecast
Should grab all the status changes
will send a daily report by email (config option to disable)
Status (Grafana) - should display all the status messages now

Please sign in to comment.