Read the statement by Michael Teeuw here.
Send display status to MQTT
-
Hi all,
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.
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?#!/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()
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login