« first day (2324 days earlier)      last day (1017 days later) » 

3:33 PM
`import paho.mqtt.client as mqtt
import os
import subprocess

a=""
def on_connect(client, userdata, flags, rc):
client.subscribe("zigbee2mqtt/switch/action")

x = 0

def on_message(client, userdata, msg):
global x, cmd
info = msg.payload.decode()
print (info)

if str(info)== 'on':
x += 1

if x == 1:
p = subprocess.run("/home/pi/skynews.sh")

if x == 2:
p = subprocess.run("/home/pi/bbcnews.sh")

if x == 3:
p = subprocess.run("/home/pi/cnnnews.sh")


broker_address= "192.168.68.688"
port = 1883
user = "test"
I have a second piece of code which stops the first channel from streaming and here it is :
import paho.mqtt.client as mqtt
import os
import subprocess

a=""
def on_connect(client, userdata, flags, rc):
client.subscribe("zigbee2mqtt/switch/action")

x = 0

def on_message(client, userdata, msg):
global x, cmd
info = msg.payload.decode()
print (info)
if str(info)== 'shake':
x += 1

if str(info)== 'fall':
print ("bye")
os.system("killall streamlink")


broker_address= "192.168.68.688"
port = 1883
user = "test"
password = "test"


client = mqtt.Client()
client.connect(broker_address,port,60)
import paho.mqtt.client as mqtt
import os
import subprocess

a=""
def on_connect(client, userdata, flags, rc):
client.subscribe("zigbee2mqtt/switch/action")

x = 0

def on_message(client, userdata, msg):
global x, cmd
info = msg.payload.decode()
print (info)
if str(info)== 'off':
x += 1

if str(info)== 'fall':
print ("bye")
os.system("killall streamlink")


broker_address= "192.168.68.688"
port = 1883
user = "test"
password = "test"


client = mqtt.Client()
client.connect(broker_address,port,60)
 
4 messages moved from Python
 

« first day (2324 days earlier)      last day (1017 days later) »