Raspberry Pi Zero W Wireless Projects by Vasilis Tzivaras
Author:Vasilis Tzivaras
Language: eng
Format: epub, azw3, pdf
Publisher: Packt Publishing
Published: 2017-08-24T06:17:31+00:00
At this point, you have learned how to create a notification with slack API calls. It is pretty easy to combine our previous code with the temperature sensor and the new code with the slack API, and send a notification when the temperature is over 25 degrees Celsius.
Advanced client
The client here is actually the application in our mobile device or our desktop computer. For the sake of simplicity and for this project, the client will not send any messages back to the server. The client will only receive notifications if the temperature goes over 25 degrees Celsius. However, the advanced client can be developed by adding two functions. The actual function that sends a message:
def send_message(channel_id, message):
slack_client.api_call(
"chat.postMessage",
channel=channel_id,
text=message,
username='pythonbot',
icon_emoji=':robot_face:'
)
In the previous code, you choose the channel in which you want to send the message and of course the main function:
if __name__ == '__main__':
channels = list_channels()
if channels:
print("Channels: ")
for channel in channels:
print(channel['name'] + " (" + channel['id'] + ")")
detailed_info = channel_info(channel['id'])
if detailed_info:
print('Latest text from ' + channel['name'] + ":")
print(detailed_info['latest']['text'])
if channel['name'] == 'general':
send_message(channel['id'], "Hello " +
channel['name'] + "! It worked!")
print('-----')
else:
print("Unable to authenticate.")
We will not analyze this code, but you can try it out to send messages back to the server; for example, you can simply get a notification and send back an ok message.
Download
Raspberry Pi Zero W Wireless Projects by Vasilis Tzivaras.azw3
Raspberry Pi Zero W Wireless Projects by Vasilis Tzivaras.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3934)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3616)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3551)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3383)
TinyML Cookbook by Gian Marco Iodice(3321)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2842)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2603)
Fusion 360 for Makers by Lydia Sloan Cline(2220)
Networking A Beginner's Guide by Bruce Hallberg(2209)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1996)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1953)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1902)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1861)
MicroPython Projects by Jacob Beningo(1736)
Hands-On Internet of Things with MQTT by Tim Pulver(1707)
