Created
October 21, 2019 01:52
-
-
Save TheSkorm/23a59cb95f4ef37c3cb8a4cb8ff221d6 to your computer and use it in GitHub Desktop.
Posts DHT11/DHT22 stuff to home assistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
KEY="" | |
HA_URL="" # no trailing slash | |
TEMP_VALUE=`cat /sys/bus/iio/devices/iio\:device0/in_temp_input | sed 's/...$/.&/'` | |
HUMIDITY_VALUE=`cat /sys/bus/iio/devices/iio\:device0/in_humidityrelative_input | sed 's/...$/.&/'` | |
curl -X POST -H "Authorization: Bearer $KEY" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"state\": \"$TEMP_VALUE\", \"attributes\": {\"unit_of_measurement\": \"°C\", \"friendly_name\": \"Satnogs Temp\"}}" \ | |
$HA_URL/api/states/sensor.satnogs_temp | |
curl -X POST -H "Authorization: Bearer $KEY" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"state\": \"$HUMIDITY_VALUE\", \"attributes\": {\"unit_of_measurement\": \"%\", \"friendly_name\": \"Satnogs Humidity\"}}" \ | |
$HA_URL/api/states/sensor.satnogs_humidity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment