minor updates, version up to 1.0.1
This commit is contained in:
parent
47ab3d064d
commit
c9edd67172
@ -12,10 +12,12 @@ pip install inverterd
|
||||
|
||||
## Usage example
|
||||
```python
|
||||
from inverterd import Client
|
||||
from inverterd import Client, Format
|
||||
|
||||
c = Client(8305, '127.0.0.1')
|
||||
c.format('json')
|
||||
c.connect()
|
||||
|
||||
c.format(Format.JSON)
|
||||
print(c.exec('get-status'))
|
||||
print(c.exec('get-year-generated', (2021,)))
|
||||
```
|
||||
|
@ -11,8 +11,15 @@ class Format(Enum):
|
||||
|
||||
class Client:
|
||||
def __init__(self, port=8305, host='127.0.0.1'):
|
||||
self._host = host
|
||||
self._port = port
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.connect((host, port))
|
||||
|
||||
def __del__(self):
|
||||
self.sock.close()
|
||||
|
||||
def connect(self):
|
||||
self.sock.connect((self._host, self._port))
|
||||
|
||||
def _write(self, line):
|
||||
self.sock.sendall((line+'\r\n').encode())
|
||||
|
Loading…
x
Reference in New Issue
Block a user