Skip to content

Instantly share code, notes, and snippets.

@TheSkorm
Created October 21, 2019 01:52
Show Gist options
  • Save TheSkorm/23a59cb95f4ef37c3cb8a4cb8ff221d6 to your computer and use it in GitHub Desktop.
Save TheSkorm/23a59cb95f4ef37c3cb8a4cb8ff221d6 to your computer and use it in GitHub Desktop.
Posts DHT11/DHT22 stuff to home assistant
#!/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