With all required data for HA we can now create 3 rest_command integrations which can then be called from HA:
yamlenergie_id_set_heating_usage:url: !secret energie_id_usage_webhookmethod: 'post'content_type: 'application/json'payload: '{"remoteId": "ha-webhook-heating", "remoteName": "Aardgas (Home Assistant)", "metric": "naturalGasImport", "unit": "m³", "readingType": "counter", "data": [["{{ now().isoformat() }}", {{ usage }}]]}'energie_id_set_electricity_usage:url: !secret energie_id_usage_webhookmethod: 'post'content_type: 'application/json'payload: '{"remoteId": "ha-webhook-electricity", "remoteName": "Elektriciteit (Home Assistant)", "metric": "electricityImport", "unit": "kWh", "readingType": "counter", "data": [["{{ now().isoformat() }}", {{ usage }}]]}'energie_id_set_water_usage:url: !secret energie_id_usage_webhookmethod: 'post'content_type: 'application/json'payload: '{"remoteId": "ha-webhook-water", "remoteName": "Water (Home Assistant)", "metric": "drinkingWaterImport", "unit": "m³", "readingType": "counter", "data": [["{{ now().isoformat() }}", {{ usage }}]]}'
After a reload these become availble in your Developer tools:
At this point, you could already start writing scripts and automations to update the meter values in EnergieID, but lets go for something more user friendly.
Home Assistants relatively new helpers offer a great way to perform more difficult interactions in the frontend and help triggering scripts and automations. Create 1 new Input helper per meter in HA and make sure to set the correct values for step, min, max and unit.
Then with those helpers available, from the frontend (or via YAML if you prefer that) you can create a script to update all meters with the current values from the input helpers
All that we have left to do now is add it to a card in our Lovelace view so that we can very easily update our meters individual values and then send it to EnergieID.
Et voila, a somewhat more convoluted approach to integrating EnergieID and Home Assistant, but for now this will do. There is however good news that landed this month:
EnergieID recently gave its webapp a complete visual overhaul and now allows to interact with the REST API by skipping the tedious oauth flow and just use a user-generated access token. This opens the prospect of me trying to get EnergieID in HA core up again!
In the coming months I will try to find some hours in my spare time to work on this integration which I have roughly outlined with the following goals:
Creates new sensor entities per meter and pulls their state from the meters in EnergieID
Create a HA service which allows to update a meter by just passing a valid entity_id and a value to update the meter with
See what I can do with data anlytics (Grafana / HA recorder etc.)
As always, let me know what you think on Twitter!