BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
571 stars 57 forks source link

Add push notification to saving session blueprint #758

Closed Peter-HVD closed 4 months ago

Peter-HVD commented 7 months ago

Describe the feature

Please add the ability to send a push notification when a saving session is automatically joined.

Expected behaviour

Send a push notification when a saving session is automatically joined

Use Case

When a saving session is automatically joined, there is no information about that except for in the HA dashboard. It would be great to have a notification sent to my iPhone so that I know to turn everything off at the appropriate time!

Confirmation

vansteedens commented 7 months ago

Hi Peter, this is already possible by adding a device action if you have a phone set up with the HA app. This is the visual editor showing mine:

Screenshot 2024-02-16 at 09 52 24

I then just used the message: Joined new Octopus Energy saving session. It starts at {{ trigger.event.data["event_start"].strftime('%H:%M') }} on {{ trigger.event.data["event_start"].day }}/{{ trigger.event.data["event_start"].month }}

Hope that helps and it will send regardless if you have external monitoring of your HA as it's just an app push.

Peter-HVD commented 7 months ago

Hi. Thanks, yes I know I can do that myself. My point was it would be nice if it was added to the blueprint so it can be added automatically.

Peter-HVD commented 7 months ago

Actually, having said that, I've tried adding an automation and I can't get it to work. Any chance you could share the yaml? Cheers.

vansteedens commented 7 months ago

Here you go, I've edited out my ID's and not actually sure how you find out your mobile device ID as can't find it anywhere, mine was added by the visual editor which I imagine just comes from the Mobile App integration once you've installed the HA app on your device:

alias: Octopus Saving Session Joiner
description: Automatically Join Octopus Saving Session Events
trigger:
  - platform: event
    event_type: octopus_energy_new_octoplus_saving_session
condition: []
action:
  - service: octopus_energy.join_octoplus_saving_session_event
    data:
      event_code: "{{ trigger.event.data[\"event_code\"] }}"
    target:
      entity_id: event.octopus_energy_a_xxxxx_octoplus_saving_session_events
  - service: persistent_notification.create
    data:
      title: Octopus Saving Sessions Updated
      message: >
        Joined new Octopus Energy saving session. It starts at {{
        trigger.event.data["event_start"].strftime('%H:%M') }} on {{
        trigger.event.data["event_start"].day }}/{{
        trigger.event.data["event_start"].month }} 
  - device_id: xxxxxx
    domain: mobile_app
    type: notify
    message: >
      Joined new Octopus Energy saving session. It starts at {{
      trigger.event.data["event_start"].strftime('%H:%M') }} on {{
      trigger.event.data["event_start"].day }}/{{
      trigger.event.data["event_start"].month }}
    title: New saving session has been joined
mode: single
BottlecapDave commented 7 months ago

Hello. The blueprints here are designed to get people up and running quickly and provide an example of how things can be done. I went with the persistent notification because everyone has access to it.

I'm happy for a second blueprint to exists along side it with the desire to send to someone's phone. I'm not sure when I'll get around to it. Similarly happy for someone else to tackle it and open a merge request.

BottlecapDave commented 4 months ago

There is now a separate version of the blueprint which supports added custom actions when a saving session is joined