--- /dev/null
+[Unit]
+Description=mqtt-stat-pgsql
+
+[Service]
+User=dpavlin
+ExecStart=/klin/rtl433-sensors/mqtt-stat-pgsql.sh
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+#!/bin/sh -e
+
+mosquitto_sub -h 10.13.37.5 -t 'stat/#' -v | while read topic value ; do
+ topic=`echo $topic | sed 's/^stat\///'`
+ psql --quiet -c "insert into stat (topic,value) values ('$topic','$value')" rot13
+done
--- /dev/null
+drop table stat;
+create table stat (
+ _id serial,
+ time timestamp without time zone default now(),
+ topic text not null,
+ value text
+);
+