At home I use esphome hydrometers as part of my fermentation process and would like to be able to use a specified, ‘Hydrometer’ device class with the units of either Specific Gravity, Brix, or Plato.
i.e., in the way I use:
to denote the fact that an analog input to a voltage divider should result in a battery level, I would like to use device_class: hydrometer to inform HA that the accelerometer I use should result in specific gravity.
The hardware concept so clever I bought one immediately, but am currently still drinking my previous batch of brewing so haven’t tried the calibration nor MQTT + different firmware options yet.
Would you mind sharing the rest of your work in progress config please?
As you’ve already done for the battery, it’s a case of picking the MQTT topic, icon, unit_of_measurement, and device_class. Percentage + generic might well be the best option for the SG without a pull-request.
Poking around in the GitHub source, there is a definition for Units.SPECIFIC_GRAVITY which suggests there is a way SG can be used as a (custom?) HASS unit, although note properties device_class and state_class are missing (and not in const.py definitions either) which is a bit confusing:
Although digging through Python dependency trees in Git isn’t my strong point, the lack of code in const.py suggests this is a custom unit, and a feature request for both HASS core DeviceClass.SPECIFIC_GRAVITY and ESPhome is needed to add SG properly. The 2022.10 release _might_make this clearer when all the code is in the release branch.
Personally, whilst ESPhome firmware would be great, a MQTT definition with units would be enough to get my next brew batch monitored.
And it’s just “SG” so I’m not sure how that works within homeassistant - I might try and fiddle with my iSpindel MQTT config messages as it’s currently sending SG as degrees Plato which is confusing
Oh, and there is a closed pull request in the iSpindel firmware repository for the tilt value to get a unit of measurement (degrees) so it shows as a graph not a state, which is annoying in homeassistant but easily fixed by fiddling with MQTT config messages. Maybe something similar could be added for SG but it’s tricky when there isn’t really a unit for it, it’s just a ratio as I understand it (very new to brewing)