Browse Source

Usage of mqtt app_name for client instance + no switch off on init

master
Dirk Alders 2 years ago
parent
commit
e8334669e8
1 changed files with 2 additions and 9 deletions
  1. 2
    9
      powerplug.py

+ 2
- 9
powerplug.py View File

@@ -1,6 +1,6 @@
1 1
 import config
2 2
 import logging
3
-import paho.mqtt.client as mqtt
3
+import paho.mqtt.client as paho
4 4
 import report
5 5
 import socket
6 6
 import subprocess
@@ -19,14 +19,7 @@ class sispmctl(object):
19 19
     def __init__(self, mqtt_client):
20 20
         logger.info("Starting sispmctl module...")
21 21
         self.__mqtt_client__ = mqtt_client
22
-        self.__state__ = [False, False, False, False]
23 22
         self.__state_requests__ = [{}, {}, {}, {}]
24
-        try:
25
-            out_txt = subprocess.check_output(["sudo", "sispmctl", "-f", "all"]).decode('UTF-8')
26
-        except subprocess.CalledProcessError as grepexc:                                                                                                   
27
-            logger.error("sispm error code %d", grepexc.returncode)
28
-        else:
29
-            logger.info('sispmctl all channels switched off')
30 23
         self.publish_states()
31 24
 
32 25
     def __filter_output_parameter__(self, output):
@@ -99,7 +92,7 @@ class mqtt_powerplug(object):
99 92
     ]
100 93
 
101 94
     def __init__(self):
102
-        self.__client__ = mqtt.Client("mqtt_powerplug")                         # create client object
95
+        self.__client__ = paho.Client(config.APP_NAME)                          # create client object
103 96
         self.__client__.on_message = self.__receive__                           # attach function to callback
104 97
         self.__client__.username_pw_set(config.MQTT_USER, config.MQTT_PASS)     # login with credentials
105 98
         try:

Loading…
Cancel
Save