Last active
December 20, 2021 04:56
-
-
Save hara/7236ef30dedad54f25de98788bac9eeb to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -euo pipefail | |
echo "getting temperature and humidity from ${METER_MAC_ADDRESS}" | |
data="$(/usr/local/bin/switchbot-meter -a "${METER_MAC_ADDRESS}")" | |
echo "${data}" | |
body="$(echo "${data}" | jq -c '{(.addr): del(.addr)}')" | |
ts=$(echo "${data}" | jq -r '.ts') | |
echo "${body}" | curl -X POST \ | |
-H "x-soracom-timestamp: ${ts}" \ | |
-H "Content-Type: application/json" \ | |
-d @- \ | |
http://unified.soracom.io |
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
[Unit] | |
Description=Temperature and Humidity Monitor | |
[Service] | |
Type=oneshot | |
Environment="METER_MAC_ADDRESS=YOUR_METER_MAC_ADDRESS" | |
ExecStart=/usr/local/bin/temperature-humidity-monitor | |
[Install] | |
WantedBy=multi-user.target |
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
[Unit] | |
Description=Run Temperature and Humidity Monitor | |
[Timer] | |
OnBootSec=1m | |
OnUnitActiveSec=15m | |
Unit=temperature-humidity-monitor | |
[Install] | |
WantedBy = timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment