Browse Source

[models/variable_type] on shifte la réponse dans la classe du type

Maxime Alves LIRMM@home 3 years ago
parent
commit
55c943c149
3 changed files with 9 additions and 7 deletions
  1. 2
    3
      pyheatpump/cli.py
  2. 1
    2
      pyheatpump/heatpump.py
  3. 6
    2
      pyheatpump/models/variable_type.py

+ 2
- 3
pyheatpump/cli.py View File

@@ -15,7 +15,6 @@ import requests
15 15
 
16 16
 from pyheatpump.logger import logger_init
17 17
 from pyheatpump.models import *
18
-from pyheatpump.lib import shift_response
19 18
 
20 19
 CONTEXT_SETTINGS={
21 20
     'default_map':{'run': {}}
@@ -210,10 +209,10 @@ def supervise(since):
210 209
     logger.info(build_url(post_url))
211 210
 
212 211
     for packet in post_packets:
213
-        logger.debug('Will send %s', shift_response(packet))
212
+        logger.debug('Will send %s', packet)
214 213
         post_resp = requests.post(
215 214
             url=build_url(post_url),
216
-            json=shift_response(packet),
215
+            json=packet,
217 216
             verify=False,
218 217
             timeout=200
219 218
         )

+ 1
- 2
pyheatpump/heatpump.py View File

@@ -3,7 +3,6 @@ from datetime import datetime
3 3
 from starlette.routing import Router, Route
4 4
 from starlette.responses import JSONResponse
5 5
 from .config import config
6
-from .lib import shift_response
7 6
 import uvicorn
8 7
 
9 8
 from pyheatpump.models import *
@@ -16,7 +15,7 @@ def get_variable_values(request):
16 15
         time = datetime.fromisoformat(request.params['time'])
17 16
         h = Heatpump(config.get('heatpump', 'mac_address'), request.params['time'])
18 17
 
19
-    return JSONResponse(shift_response(h.packet))
18
+    return JSONResponse(h.packet)
20 19
 
21 20
 
22 21
 ROUTES=[

+ 6
- 2
pyheatpump/models/variable_type.py View File

@@ -64,8 +64,12 @@ class VariableType(RowClass):
64 64
 
65 65
     def get_variables_values(self):
66 66
         from .variable import Variable
67
-        print(self)
68
-        return Variable.getall_values_of_type(self)
67
+        values = Variable.getall_values_of_type(self)
68
+        res = {}
69
+        for address, variable in values.items():
70
+            res[str(address - self.start_address + 1)] = variable
71
+        return res
72
+
69 73
 
70 74
     def get_variables_values_since(self, since: int):
71 75
         from .variable import Variable

Loading…
Cancel
Save