Add a Hydrometer Device Class

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:

  - platform: adc
    pin: A0
    id: brew_hydrometer_1_battery_level
    name: "Brew Hydrometer 1 Battery Level"
    unit_of_measurement: '%'
    device_class: battery

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.

Hi,
Is that via an iSpindel device?

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?

I have experience of custom MQTT sensor and device class config after writing custom firmware for plant watering complete with HASS auto-configuration which works well. The main trick is not trying to be too clever with JSON transformations if you can choose what to MQTT publish.

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.

There is a Python header file with all the #define options, but it’s the same as device class docs.

James

Hi,
The path may be a little clearer to create an iSpindel automation with full long-term stats graphing of SG.

Release 2022.10 BETA includes a binding for a similar Bluetooth device to the open hardware WLAN/MQTT iSpindel device.

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.

James

@FloatingBoater I think it comes from the bottom of here:

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 :grin:

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)