Hi!
I have created a custom Slider widget to have a Slider on Cayenne with those settings :
Min Value : 0
Max Value : 100
Step between values : 10
The slider is connected with my Rpi, added with the Bring Your Own Thing feature.
Here’s my Python 3 Code :
#!/usr/bin/env python3
import cayenne.client #Cayenne MQTT Client
from gpiozero import PWMLED
slider=PWMLED(17) #Utilisation du Gpio17
Les infos du Device auquel nous voulons nous connecter
MQTT_USERNAME = “6f48ba60-6dbb-11e9-b4eb-6bf2c2412b24”
MQTT_PASSWORD = “8c0bd26c591b93077bc5c2357e15f1384ac5ca97”
MQTT_CLIENT_ID = “38865770-7000-11e9-be3b-372b0d2759ae”
Callback apres reception d’un message de cayenne
def on_message(message):
print("message received: " + str(message))
if message.channel==2: #canal 2
slider.value=float(message.value)/100#
if float((slider.value)*100) <= 1.0:
slider.value = 0
print("Valeur nulle "+ str(slider.value))
else:
print("La valeur du Slider est: "+ str((slider.value)*100))
client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message #A la reception d’un message, fait : def on_message
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
while True:
client.loop()
I’ve tried what I’ve seen on others topics, put the min value at 0.1 and have a step value equal to 0.1… but I don’t want a slider like that.
If you have any idea to solve my problem I would be gratfull
Thanks in advance.