Compare commits

..

No commits in common. "ee201df901afccb70e86b377e7e8d2a5cf44fe95" and "ed4efd48c167d517b8e1052224379e76953be893" have entirely different histories.

3 changed files with 11 additions and 19 deletions

View File

@ -6,8 +6,7 @@ import sys
SERVICE_FILE = """ SERVICE_FILE = """
[Unit] [Unit]
Description=MPD Monitor Service Description=MPD Monitor Service
After=network-online.target After=mosquitto.target
Wants=network-online.target
[Service] [Service]
User=%(UID)d User=%(UID)d
Group=%(GID)d Group=%(GID)d

View File

@ -13,10 +13,10 @@ MQTT_TOPIC = "hifi/mpd"
# #
__BASEPATH__ = os.path.abspath(os.path.dirname(__file__)) __BASEPATH__ = os.path.abspath(os.path.dirname(__file__))
APP_NAME = "mpd" APP_NAME = "mpd"
LOGTARGET = 'stdout' # possible choices are: 'logfile' or 'stdout' LOGTARGET = 'logfile' # possible choices are: 'logfile' or 'stdout'
LOGLVL = 'DEBUG' LOGLVL = 'DEBUG'
LOGHOST = 'cutelog' LOGHOST = 'cutelog'
LOGPORT = 19996 LOGPORT = 19996
formatter = report.SHORT_FMT formatter = report.LONG_FMT

View File

@ -52,25 +52,18 @@ class mpc(object):
def send_state_msg_mqtt(state): def send_state_msg_mqtt(state):
client= paho.Client("mpd") client= paho.Client("mpd")
client.username_pw_set(config.MQTT_USER, config.MQTT_PASS) client.username_pw_set(config.MQTT_USER, config.MQTT_PASS)
try: client.connect(config.MQTT_SERVER, 1883)
client.connect(config.MQTT_SERVER, 1883) topic = config.MQTT_TOPIC + "/state"
topic = config.MQTT_TOPIC + "/state" logger.info("Sending MPD status information to mqtt %s = %s", topic, str(state))
logger.info("Sending MPD status information to mqtt %s = %s", topic, str(state)) client.publish(topic, "true" if state else "false")
client.publish(topic, "true" if state else "false")
except (socket.timeout, OSError) as e:
logger.warning("Erro while sending mpd state information")
def send_title_msg_mqtt(title): def send_title_msg_mqtt(title):
client= paho.Client("mpd") client= paho.Client("mpd")
client.username_pw_set(config.MQTT_USER, config.MQTT_PASS) client.username_pw_set(config.MQTT_USER, config.MQTT_PASS)
try: client.connect(config.MQTT_SERVER, 1883)
client.connect(config.MQTT_SERVER, 1883) topic = config.MQTT_TOPIC + "/title"
topic = config.MQTT_TOPIC + "/title" logger.info("Sending MPD title information to mqtt %s = \"%s\"", topic, title)
logger.info("Sending MPD title information to mqtt %s = \"%s\"", topic, title) client.publish(topic, title)
client.publish(topic, title)
except (socket.timeout, OSError) as e:
logger.warning("Erro while sending mpd title information")
if __name__ == '__main__': if __name__ == '__main__':