mirror of
https://github.com/suaveolent/hoymiles-wifi.git
synced 2024-09-19 19:00:17 +00:00
Compare commits
3 Commits
18f88d810c
...
255a9109d8
Author | SHA1 | Date | |
---|---|---|---|
|
255a9109d8 | ||
|
c600d5af4c | ||
|
26148448cb |
@ -2,7 +2,7 @@
|
||||
|
||||
This Python library facilitates communication with Hoymiles DTUs and the HMS-XXXXW-2T HMS microinverters, utilizing protobuf messages.
|
||||
|
||||
For the Home Assistant integration have a look here:
|
||||
For the Home Assistant integration have a look here:
|
||||
https://github.com/suaveolent/ha-hoymiles-wifi
|
||||
|
||||
**Disclaimer: This library is not affiliated with Hoymiles. It is an independent project developed to provide tools for interacting with Hoymiles HMS-XXXXW-2T series micro-inverters featuring integrated WiFi DTU. Any trademarks or product names mentioned are the property of their respective owners.**
|
||||
@ -27,7 +27,7 @@ You can integrate the library into your own project, or simply use it in the com
|
||||
### Command line:
|
||||
|
||||
```
|
||||
hoymiles-wifi [-h] --host HOST [--as-json] <command>
|
||||
hoymiles-wifi [-h] --host HOST [--local_addr IP_OF_INTERFACE_TO_USE] [--as-json] <command>
|
||||
|
||||
commands:
|
||||
get-real-data-new,
|
||||
|
@ -314,6 +314,12 @@ async def main() -> None:
|
||||
parser.add_argument(
|
||||
"--host", type=str, required=True, help="IP address or hostname of the DTU"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--local_addr",
|
||||
type=str,
|
||||
required=False,
|
||||
help="IP address of the interface to bind to",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--as-json",
|
||||
action="store_true",
|
||||
@ -347,7 +353,7 @@ async def main() -> None:
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
dtu = DTU(args.host)
|
||||
dtu = DTU(args.host, args.local_addr)
|
||||
|
||||
# Execute the specified command using a switch case
|
||||
switch = {
|
||||
|
@ -70,10 +70,11 @@ class NetworkState(Enum):
|
||||
class DTU:
|
||||
"""DTU class."""
|
||||
|
||||
def __init__(self, host: str):
|
||||
def __init__(self, host: str, local_addr: str = None):
|
||||
"""Initialize DTU class."""
|
||||
|
||||
self.host = host
|
||||
self.local_addr = local_addr
|
||||
self.state = NetworkState.Unknown
|
||||
self.sequence = 0
|
||||
self.mutex = asyncio.Lock()
|
||||
@ -365,11 +366,13 @@ class DTU:
|
||||
+ request_as_bytes
|
||||
)
|
||||
|
||||
address = (self.host, dtu_port)
|
||||
ip_to_bind = (self.local_addr, 0) if self.local_addr is not None else None
|
||||
|
||||
async with self.mutex:
|
||||
try:
|
||||
reader, writer = await asyncio.open_connection(*address)
|
||||
reader, writer = await asyncio.open_connection(
|
||||
host=self.host, port=dtu_port, local_addr=ip_to_bind
|
||||
)
|
||||
|
||||
writer.write(message)
|
||||
await writer.drain()
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ setup(
|
||||
name="hoymiles-wifi",
|
||||
packages=["hoymiles_wifi", "hoymiles_wifi.protobuf"],
|
||||
install_requires=["protobuf", "crcmod"],
|
||||
version="0.2.3",
|
||||
version="0.2.4",
|
||||
description="A python library for interfacing with the Hoymiles DTUs and the HMS-XXXXW-2T series of micro-inverters using protobuf messages.",
|
||||
author="suaveolent",
|
||||
include_package_data=True,
|
||||
|
Loading…
Reference in New Issue
Block a user