JSON example using Sonoff Basic Smart Switch & ESPEasy.

ThomasB, Apr-10-2019

Connect to ESPEasy on local IP (change as needed to match the device) and load the jason into a array called "espez"

import json, requests
url = requests.get('http://192.168.1.81/json')
espez = json.loads(url.text)

Show an example of printing the current value of the built-in push button switch.

Device configuration as follows: Task= 1, Device= Switch input-Switch, Name= PBSW

print("Device Name: ", espez'Sensors'['TaskName'])

wendu = int(espez'Sensors''TaskValues'['Value'])

print("Temp is : ", wendu)

if wendu >=27: #判断并且显示温度高低

print('Hot Temp is:',wendu,'°C')

else:

print('Cool Temp is:',wendu,'°C')


参考链接:
https://www.letscontrolit.com/forum/viewtopic.php?f=6&t=6612&p=36311

标签: none

添加新评论