Upload gas readings to mindergas.nl

Seems the value of your meter reading is empty, so the sensor is not correctly added in the template or not correctly returning values

When the automation starts the upload it indeed seems to be so but like I already said when I start the automation manualy via the “three dots” menu is runs without an issue and the value is uploaded to mindergas.

update:

I changed the automation to:

  • alias: Update Mindergas
    trigger:
    • platform: time
      at: 23:55:00
      action:
    • service: rest_command.mindergas_post
      data_template:
      date: ‘{{ timestamp_custom(’‘%Y-%m-%d’‘) }}’
      meterreading: ‘{{ states(’‘sensor.gas_usage’‘) }}’

So without the time offset.
And now it seems to work. Fingers crossed for tonight.

It looks like something strange happens with the Youless gas_usage sensor in the Youless integration. Around midnight the sensor has no value.
I now use a shell script that fetches the gas usage information directly from my Youless and sends it to minder gas.

Thanks @Mey for this information!

Only for some reason my readings aren’t uploaded.

My Automation.yaml

alias: Upload MinderGas
description: Upload meterstand naar MinderGas.nl
trigger:
  - platform: time
    at: "00:00:23"
condition: []
action:
  - service: rest_command.mindergas_post
    data_template:
      data: "{{ (now().timestamp() - 60*60) | timestamp_custom('%Y-%m-%d') }}"
      meterreading: "{{ states('sensor.gas_meter_gas_consumption') }}"
mode: single

When i manualy run the automation i receive 2 errors;

Logger: homeassistant.components.rest_command
Source: components/rest_command/init.py:155
Integration: RESTful Command (documentation, issues)
First occurred: 20:50:09 (1 occurrences)
Last logged: 20:50:09
Error. Url: https://www.mindergas.nl/api/meter_readings. Status code 422. Payload: b’{ “date”: “”, “reading”: 6609.474 }’

Logger: homeassistant.helpers.template
Source: helpers/template.py:2260
First occurred: 20:50:09 (1 occurrences)
Last logged: 20:50:09
Template variable warning: ‘date’ is undefined when rendering ‘{ “date”: “{{ date }}”, “reading”: {{ meterreading }} }’

Does anyone have an idea what this could be?

You defined ‘date’ as an argument in the REST command, but you defined ‘data’ in your automation. So the Rest command complains that the required ‘date’ argument is not defined while rendering. Which is indeed the fact.