Skip to content

Commit

Permalink
Add daily fee metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
megakid committed Jun 16, 2022
1 parent b1f0136 commit 3204a3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
3 changes: 0 additions & 3 deletions custom_components/hildebrand_glow_ihd_mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ async def async_setup(hass: HomeAssistant, config: dict):

return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_LOGGER.debug("Setting up Hildebrand Glow IHD MQTT integration")

Expand All @@ -32,8 +31,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):

hass.data[DOMAIN][entry.entry_id][CONF_DEVICE_ID] = entry.data[CONF_DEVICE_ID].strip().upper().replace(":", "").replace(" ", "")



for component in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component))
Expand Down
33 changes: 18 additions & 15 deletions custom_components/hildebrand_glow_ihd_mqtt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.TOTAL_INCREASING,
#"value_template": "{{ value_json['electricitymeter']['energy']['export']['cumulative'] }}",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['energy']['export']['cumulative'],
},
Expand All @@ -88,7 +87,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.TOTAL_INCREASING,
#"value_template": "{% if value_json['electricitymeter']['energy']['import']['cumulative'] == 0 %}\n {{ states('sensor.smart_meter_electricity_import') }}\n{% else %}\n {{ value_json['electricitymeter']['energy']['import']['cumulative'] }}\n{% endif %}\n",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['energy']['import']['cumulative'],
"ignore_zero_values": True,
Expand All @@ -98,7 +96,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['electricitymeter']['energy']['import']['day'] }}",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['energy']['import']['day'],
},
Expand All @@ -107,7 +104,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['electricitymeter']['energy']['import']['week'] }}",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['energy']['import']['week'],
},
Expand All @@ -116,7 +112,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
# "value_template": "{{ value_json['electricitymeter']['energy']['import']['month'] }}",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['energy']['import']['month'],
},
Expand All @@ -125,7 +120,6 @@
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP/kWh",
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['electricitymeter']['energy']['import']['price']['unitrate'] }}",
"icon": "mdi:cash",
"func": lambda js : js['electricitymeter']['energy']['import']['price']['unitrate'],
},
Expand All @@ -134,7 +128,6 @@
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['electricitymeter']['energy']['import']['price']['standingcharge'] }}",
"icon": "mdi:cash",
"func": lambda js : js['electricitymeter']['energy']['import']['price']['standingcharge'],
},
Expand All @@ -143,9 +136,17 @@
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": POWER_KILO_WATT,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['electricitymeter']['power']['value'] }}",
"icon": "mdi:flash",
"func": lambda js : js['electricitymeter']['power']['value'],
},
{
"name": "Smart Meter Electricity: Cost (Today)",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
"icon": "mdi:cash",
"func": lambda js : round(js['electricitymeter']['energy']['import']['price']['standingcharge'] + \
(js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2),
}
]

Expand All @@ -155,7 +156,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.TOTAL_INCREASING,
#"value_template": "{% if value_json['gasmeter']['energy']['import']['cumulative'] == 0 %}\n {{ states('sensor.smart_meter_gas_import') }}\n{% else %}\n {{ value_json['gasmeter']['energy']['import']['cumulative'] }}\n{% endif %}\n",
"icon": "mdi:fire",
"func": lambda js : js['gasmeter']['energy']['import']['cumulative'],
"ignore_zero_values": True,
Expand All @@ -165,7 +165,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['energy']['import']['day'] }}",
"icon": "mdi:fire",
"func": lambda js : js['gasmeter']['energy']['import']['day']
},
Expand All @@ -174,7 +173,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['energy']['import']['week'] }}",
"icon": "mdi:fire",
"func": lambda js : js['gasmeter']['energy']['import']['week']
},
Expand All @@ -183,7 +181,6 @@
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['energy']['import']['month'] }}",
"icon": "mdi:fire",
"func": lambda js : js['gasmeter']['energy']['import']['month']
},
Expand All @@ -192,7 +189,6 @@
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP/kWh",
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['energy']['import']['price']['unitrate'] }}",
"icon": "mdi:cash",
"func": lambda js : js['gasmeter']['energy']['import']['price']['unitrate']
},
Expand All @@ -201,7 +197,6 @@
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['energy']['import']['price']['standingcharge'] }}",
"icon": "mdi:cash",
"func": lambda js : js['gasmeter']['energy']['import']['price']['standingcharge']
},
Expand All @@ -210,9 +205,17 @@
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": POWER_KILO_WATT,
"state_class": SensorStateClass.MEASUREMENT,
#"value_template": "{{ value_json['gasmeter']['power']['value'] }}",
"icon": "mdi:fire",
"func": lambda js : js['gasmeter']['power']['value']
},
{
"name": "Smart Meter Gas: Cost (Today)",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
"icon": "mdi:cash",
"func": lambda js : round(js['gasmeter']['energy']['import']['price']['standingcharge'] + \
(js['gasmeter']['energy']['import']['day'] * js['gasmeter']['energy']['import']['price']['unitrate']), 2),
}
]

Expand Down

0 comments on commit 3204a3a

Please sign in to comment.