homebridge-tauron-elicznik 0.0.2-beta42 → 0.0.2-beta43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('path');
4
+ const axios = require('axios');
4
5
  const fs = require('fs');
5
6
  const fsPromises = require('fs').promises;
6
- const pyshell = require('python-shell');
7
7
 
8
8
  const PLUGIN_NAME = 'homebridge-tauron-elicznik';
9
9
  const PLATFORM_NAME = 'tauroneLicznik';
@@ -170,17 +170,6 @@ class eLicznikDevice {
170
170
  async updateDeviceState() {
171
171
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
172
172
  try {
173
- var options = {
174
- mode: 'text',
175
- pythonOptions: ['-u'],
176
- args: [this.user, this.passwd, this.meterId]
177
- };
178
-
179
- pyshell.PythonShell.run(__dirname + '/src/elicznik.py', options, function (err, results) {
180
- if (err) throw err;
181
- // results is an array consisting of messages collected during execution
182
- console.log('results: %j', results.toString());
183
- });
184
173
 
185
174
  const energyImport = 0;
186
175
  const energyExport = 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tauron eLicznik",
3
3
  "name": "homebridge-tauron-elicznik",
4
- "version": "0.0.2-beta42",
4
+ "version": "0.0.2-beta43",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -19,7 +19,6 @@
19
19
  },
20
20
  "main": "index.js",
21
21
  "files": [
22
- "src",
23
22
  "index.js",
24
23
  "config.schema.json",
25
24
  "package.json",
@@ -32,7 +31,7 @@
32
31
  "homebridge": ">=1.3.0"
33
32
  },
34
33
  "dependencies": {
35
- "python-shell": "^3.0.0"
34
+ "axios": "^0.21.4"
36
35
  },
37
36
  "keywords": [
38
37
  "homebridge",
package/src/elicznik.py DELETED
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import sys
4
- import requests
5
- from requests import adapters
6
- import ssl
7
- from urllib3 import poolmanager
8
- import datetime
9
-
10
- # Add login details & meter ID here:
11
- username = sys.argv[0]
12
- password = sys.argv[1]
13
- meter_id = sys.argv[2]
14
-
15
- payload = {
16
- 'username': username,
17
- 'password': password,
18
- 'service': 'https://elicznik.tauron-dystrybucja.pl'
19
- }
20
-
21
- url = 'https://logowanie.tauron-dystrybucja.pl/login'
22
- charturl = 'https://elicznik.tauron-dystrybucja.pl/index/charts'
23
- headers = {'cache-control': 'no-cache'}
24
-
25
-
26
- class TLSAdapter(adapters.HTTPAdapter):
27
-
28
- def init_poolmanager(self, connections, maxsize, block=False):
29
- """Create and initialize the urllib3 PoolManager."""
30
- ctx = ssl.create_default_context()
31
- ctx.set_ciphers('DEFAULT@SECLEVEL=1')
32
- self.poolmanager = poolmanager.PoolManager(
33
- num_pools=connections,
34
- maxsize=maxsize,
35
- block=block,
36
- ssl_version=ssl.PROTOCOL_TLS,
37
- ssl_context=ctx)
38
-
39
-
40
- session = requests.session()
41
- session.mount('https://', TLSAdapter())
42
-
43
- p = session.request("POST", url, data=payload, headers=headers)
44
- p = session.request("POST", url, data=payload, headers=headers)
45
-
46
- chart_year = {
47
- # change timedelta to get data from another days (1 for yesterday)
48
- "dane[chartYear]": 2020,
49
- "dane[paramType]": "year",
50
- "dane[smartNr]": meter_id,
51
- # comment if don't want generated energy data in JSON output:
52
- "dane[checkOZE]": "on"
53
- }
54
-
55
- r = session.request("POST", charturl, data=chart_year, headers=headers)
56
-
57
- print(r.text)