User Tools

Site Tools


dh22

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dh22 [2021/12/19 20:58] admindh22 [2021/12/19 21:07] (current) admin
Line 1: Line 1:
-====== DH22 ======+====== DH22 - HomeAssistant ====== 
 + 
 +Get values (temperature and humidity) from DH22, round the values and send it to HomeAssistant
  
 <code python> <code python>
 #!/usr/bin/python3 #!/usr/bin/python3
  
-import os, sys 
 import Adafruit_DHT import Adafruit_DHT
 import time import time
 import requests import requests
-import html 
  
 def sendData(name, sensor, value, unit): def sendData(name, sensor, value, unit):
Line 31: Line 31:
     now = time.strftime('%d-%m-%Y %H:%M:%S', time.localtime(epoch))     now = time.strftime('%d-%m-%Y %H:%M:%S', time.localtime(epoch))
  
-    sendData('Pi Humidity', 'radiopi_humidity', humidity, '%'+    sendData('KitchenPi Humidity', 'kitchenpi_humidity', round(humidity, 3), '%'
-    sendData('Pi Temperature', 'radiopi_temperature', temperature, 'C')+    sendData('KitchenPi Temperature', 'kitchenpi_temperature', round(temperature, 3), 'C')
  
     print('"{0:s}","{1:0.1f}","{2:0.1f}"'.format(now, temperature, humidity))     print('"{0:s}","{1:0.1f}","{2:0.1f}"'.format(now, temperature, humidity))
dh22.1639943916.txt.gz · Last modified: 2021/12/19 20:58 by admin