blueprint:
  name: Octopus Energy - Power Up Session Baseline Reached
  description: Automatically get an alert if current interval consumption has reached the current power up baseline
  domain: automation
  author: BottlecapDave
  input:
    interval_consumption_entity:
      name: Interval consumption entity
      description: The entity which reports the consumption for the current interval (e.g sensor.octopus_energy_electricity_{{METER_SERIAL_NUMBER}}_{{MPAN_NUMBER}}_current_interval_accumulative_consumption)
      selector:
        entity:
          filter:
          - domain:
            - sensor
            integration: octopus_energy
    baseline_entity:
      name: Baseline entity
      description: The entity which reports the current target baseline (e.g sensor.octopus_energy_electricity_{{METER_SERIAL_NUMBER}}_{{MPAN_NUMBER}}_octoplus_power_up_baseline)
      selector:
        entity:
          filter:
          - domain:
            - sensor
            integration: octopus_energy
    actions:
      name: Actions
      description: Notifications or similar to be run. {{message}} is an example message
      selector:
        action: {}
trigger_variables:
  interval_consumption_entity: !input interval_consumption_entity
  baseline_entity: !input baseline_entity
variables:
  message: 'You have reached your current baseline ({{ states(baseline_entity) | round(2) }} kWh). Power up is now available for the current 30 minute period.'
mode: queued
max: 4
trigger:
- platform: template
  value_template: >
    {% set interval = states(interval_consumption_entity) | float(0) %}
    {% set baseline = states(baseline_entity) | float(0) %}
    {% if interval and baseline %}
      {{ interval >= baseline }}
    {% else %}
      {{ False }}
    {% endif %}
condition: []
action:
- choose: []
  default: !input actions
