1
0
Fork 0
Commit Graph

8 Commits (master)

Author SHA1 Message Date
Dustin 990de7fbb9 sensor: Improve reported value precision
Casting the measured values to `int` loses a lot of precision.  Sending
the raw values, however, results in uselessly over-precise values.
Thus, we need to compromise by truncating the values at the tenths
place.
2021-06-18 18:31:34 -05:00
Dustin 2afae103d9 sensor: Set retain on config/availability messages
When Home Assistant restarts, it puts the sensor in "Unavailable" state
until it receives an "online" message.  Since the sensor has no idea
Home Assistant is waiting for such a message, it will never send one.
By setting the "retain" flag on availability and configuration messages,
the broker will automatically resend them to Home Assistant when it
subscribes to the topic again, which resolves this issue.
2021-06-10 08:51:18 -05:00
Dustin 257bac9d86 sensor: Add device metadata
Associating sensor entities with a device improves organization within
the Home Assistant UI.
2021-06-09 09:04:43 -05:00
Dustin e26363a4c8 sensor: Add unique IDs to sensors
Home Assistant seems to lose data from MQTT sensors that do not have a
unique ID when it restarts.
2021-06-09 09:04:43 -05:00
Dustin e30e8aaedc sensor: Add availability messages
Home Assistant can mark MQTT-based sensors as "unavailable" when it
receives a special message (`offline`) on a designated topic.  We send
an `online` message when the sensor process starts, and `offline` when
the process shuts down.  Additionally, we set the last will and
testament message to `offline` as well, so that Home Assistant will
still get the notification, even if the sensor does not shut down
cleanly.
2021-05-01 15:57:03 -05:00
Dustin 205989aefd sensor: Use pipe to interrupt loop
The `time.sleep` function cannot be stopped prematurely.  This means
that when the program receives a signal indicating it should stop, it
will not be able to do so until the running `sleep` completes.  This
means it could take up to 10 seconds for the process to stop.

A better way to handle the shutdown signal is to use a pipe.  When the
signal is received, the write end of the pipe is closed.  The event loop
will detect this immediately, as `select.select` returns as soon as any
event occurs on any of the polled file descriptors, or the timeout
expires.
2021-05-01 15:27:33 -05:00
Dustin 9503e87b4b Add backlight daemon
The backlight on the CM3-PANEL cannot be controled with normal DPMS.  Instead,
the brightness is set using PWM on GPIO pin 22.  The
`thermostat.backlight` program runs as a background process to manage
the PWM duty cycle.  It exposes a D-Bus service to allow other programs
to control the backlight.  It also watches for *xscreensaver* events to
detect when the screen is blanked and disable the backlight.

https://www.acmesystems.it/CM3-PANEL-7-BASIC_backlight
2021-04-30 08:24:14 -05:00
Dustin a64c749f18 Initial commit 2021-04-29 09:36:49 -05:00