aaronwmorris / indi-allsky

Software to manage a Linux-based All Sky Camera.
GNU General Public License v3.0
188 stars 31 forks source link

Enhancement: Set Home Assistant unit of measurement and device class in discovery script for user sensors to allow HA to display a line graph instead of state graph #1350

Open Vertikar opened 1 week ago

Vertikar commented 1 week ago

I did some reading after this post: https://github.com/aaronwmorris/indi-allsky/discussions/1335#discussioncomment-9824803

And it seems that you need at least a unit of measurement and possibly a device class for the line graph to be displayed in Home Assistant instead of the state graph that's used for sensors with text values. I haven't tested this yet, but will try to today.

These are the valid types of device class:

https://www.home-assistant.io/integrations/sensor/#device-class

I can see that for example the Camera temp sensor in the discovery script https://github.com/aaronwmorris/indi-allsky/blob/0a883ad3efec6d6be0fb29d26fd72b24358a40f3/misc/home_assistant_auto_discovery.py#L138 has a unit of measurement of degrees, and that maps into a line graph fine.

My thoughts were that even though the sensors internally are referenced as user_sensor_1-30, indi-allsky is aware of what type of sensor is in which slot, so that could potentially map into the discovery script with the right unit of measurement, but I'm not across the codebase enough, or python quite well enough to be able to do that myself.