Commit Graph

8 Commits (master)

Author SHA1 Message Date
Dustin c933b4cdcd mqtt discovery: Set icon for soil moisture sensor 2022-05-18 20:30:32 -05:00
Dustin 1ea3de712e values: Report battery level in percentage
The LiPo battery apparently ranges from 3.0 V to 3.95 V.  Since we know
the range, we can report the current level as a percentage, which Home
Assistant will display.

We'll leave the original voltage reading in the MQTT state payload for
diagnostic purposes.
2022-05-16 21:41:38 -05:00
Dustin d0e546571e values: Include firmware build date
Home Assistant will display a "Firmware Version" field in the device
information panel if the `sw_version` field is populated in the
discovery configuration payload.  We'll fill this with the build date
and time of the firmware as a proxy.
2022-05-16 21:32:00 -05:00
Dustin c9cacc540f main: Deep sleep after network failures
Instead of entering a "hot" reboot loop when there is a problem
connecting to WiFi or the MQTT broker, the chip will now go into deep
sleep for a minute before trying again.  This should conserve battery in
situations where simply trying again right away won't fix the problem
(e.g. WiFi is actually down, or the band conditions are just really bad
for now).
2022-05-16 21:17:20 -05:00
Dustin 38df5d00c4 values: Include boot count in state messages
This should be useful for diagnostic purposes.  It's not brought out
into a proper sensor in HA, but it can be seen using the MQTT message
viewer in the HA device configuration tool.
2022-05-16 21:17:20 -05:00
Dustin 6c1757b43d main: Deep sleep for up to an hour
It really isn't necessary to have minute-level granularity of soil
moisture (especially since it's just been sitting at "max" for 2
weeks!).  Updating frequently is helpful for diagnostics, though.  To
compromise, the sensor will now publish data every minute for the first
few minutes after it starts up, then reduce its update frequency to once
every hour.
2022-05-16 21:17:20 -05:00
Dustin e628508ff5 mqtt_discovery: Add state_class, entity_category
Populating these options helps Home Assistant display the sensors better
in the UI.

The `publish_client` function has too many parameters as it is, making
it difficult to keep track of which value is passed as which argument.
Using a structure and designated initializers makes this a lot cleaner.
2022-05-16 21:17:20 -05:00
Dustin 87c4833a10 Initial commit 2022-05-08 20:34:58 -05:00