Merge branch 'main' of https://git.jerick.xyz/jerick/homeassistantPi
This commit is contained in:
10
mqtt/tempHumidSensor.service
Normal file
10
mqtt/tempHumidSensor.service
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Script for the Temp & Humidity sensors through MQTT
|
||||||
|
After=multi-user.target
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/python3 /home/pi/homeassistantPi/mqtt/tempSensor.py
|
||||||
|
User=pi
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=30s
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -46,7 +46,8 @@ def getValues(sensor):
|
|||||||
try:
|
try:
|
||||||
temp = sensor.temperature
|
temp = sensor.temperature
|
||||||
humidity = sensor.humidity
|
humidity = sensor.humidity
|
||||||
|
print("Temp:", temp)
|
||||||
|
print("Humidity:", humidity)
|
||||||
#convert to Farenheit
|
#convert to Farenheit
|
||||||
temp = (temp * 1.8) + 32
|
temp = (temp * 1.8) + 32
|
||||||
#Round the decimals
|
#Round the decimals
|
||||||
|
|||||||
Reference in New Issue
Block a user