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
 Type=simple
6
 Type=simple
7
 WorkingDirectory=/var/lib/pyheatpump/
7
 WorkingDirectory=/var/lib/pyheatpump/
8
 Environment="LOGLEVEL=INFO"
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
 KillMode=mixed
10
 KillMode=mixed
12
 TimeoutStopSec="infinity"
11
 TimeoutStopSec="infinity"
13
 PrivateTmp=true
12
 PrivateTmp=true

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

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

+ 5
- 6
pyheatpump/cli.py View File

57
         workers=1)
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
     logger = logger_init()
62
     logger = logger_init()
64
 
63
 
65
     from pyheatpump import modbus
64
     from pyheatpump import modbus
66
 
65
 
67
     try:
66
     try:
68
-        if type is None:
67
+        if len(types) == 0:
69
             var_types = VariableType.getall()
68
             var_types = VariableType.getall()
70
         else:
69
         else:
71
             var_types = {}
70
             var_types = {}
158
 
157
 
159
 
158
 
160
 
159
 
161
-@click.option('--since', is_flag=True)
162
 @cli.command()
160
 @cli.command()
163
 def supervise(since):
161
 def supervise(since):
164
     logger = logger_init()
162
     logger = logger_init()
204
     else:
202
     else:
205
         logger.warn('Unable to set data from supervisor\n{}'.format(control_data))
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
     post_packets = [
208
     post_packets = [
210
         Heatpump(mac_address, last_update, ['Analog']).packet,
209
         Heatpump(mac_address, last_update, ['Analog']).packet,

Loading…
Cancel
Save