#!/bin/bash
# homebridge-rpi/opt/pigpio/cgi/getState
# Copyright © 2019-2025 Erik Baauw.  All rights reserved.
#
# Homebridge plugin for Raspberry Pi.

umask 022
exec 2> /dev/null
exec > /tmp/getState.json

cat - <<+
{\
"date":"$(date -uIseconds)",\
"boot": "$(uptime -s)",\
"fan": "$(cat /sys/devices/platform/cooling_fan/hwmon/hwmon?/pwm1)",\
"freq":"$(vcgencmd measure_clock arm)",\
"load":"$(uptime)",\
"powerLed": "$(cat /sys/class/leds/PWR/brightness)",\
"swap": "$(swapon --show=size,used --noheadings --bytes)",\
"temp":"$(vcgencmd measure_temp)",\
"throttled":"$(vcgencmd get_throttled)",\
"volt":"$(vcgencmd measure_volts)"\
}
+

