Created
June 22, 2021 02:32
-
-
Save Ajak58a/9111244336b13c1f49a95f2aad93b793 to your computer and use it in GitHub Desktop.
fn_callbacks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from devices import * | |
def Device_1(client, userdata, msg): | |
#print "device1:"+str(msg.payload) | |
global devices_names_live | |
global devices_names_debug | |
global devices_names_sensor | |
message = str(msg.payload) | |
#print message | |
if("on" in message.lower()): | |
devices_names_live[0] = "ONLINE" | |
if("off" in message.lower()): | |
devices_names_live[0] = "OFFLINE" | |
if("debug:" in message): | |
command = message.replace("debug:","") | |
devices_names_debug[0] = command | |
if("sensor:" in message): | |
command = message.replace("sensor:","") | |
devices_names_sensor[0] = command | |
def Device_2(client, userdata, msg): | |
global devices_names_live | |
global devices_names_debug | |
global devices_names_sensor | |
#print "device2:"+str(msg.payload) | |
message = str(msg.payload) | |
#print message | |
if("on" in message.lower()): | |
devices_names_live[1] = "ONLINE" | |
if("off" in message.lower()): | |
devices_names_live[1] = "OFFLINE" | |
if("debug:" in message): | |
command = message.replace("debug:","") | |
devices_names_debug[1] = command | |
if("sensor:" in message): | |
command = message.replace("sensor:","") | |
devices_names_sensor[1] = command | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment