I think you’d need to add the current value(s) and display the series as a nested map (with the input name as keys) instead of a list of maps (with the input name as values).
With data like {"series": [{"name": "mains", ...}, ...]}
I’ll still have to do some template gymnastics in additional “sensors” in Home Assistant that exist purely to reformat the data.
Might as well just keep show=series
as-is and add show=current
or show=ha
that outputs more (all current) data and in a different format?
For example:
{
"voltage_series": {
"voltage": {
"V": 245.6,
"Hz": 50.1
}
},
"power_series": {
"mains": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"oven": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"air_conditioners_1": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"hot_water_system": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"solar_analytics": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"power_points_1": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"lights_1": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"power_points_2": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"lights_2": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"air_conditioners_2": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"fronius_inverter": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"latronics_inverter": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"air_conditioners": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"consumption": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"grid_export": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"grid_import": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"grid_import_neg": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"lights": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"mains_inverted": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"power_points": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"production": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"self_consumption": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
},
"unmeasured": {
"Wh": 567.8,
"W": 123.4,
"A": 5,
"kVA": 6.7,
"PF": "0.988"
}
}
}
Then my Home Assistant integration could be as simple as:
sensor:
- platform: rest
name: IoTaWatt
resource: http://iotawatt.home/query?show=current
json_attributes:
- voltage_series
- power_series
And I could access those values by input/output name in my HA automations, or create additional template sensors for the data I need to expose directly:
sensor:
- platform: template
sensors:
iotawatt_air_conditioners_w:
friendly_name: Air Conditioners
unit_of_measurement: Watts
value_template: '{{ state_attr("sensor.iotawatt", "power_series").air_conditioners.W }}'
It could select from begin=d
to end=s
by default (and allow you to input your own begin/end) and report the last recorded value in the range as W
, and Wh
for the whole period.