<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Send display status to MQTT]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">Not sure if this is the right category to post this, so forgive me if I’m wrong.  Basically, what I am trying to do is create a Python script to regularly check the outcome of “vcgencmd display_power” and send this status via MQTT.<br />
This might allow me to sync the switch status on Home Assistent and Node Red.  Using copy-paste, I have a start of a script, but it keeps giving error on the stdout variable. Could one of you please check?</p>
<pre><code>#!/bin/bash
#!/usr/bin/env python3

import paho.mqtt.client as mqtt
import subprocess
# This is the Subscriber

def on_connect(client, userdata, flags, rc):
  print("Connected with result code "+str(rc))
  client.subscribe("thuis/woonkamer/scherm")

output = subprocess.check_output(['vcgencmd display_power'], stdout=subprocess.PIPE)
if stdout() == 'display_power 0':
  client.publish(topic, msg)

client = mqtt.Client()
client.connect("192.168.2.150",1883,60)

#client.on_connect = on_connect
#client.on_message = on_message

client.loop_forever()

</code></pre>
]]></description><link>https://forum.magicmirror.builders/topic/14718/send-display-status-to-mqtt</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 17:53:59 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/14718.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 Feb 2021 15:57:53 GMT</pubDate><ttl>60</ttl></channel></rss>