This is my code :
import cayenne.client #Cayenne MQTT Client from gpiozero import LED
led=LED(17) #Declaring button pin 17
#Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME = “8a58db60-”
MQTT_PASSWORD = “8aaf623135c1f2e6fe6de2d3b1a88”
MQTT_CLIENT_ID = “d5bfb780-ca3-552aaa” # The callback for when a message is received from Cayenne.
def on_message(message):
print("message received: " + str(message))
if message.channel==1: #Dashboard Led widget channel. They must be same.
if message.value==“1”: #If led command “1”, turn led on(message.value must be string)
led.on()
elif message.value==“0”: #If led command “0”, turn led off(message.value must be string)
led.off()
client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message #When message recieved from Cayenne run on_message function
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
while True:
client.loop()
root@osmc:/home/osmc# sudo python guzik.py
Traceback (most recent call last):
File “guzik.py”, line 2, in
led=LED(17) #Declaring button pin 17
NameError: name ‘LED’ is not defined
Where is problem thx