Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

The set_led_level(data) method

set_led_level(data) at line (6) is where we integrate with GPIOZero to change the brightness of our LED and the method similar to the corresponding methods we covered in Chapter 3, Networking with RESTful APIs and Web Sockets Using Flask, so we will not cover the internals here again:

def set_led_level(data):  # (6)
...

The data parameter is expected to be a Python dictionary in the form of { "level": 50 }, where the integer is between 0 and 100 to indicate the brightness percentage.

Next, we have the callback functions for MQTT. We'll start by reviewing on_connect() and on_disconnect().

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461