Browse Source

[cli] fusion de fetch et supervise pour corresponse à l'ordre juste d'execution des tâches

Maxime Alves LIRMM@home 3 years ago
parent
commit
1cd47798f6
3 changed files with 7 additions and 9 deletions
  1. 1
    2
      config/pyheatpump_supervise.service
  2. 1
    1
      config/pyheatpump_supervise.timer
  3. 5
    6
      pyheatpump/cli.py

config/pyheatpump_fetch.service → config/pyheatpump_supervise.service View File

@@ -6,8 +6,7 @@ Wants=dev-rs485.device
6 6
 Type=simple
7 7
 WorkingDirectory=/var/lib/pyheatpump/
8 8
 Environment="LOGLEVEL=INFO"
9
-ExecStart=/usr/bin/env pyheatpump fetch -t D -t A -t I
10
-ExecStop=/usr/bin/env pyheatpump supervise --since
9
+ExecStart=/usr/bin/env pyheatpump supervise --since
11 10
 KillMode=mixed
12 11
 TimeoutStopSec="infinity"
13 12
 PrivateTmp=true

config/pyheatpump_fetch.timer → config/pyheatpump_supervise.timer View File

@@ -1,5 +1,5 @@
1 1
 [Unit]
2
-Description=Timer to launch pyheatpump fetch every minute
2
+Description=Timer to launch pyheatpump supervise every minute
3 3
 
4 4
 [Timer]
5 5
 OnStartSec=15sec

+ 5
- 6
pyheatpump/cli.py View File

@@ -57,15 +57,14 @@ def run(host, port):
57 57
         workers=1)
58 58
 
59 59
 
60
-@click.option('--type', '-t', default=None, multiple=True)
61
-@cli.command()
62
-def fetch(type):
60
+
61
+def fetch(types=[]):
63 62
     logger = logger_init()
64 63
 
65 64
     from pyheatpump import modbus
66 65
 
67 66
     try:
68
-        if type is None:
67
+        if len(types) == 0:
69 68
             var_types = VariableType.getall()
70 69
         else:
71 70
             var_types = {}
@@ -158,7 +157,6 @@ def fetch(type):
158 157
 
159 158
 
160 159
 
161
-@click.option('--since', is_flag=True)
162 160
 @cli.command()
163 161
 def supervise(since):
164 162
     logger = logger_init()
@@ -204,7 +202,8 @@ def supervise(since):
204 202
     else:
205 203
         logger.warn('Unable to set data from supervisor\n{}'.format(control_data))
206 204
 
207
-    time.sleep(3)
205
+    # Récupération de toutes les variables en modbus
206
+    fetch()
208 207
     
209 208
     post_packets = [
210 209
         Heatpump(mac_address, last_update, ['Analog']).packet,

Loading…
Cancel
Save