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

This commit is contained in:
Dirk Alders 2022-09-12 13:15:21 +01:00
parent d2752495fb
commit e8334669e8

View File

@ -1,6 +1,6 @@
import config import config
import logging import logging
import paho.mqtt.client as mqtt import paho.mqtt.client as paho
import report import report
import socket import socket
import subprocess import subprocess
@ -19,14 +19,7 @@ class sispmctl(object):
def __init__(self, mqtt_client): def __init__(self, mqtt_client):
logger.info("Starting sispmctl module...") logger.info("Starting sispmctl module...")
self.__mqtt_client__ = mqtt_client self.__mqtt_client__ = mqtt_client
self.__state__ = [False, False, False, False]
self.__state_requests__ = [{}, {}, {}, {}] self.__state_requests__ = [{}, {}, {}, {}]
try:
out_txt = subprocess.check_output(["sudo", "sispmctl", "-f", "all"]).decode('UTF-8')
except subprocess.CalledProcessError as grepexc:
logger.error("sispm error code %d", grepexc.returncode)
else:
logger.info('sispmctl all channels switched off')
self.publish_states() self.publish_states()
def __filter_output_parameter__(self, output): def __filter_output_parameter__(self, output):
@ -99,7 +92,7 @@ class mqtt_powerplug(object):
] ]
def __init__(self): def __init__(self):
self.__client__ = mqtt.Client("mqtt_powerplug") # create client object self.__client__ = paho.Client(config.APP_NAME) # create client object
self.__client__.on_message = self.__receive__ # attach function to callback self.__client__.on_message = self.__receive__ # attach function to callback
self.__client__.username_pw_set(config.MQTT_USER, config.MQTT_PASS) # login with credentials self.__client__.username_pw_set(config.MQTT_USER, config.MQTT_PASS) # login with credentials
try: try: