Octopus Energy - Intelligent Tariff

I’ve a question related to the use of this with another integration. I have just installed the Polestar Integration so have my state of charge in HA for the first time.
I’m using the Zappi integration so I just tell Octopus how much charge to add.
What I would like to do is set a target state of charge and have HA work out the difference, round to the nearest 5% and set the charge to add at that.
I assume I create a helper for the desired state of charge then when the car is plugged in, or the target state of charge is changed trigger an automation to calculate the difference, round to 5% then set this as the charge to add
something like
set {octopus charge to add = [target state of charge] - [polestar state of charge] rounded up to nearest 5%
e.g. target =80% current = 66% difference = 14% so set charge to add = 15%
I can do that automation but don’t know how to do the calculation of the difference then round it. is the difference a different helper? or can this be done calculated within the automation?
thanks for any help you can offer

Hi,

Im using the powerwall “Teslar customl integration and I alsi have a manual input number called “input_number.overnight_powerwall_max_charge“ and set it from the weather forecast Integration Solcast depending on the next days solar forecast. Or you could set it manually on your dashboard. Then for the trigger i use

alias: "POWERWALL: Keep PW SOC within 10% of Max Charge Required from grid"
description: ""
trigger:
  - platform: template
    value_template: |-
      {{ states('sensor.powerwall_charge_corrected') | float(0) <
        states('input_number.overnight_powerwall_max_charge') | float(0) -9 }}
  - platform: template
    value_template: |-
      {{ states('sensor.powerwall_charge_corrected') | float(0) >=
        states('input_number.overnight_powerwall_max_charge') | float(0) }}
  - platform: time
    at: "23:32:00"
  - platform: time_pattern
    minutes: /30
  - platform: state
    entity_id:
      - binary_sensor.ix_xdrive40_charging_status
condition:
  - condition: time
    after: "23:30:00"
    before: "05:25:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun

Then for my action I use a choice depending on the action triggered:

choose:
  - conditions:
      - condition: template
        value_template: |-
          {{ states('sensor.powerwall_charge_corrected') | float(0) <
            states('input_number.overnight_powerwall_max_charge') | float(0) -10 }}
    sequence:
      - service: select.select_option
        data:
          option: "Yes"
        target:
          entity_id: select.home_energy_gateway_grid_charging
      - service: select.select_option
        data:
          option: Time-Based Control
        target:
          entity_id: select.home_energy_gateway_operation_mode
      - service: number.set_value
        data:
          value: >-
            {{states('input_number.overnight_powerwall_max_charge') | float(0)
            }}
        target:
          entity_id: number.home_energy_gateway_backup_reserve
        enabled: false
      - service: number.set_value
        target:
          entity_id:
            - number.home_energy_gateway_backup_reserve
          device_id: []
          area_id: []
        data:
          value: >-
            {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
            states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
            }}
  - conditions:
      - condition: template
        value_template: |-
          {{ states('sensor.powerwall_charge_corrected') | float(0) >=
            states('input_number.overnight_powerwall_max_charge') | float(0) }}
      - condition: not
        conditions:
          - condition: state
            entity_id: binary_sensor.zappi_charging_status
            state: "on"
          - condition: state
            entity_id: input_boolean.eddi_boosting
            state: "on"
          - condition: state
            entity_id: binary_sensor.zappi_charging_status
            state: unavailable
    sequence:
      - service: select.select_option
        data:
          option: "No"
        target:
          entity_id: select.home_energy_gateway_grid_charging
        enabled: false
      - service: select.select_option
        data:
          option: Self-Powered
        target:
          entity_id: select.home_energy_gateway_operation_mode
        enabled: false
      - service: number.set_value
        data:
          value: >-
            {{states('input_number.overnight_powerwall_max_charge') | float(0)
            }}
        target:
          entity_id: number.home_energy_gateway_backup_reserve
        enabled: false
      - service: number.set_value
        target:
          entity_id:
            - number.home_energy_gateway_backup_reserve
          device_id: []
          area_id: []
        data:
          value: >-
            {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
            states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
            }}
  - conditions:
      - condition: template
        value_template: |-
          {{ states('sensor.powerwall_charge_corrected') | float(0) >=
            states('input_number.overnight_powerwall_max_charge') | float(0) }}
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.zappi_charging_status
            state: "off"
          - condition: state
            entity_id: sensor.myenergi_eddi_14771640_status
            state: Boosting
    sequence:
      - service: select.select_option
        data:
          option: "No"
        target:
          entity_id: select.home_energy_gateway_grid_charging
      - service: select.select_option
        data:
          option: Self-Powered
        target:
          entity_id: select.home_energy_gateway_operation_mode
      - service: number.set_value
        data:
          value: >-
            {{states('input_number.overnight_powerwall_max_charge') | float(0)
            }}
        target:
          entity_id: number.home_energy_gateway_backup_reserve
        enabled: false
      - service: number.set_value
        target:
          entity_id:
            - number.home_energy_gateway_backup_reserve
          device_id: []
          area_id: []
        data:
          value: >-
            {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
            states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
            }}
      - wait_for_trigger:
          - platform: state
            entity_id:
              - sensor.myenergi_eddi_14771640_status
            from: Boosting
        enabled: true
      - service: number.set_value
        target:
          entity_id:
            - number.home_energy_gateway_backup_reserve
          device_id: []
          area_id: []
        data:
          value: >-
            {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
            states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
            }}
  - conditions:
      - condition: template
        value_template: |-
          {{ states('sensor.powerwall_charge_corrected') | float(0) >=
            states('input_number.overnight_powerwall_max_charge') | float(0) }}
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.zappi_charging_status
            state: "on"
          - condition: state
            entity_id: input_boolean.eddi_boosting
            state: "off"
            enabled: true
    sequence:
      - service: select.select_option
        data:
          option: "No"
        target:
          entity_id: select.home_energy_gateway_grid_charging
      - service: select.select_option
        data:
          option: Self-Powered
        target:
          entity_id: select.home_energy_gateway_operation_mode
      - service: number.set_value
        data:
          value: "100"
        target:
          entity_id: number.home_energy_gateway_backup_reserve
        enabled: false
      - service: number.set_value
        target:
          entity_id:
            - number.home_energy_gateway_backup_reserve
          device_id: []
          area_id: []
        data:
          value: >-
            {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
            states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
            }}
default:
  - service: number.set_value
    target:
      entity_id:
        - number.home_energy_gateway_backup_reserve
      device_id: []
      area_id: []
    data:
      value: >-
        {{ [ states('input_number.pw_max_charge_override')|int(default=0) ,
        states('input_number.overnight_powerwall_max_charge')|int(default=0)]|max
        }}
  - condition: time
    after: "23:30:00"
    before: "05:30:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun

omg wow a world, I cannot fathom this lot out!!!
So I have HA with Octopus IOG, a Sunsynk 5.5 inverter.
Simple…
Well I have order some parts to make up something which will hopefully allow me to send commands back to my Sunsynk inverter timers.
What I am trying to do is get all the kit to talk to each other.
Ideally want octopus schedules to be pushed to my inverter so I don’t use my battery to charge my EV car.

Octopus Energy A-B1C6D2F2 Intelligent Dispatching can see this going on and off.
When I plug the car in I get a schedule from Octopus, I then have to alter my inverter times to suit. When I unplug the car I need to set the inverter to switch to battery mode, this is completed by altering the inverter timer.
Confused…
Been build and rebuilding HA numerous times, back ups take longer to restore than I can now rebuild and integrate a few apps.
Other than that the whole thing even in small parts is very confusing

While you figure out how to add your battery integration to home assistant to be able to get full control, why not make like easy for now.

Manually set your batteries to charge from 23:30 to 05:30 then you can have full batteries each morning.

Next you need to search for the integration for your battery system and how to set it up in HA.

Good luck

I’ve started to use the integration to turn certain devices on/off but I’m struggling a bit with the notification that the dispatch slots have ended.

What seems to happen is that I’m getting multiple events to say the slot has ended rather than just one

Looking at the entity I get frequent “became unavailable”

Eg this morning the slot turned ON at 10:32. I then unplugged my car at 10:37 and I got a notification at 11:21 that the slot had ended (the slot was 10:30-11:00)

Also last night I kept getting messages though the night that the slot had ended

Do I need to change my automation criteria to help filter these out?


I just use “Octopus Energy [account no] Intelligent Dispatching” as the flag for when intelligent octopus starts and stops. It seems to work within about 20 seconds of the scheduled times. I set the automation to trigger from any state, to On or Off, so that you catch a transition, in the unlikely event that it goes from Off, to Unavailable, to On.

Hi, I’m struggling to set up my automations because I seem to be missing the crucial slot sensor. I’ve checked hidden and disabled entities but it’s not there either. I noticed that some others were having a similar issue last year and it was fixed with an update to the integration, but I’m on the latest version. Is anyone else having the same problem, or do the rest of you see the slot sensor in your setups?

Cheers… Sam

Yes this is the current workaround. The issue with this integration is the sensors just go unavailable all the time, so you’ll miss dispatch slot ending triggers half the time.

I’ve just switched to IOG, so still finding my way here. So far have a nice simple automation that use the myskoda integration to set a trigger when the car comes home, then works out the charge level needed to get the batteries back up to 80% and sends that number to the Octopus app so that when I plug in my Zappi charger it’s all ready to go. I went for the Zappi integration with IOG rather than the car one as the Skoda threw a big fit when I tried the latter.

Interesting to read about extra charge periods outwith the normal times. I’ve just switched from Agile, so realise that you can get these cheaper slots when you don’t expect them sometimes. I’ve heard conflicting reports about whether you get everything at off peak in these slots if the car fails to charge then. Unfortunately, no quick way to check as you have to wait for your bill to see what you were charged then.

I’m going to charge my home batteries in these slots anyway for now as, even if I’m put on peak rate, at this time of the year my batteries are always empty by about 18:00, so by charging, say, an extra hour in the morning at peak I’m just shifting the peak usage - no extra overall cost for the day. I’ll keep a record of all the charge schedules and see what I get charged in my bill (I’ll also need to check if the car charged during that period as well). Will report back.

I guess that if it is the case that you’re charged at peak if your car fails to accept charge during a scheduled extra charge slot, then the safest way to benefit from these extra slots with home battery charging is to only go for the evening ones when you know for sure that the car will still need the charge. It’s odd though because Octopus seem to allow much more time than they need to get the requested charge in. Have checked that my battery capacity and charge rate are correct. Maybe they have more slots than they need to give them flexibility?

@megakid thank you, great integration

Did you get anywhere with this installation error? I seem to be experiencing the same issue myself with the repository apparently “not a valid add-on repository” :frowning:

Or maybe anyone else can tell me in which way I’m being stupid (as I’m sure it must be me!!)

image

Are you following instructions to add custom repositories (not the usual add repository dialogue?)

1 Like

@robbo100 could you expand on that please? I set up two automations yesterday. One to start my batteries charging when the Intelligent dispatching entity switched to on and one to stop them when it switched to off. There were no slots last night or this evening, so the “on” automation did not run, but for some reason the sensor became unavailable 3 times during the night (see image) so the off automation saw this as a change of state to off and turned off my normal night charging which was in progress (so my batteries are empty now :frowning_face:).

Looks like you’ve got a way to get round this issue. Could you share your automation code please?

alias: Extra cheap slot - charge batteries STOP
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.octopus_intelligent_planned_dispatch_slot
    to: "off"
condition: []
action:
  - service: switch.turn_off
    target:
      entity_id:
        - switch.lux_ac_charge_enable
    data: {}
mode: single

Just change your trigger to a state change from off to on or from on to off then if the integration goes to a state of Unknown or Unavailable it will not trigger your automation.

FYI i have disabled all of my Intelligent automations as the integration is not reliable at this time…hopefully the author can improve this:

alias: "POWERWALL: Turn ON PW charging when intelligent slot starts"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.octopus_intelligent_slot
    from: "off"
    to: "on"
condition:
  - condition: not
    conditions:
      - condition: time
        after: "23:30:00"
        before: "05:30:00"
action:
  - choose:
      - conditions:
          - condition: state
            state: "on"
            entity_id: binary_sensor.octopus_intelligent_slot
        sequence:
          - service: select.select_option
            data:
              option: "Yes"
            target:
              entity_id: select.home_energy_gateway_grid_charging
          - service: select.select_option
            data:
              option: Backup
            target:
              entity_id: select.home_energy_gateway_operation_mode
          - service: number.set_value
            data:
              value: "100"
            target:
              entity_id: number.home_energy_gateway_backup_reserve
mode: single

Thank you. Also occurred to me that I could just have one automation for start and stop with a wait condition in the middle, so that charging will never be stopped unless it has been started by the same automation.

What issues are you having with the sensors? Just a lot of unavailable like me or other things also?

Yes the Integration goes off line throuogh the day and seems to require a system restart to refresh it and get back online.

For your single Automation approach just use a choice for the actions. and have two triggers for each “On to Off” and “Off to On” then the choice will select what action to take for each switch trigger change

I see that now with the sensors. Shame, because it would be great if it worked.

Think I’ve been a bit thick about this actually…the native HA Octopus energy integration has a sensor that gets the current rate and, looking at the history since I’ve been on OIG, it has been available and accurate all the time. I’ll use that instead :grinning:

1 Like

Sorry, I am a bit late in replying.

I create a helper called “input_select.octopus_energy_slot_i_o_smoother”, and then have two automations which deal with the scenario where there is a potentially unknown state. The “smoothed” helper, never shows anything other than On or Off.

alias: I/O Charging Slots - Smoothed to Off
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.octopus_energy_X_XXXXXXX_intelligent_dispatching
    to: "off"
condition: []
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.octopus_energy_slot_i_o_smoother
    data:
      option: I/O Peak (Smoothed)
mode: single

and

alias: I/O Charging Slots - Smoothing to On
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.octopus_energy_X_XXXXXXX_intelligent_dispatching
    to: "on"
condition: []
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.octopus_energy_slot_i_o_smoother
    data:
      option: I/O Off-Peak (Smoothed)
mode: single

I’m on IOG, whats funny is if you select an “unreasonable” amount of charge and a very short time i.e ready by 5am it starts charging straight away… I am getting the status of the Zappi charger using the integration and am using that along with Solar assistant on a raspberry pi to trigger the charging of the house batteries. I wonder whether the energy firm have an insight into me doing this as they must be able to pull stats off myenergi I would have thought.