I’m sorry, I should have given more info…
This is a sample payload:
{
"System": {
"Hostname": "myhost",
"TimeStamp": "Sat Jul 15 09:49:01 AM EEST 2023",
"Architecture": "x86_64",
"Uptime": "1 week, 14 hours, 43 minutes",
"Load1": 0.02,
"Load5": 0.07,
"Load15": 0.02,
"LastUpdated": "Jul 1 07:00"
},
"CPU": {
"CPUs": 2,
"CoresPerSocket": 1,
"ThreadsPerCore": 1,
"OSPretty": "Debian GNU/Linux 12 (bookworm)"
},
"Memory": {
"TotalMemory": 2527512,
"FreeMemory": 187820
},
"Storage": {
"TotalDiskSpace": 59233540,
"FreeDiskSpace": 48872024,
"TotalSwap": 2621436,
"FreeSwap": 2362840
},
"Network": {
"IPAddress": "1.2.3.4"
}
}
So far I have 2 ways of getting all the values in HA:
- Creating a sensor that has some value in its state and the whole json as an attribute, like this:
- name: All
state_topic: "viktak/alonisos"
value_template: "{{ '%.1f' | format(( 1 - value_json['Storage']['FreeDiskSpace'] / value_json['Storage']['TotalDiskSpace'] ) * 100|float) }}"
unit_of_measurement: "%"
json_attributes_topic: "viktak/alonisos"
icon: mdi:harddisk
- Creating multiple sensors that each have one of the values as their state, like this:
- name: Disk Usage Percent
state_topic: "viktak/alonisos"
value_template: "{{ '%.1f' | format(( 1 - value_json['Storage']['FreeDiskSpace'] / value_json['Storage']['TotalDiskSpace'] ) * 100|float) }}"
unit_of_measurement: "%"
icon: mdi:harddisk
I feel this is not very efficient (for both creating all those sensors and for HA itself). I just don’t know how to combine them in a single sensor other than the first method.
What I would like is to get a single sensor with several attributes, like many others that various integrations provide. I’m happy to create a new integration, I just don’t want to reinvent the wheel.