summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-05-16 01:35:16 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-05-16 01:35:16 +0300
commitc9edd6717283a4bf11bdda91e95b70590ac84a2f (patch)
tree082fe36b050764e0b84160b91019da706107d15f
parent47ab3d064d1fff7645fa55e39a1642e9643107e1 (diff)
minor updates, version up to 1.0.1
-rw-r--r--README.md6
-rw-r--r--inverterd/inverterd.py9
-rw-r--r--setup.cfg2
3 files changed, 13 insertions, 4 deletions
diff --git a/README.md b/README.md
index 106605b..af12a45 100644
--- a/README.md
+++ b/README.md
@@ -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,)))
```
diff --git a/inverterd/inverterd.py b/inverterd/inverterd.py
index 9f07c2e..5b9541e 100644
--- a/inverterd/inverterd.py
+++ b/inverterd/inverterd.py
@@ -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())
diff --git a/setup.cfg b/setup.cfg
index 1140bcc..e27b57d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = inverterd
-version = 1.0.0
+version = 1.0.1
author = Evgeny Zinoviev
author_email = me@ch1p.io
description =