Button in a e-mail

Hi,

I have solar panels. Every time they have produced 1000KwH, I get money for this from the government. I always have to pass this on via a specific website my.fluvius.be.

I have created an automation for this, which notify me by email.

The e-mail contains the total electricity produced, which I then
enter manually in my.fluvius.be.

Once this is done, I have to enter this same number in a helper in Home Assistant (input_number.number_doorgegeven_groene_meterstand).

I would also like to automate the latter, but I donā€™t know howā€¦ Ideal would be a button in the e-mail, which would update the helper with the correct value when clickedā€¦ but is this possible?

So hereā€™s the automation I already have:

alias: Groenestroomcertificaat aanvragen
description: ''
trigger:
  - platform: time
    at: '06:00'
condition:
  - condition: template
    value_template: >-
      {% set i = states('input_number.number_doorgegeven_groene_meterstand') |
      int %} {% set i = (i / 1000) | int %} {% set i = (i * 1000) | int %} {{
      (states('sensor.energy_produced_total_zonnepanelen_kwh') | int - i | int)
      > 1000 }}
action:
  - service: notify.gmail
    data:
      title: Groenestroomcertificaat aanvragen
      message: >-
        Meterstand : {{ states('sensor.energy_produced_total_zonnepanelen_kwh')
        | int }} (https://mijn.fluvius.be)
mode: single

alias: Groenestroomcertificaat aanvragen
description: ''
trigger:
  - platform: time
    at: '06:00'
condition:
  - condition: template
    value_template: >-
      {% set i = states('input_number.number_doorgegeven_groene_meterstand') |
      int %} {% set i = (i / 1000) | int %} {% set i = (i * 1000) | int %} {{
      (states('sensor.energy_produced_total_zonnepanelen_kwh') | int - i | int)
      > 1000 }}
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.number_doorgegeven_groene_meterstand
    data:
      value: "{{ states('sensor.energy_produced_total_zonnepanelen_kwh') }}"
  - service: notify.gmail
    data:
      title: Groenestroomcertificaat aanvragen
      message: >-
        Meterstand : {{ states('sensor.energy_produced_total_zonnepanelen_kwh')
        | int }} (https://mijn.fluvius.be)
mode: single

Something along the lines of this? Why push a button, when you can do that via automation.

And if you need or want a button, just write a seperate automation, where you set the value on the click of a button in your dashboard. Or did I misunderstood what you want to achieve?

EDIT: added the missing quotation marks around the value template

1 Like

I donā€™t think e-mails could behave like the actionable notifications directly in HA:

  1. idea: Why not use these actionable notifications rather than those 1997ish e-mails
  2. idea: Why the extra step? If you always do the same you could just have the update for the helper as a second action, maybe with a delay.

I - for myself - would probably chose idea 1 so I could just do it in one motion whenever Iā€™m ready.

Thanks for the ideas !

ā€œActionable notificationsā€ are great and I use regularly, but in this case too dangerous that I accidentally delete the notification without having previously entered the data at fluvius (the e-mail stays nicely in the inbox).
Iā€™m currently going for Patrickā€™s solution and update the helper at the same time as sending the email. I first wanted to do it with an intermediate step, because it once happened that the fluvius site didnā€™t workā€¦but now that I think about it, the mail stays in my mailbox so it should work like this.

Can you set the number on that page (fluvius) automatically? I mean, is there an api or something to do this?

You could insert something in your automation to set that value, wait a bit and check if the value is set. After that you put the number in your input_number and send out a ā€œOK, all doneā€ mail. :slight_smile:

Just a thought. :smiley:

The site is seriously secured, so Iā€™m afraid this wonā€™t workā€¦

Thatā€™s a shame, life could be so much easierā€¦ :smiley:

Sorry, Iā€™m backā€¦

The code is not acceptedā€¦when I save it I get this :

  • service: input_number.set_value
    target:
    entity_id: input_number.number_doorgegeven_groene_meterstand
    data:
    value:
    ā€˜[object Object]ā€™: null

Seems the value must be a fix number ?

Welcome back! Sorry, my bad, I missed the quotation marks around the template lineā€¦ :astonished: :crazy_face:

This line
value: {{ states('sensor.energy_produced_total_zonnepanelen_kwh') }}
has to be escaped by quotation marks
value: "{{ states('sensor.energy_produced_total_zonnepanelen_kwh') }}"

Would you mind trying? :slight_smile:

So stupidā€¦thanks !