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 = """
[Unit]
Description=MPD Monitor Service
After=network-online.target
Wants=network-online.target
After=mosquitto.target
[Service]
User=%(UID)d
Group=%(GID)d

View File

@ -13,10 +13,10 @@ MQTT_TOPIC = "hifi/mpd"
#
__BASEPATH__ = os.path.abspath(os.path.dirname(__file__))
APP_NAME = "mpd"
LOGTARGET = 'stdout' # possible choices are: 'logfile' or 'stdout'
LOGTARGET = 'logfile' # possible choices are: 'logfile' or 'stdout'
LOGLVL = 'DEBUG'
LOGHOST = 'cutelog'
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):
client= paho.Client("mpd")
client.username_pw_set(config.MQTT_USER, config.MQTT_PASS)
try:
client.connect(config.MQTT_SERVER, 1883)
topic = config.MQTT_TOPIC + "/state"
logger.info("Sending MPD status information to mqtt %s = %s", topic, str(state))
client.publish(topic, "true" if state else "false")
except (socket.timeout, OSError) as e:
logger.warning("Erro while sending mpd state information")
client.connect(config.MQTT_SERVER, 1883)
topic = config.MQTT_TOPIC + "/state"
logger.info("Sending MPD status information to mqtt %s = %s", topic, str(state))
client.publish(topic, "true" if state else "false")
def send_title_msg_mqtt(title):
client= paho.Client("mpd")
client.username_pw_set(config.MQTT_USER, config.MQTT_PASS)
try:
client.connect(config.MQTT_SERVER, 1883)
topic = config.MQTT_TOPIC + "/title"
logger.info("Sending MPD title information to mqtt %s = \"%s\"", topic, title)
client.publish(topic, title)
except (socket.timeout, OSError) as e:
logger.warning("Erro while sending mpd title information")
client.connect(config.MQTT_SERVER, 1883)
topic = config.MQTT_TOPIC + "/title"
logger.info("Sending MPD title information to mqtt %s = \"%s\"", topic, title)
client.publish(topic, title)
if __name__ == '__main__':