Shared whole config on GitHub (Floorplan / Octopus Agile optimisation with solar forecasting for Powerwall & EVs)

I’ve decided to share my configuration in the hope that it might help someone.
I’ve received loads of help from the forums whilst building everything so far so thought I would share.

You can find it on GitHub

Home Assistant Configuration

The config file is split into a large number of packages to allow it to be browsed and reused more easily. I’m working on documenting each section so you can see what it is doing.

Main features are:

3 Likes

I’ve transferred all my lovelace from UI into YAML, so I could get that into my github too.

1 Like

@BruceH5200,

Thanx and great sharing! You really must have put countless hours in to your set up. I’m interested in the Octopus Energy and Power Wall controls, I have a very basic understanding and managed to set up a simple HA dashboard to show my Solar generation, house load, energy difference (when excess solar present) and then from the back of that some automation’s to turn on and off some “luxury” electrical loads like UFH in the bathrooms. I just laid some new 16mm2 power cables from my house to the garage and I’m getting ready to have a PW2 installed, then I would like to have some control over the PW and its charging behaviour. I have read countless information on the PW and how tightly it is locked down. So does your system require any “hacking” of the PW that might affect its long term warranty? Do you have any documentation on how to set up from scratch the Octopus/PW automation’s that you have kindly shared on your Github? Or would I just need to copy all the tesla_powerwall .yaml files in to my packages/systems/tesla_powerwall folder? :slight_smile: unlikely to be that easy, I know :slight_smile:

Thanx once again for your share and also for any help setting up for the beginner.

Chris.

Thanks for looking at my code.
You are right, I have spent (and do spend) a lot of time tweaking and improving the code.
No hacking of the powerwall is required.

Copy this folder into your custom components.
Tesla Gateway

If you don’t use 2FA for your Tesla account then there is a slightly easier version to use, which I’ll find for you.
I use 2FA / MFA so at the moment I have to obtain a login token manually and put it into my secrets file.

This custom component allows the mode of the powerwall to be changed and the reserve %.

Then look in:
Tesla Powerwall Code
and
Octopus Agile Code

For various scripts and automations.

Hi again @BruceH5200

So I copied across those two folders and then went through each file in turn to make personal changes to details and sensors etc. A few questions, I note references to telegram chat and ‘solcast’. Please could you confirm that I need to make use of telegram app from telegram.org and then create myself an alias then use that as my “telegram_chat_id” in my !secrets file? What about the “solcast” data where do you pull that from? I could not find any plug-ins for HA in the app store or HACS for “Solcast” so I’m a bit unsure where to link that to for the charging forecasting component of the Tesla PW.
In the Octopus section you refer to “octopus_auth” is this my Octopus API key starting with “sk_live”? I did not see any references to the Octopus account number, is that required anywhere? I also changed the region from your L to my K.

Now that I made all the changes I went to the Configuration/server controls to verify my new yaml configurations before attempting any HA restart… I have worked my way though a few configuration invalid warnings up to this one, which Im unsure how to clear. would you have any advise about the mentioned “octopus_agile” setup and integrations?

Package octopus_agile setup failed. Component octopusagile Integration ‘octopusagile’ not found.
Platform error sensor.octopusagile - Integration ‘octopusagile’ not found.

Thanx once again for any pointers and assistance.
Chris

For Octopus Agile, you need to install this:
Octopus Agile Custom Component

For Solcast, look at:
Solcast Custom Component
and…
Solcast
For Telegram, look at:
Telegram Bot Component

Secrets for Octopus are…

mpan: 2200999999999
serial: 20J9999999
auth: sk_live_ABCDEaBzDv9aBc3AbCDEFgh
1 Like

Hi again @BruceH5200,

I think that I have made some progress today :slight_smile: but I’m currently unable to parse the validation check on my .yaml files as it is getting stuck at the Telegram settings, please could you help me with the syntax required for the below error:

Invalid config for [telegram_bot]: expected int @ data[‘telegram_bot’][0][‘allowed_chat_ids’][0]. Got ‘t’. (See ?, line ?).
Invalid config for [notify.telegram]: expected int for dictionary value @ data[‘chat_id’]. Got ‘t.me/cwinstock789’. (See ?, line ?).

These are my !secret file entries (Changed the numbers and token numbers for protection):
telegram_chat_id_chris: t.me/cwinstock789
telegram_bot_chat_ids: t.me/cwinstock789_bot
telegram_api_key: 1701552601:BCHvzs8W21g-__DGYyjZ8OJFnqIC6jC7OvU

That isn’t what the chatids look like.
see telegram webhooks
and particularly…
To get your chat_id and api_key follow the instructions here.

1 Like

Thanx @BruceH5200

finally got things working…not bad for 14 hours of work eh!! But what an eye opener matey, I just copied your Tesla Powerwall, Telegram, Solcast and Octopus_agile folders and made some personal changes. I dont have the PW installed yet but hope to in the coming 2 months when I’m at the top of the waiting list. With the Telegram_bot running it gives a whole new dimension to Home Assistant and more importantly to the other half for easier interactions and feedback.

I have pushed my luck with the family today :slight_smile: but it was great to spend the time on HA and learning from yourself, thank you!

Great. Glad I could help. I do like the telegram stuff. I’m trying to expand its capabilities. But it is just having the time.

1 Like

Hi again @BruceH5200

I have not been able to retrieve Solcast data since setting up things. ‘/status’ always shows “Todays Solar Forecast: unknown kWh”. In HA if I look at the entities I see one defined as “sensor.solcast_forecast_2” which gives an output but “sensor.solcast_forecast_tomorrow” just returns UNAVAILABLE.
Please may I ask if you have the Solcast working presently for tomorrows forecasting, or like me you only have todays forecast?

I also note that you have defined them like this, pleae could you explain to me about that:

value_template: “{{ state_attr(‘sensor.solcast_forecast’, ‘tomorrow’) }}”

thanx Chris

It looks like you’ve set it up twice.
Temporarily remove the integration and restart home assistant.
Go into entities, and delete any solcast entities that are left behind.

Then put the integration back in place.

You should have then sensor.solcast_forecast

This sensor has attributes for tomorrow forecast and day after tomorrow.
my template is splitting that attribute out into a seperate sensor.

1 Like

hi Bruce, I dont see Solcast as an integration in the Configuration/Integrations of HA…should it be there? I’m sorry to be such a NOOB

In Entities I do see everything twice as you suspected.

When I say remove the integration, I mean just comment out the solcast lines in your config.yaml
so it is temporarily removed from home assistant.

1 Like

Hi Bruce,
I cleaned out the spurious ‘Solcast_2’ sensors and now back to the original format and on my lovelace UI I can get the Solcast Forecast number (I assume that’s for today). However nothing displayed for ‘sensor.solcast_forecast_tomorrow’ or sensor.solcast_forecast_the_day_after_tomorrow.

Also if I call /solar or /status then the bot always reports “Todays forecast: unknown kWh”. THen when I replace your code “input_number.solcast_latest_today_forecast” with “sensor.solcast_forecast” then it will return “Todays solar forecast: 10.71 kWh”

Given your comment above, might it be possible that I have not copied over the .yaml or script that you used for your template to split that attribute in to separate sensors?

Have you created the helpers that are referenced? You’ll need to create the input_number helpers that the code looks at.

The today forecast from solcast is the forecast for the remainder of today.
I add this to the today production, so it always shows the forecast for the whole of today.

There will be template sensors in my folder for tomorrow forecast.

1 Like

I have not “created” any new files only copied across from your work and file structure…were the helpers part of your folders/files?

Could you give me some heads-up on the below, which I think is a “helper”? :slight_smile:

automation:
  - id: solcast_update_today_forecast
    alias: "Solcast Update Today Forecast"
    trigger:
      platform: state
      entity_id:
        - sensor.solcast_forecast        
    action:
      - service: input_number.set_value
        data:
          entity_id: input_number.solcast_latest_today_forecast
          value: "{{ (states('sensor.hauxtonenvoy_today_s_energy_production') | float + states('sensor.solcast_forecast') | float ) | round(1) }}"

I think this is what you referred to where by you take the Solcast daily forecast which reduces throughout the day, then you add your current solar production value to that. Does it then give you a total valuse of Solcast forecast + actual solar home production? and to get that value would I bee calling on the id: “solcast_update_today_forecast” ?

Also below the ‘entity_id’ it has “- sensor.solcast_forecast” would I have to also add my daily solar production entity_id “- sensor.hauxtonenvoy_today_s_energy_production” which is part of the helper calculation?

I’m getting closer and now have the below displayed in Lovelace but still only getting the current Solcast forecast figure where I think it should be the result of the above “helper”.yaml that I posted above…

Below is the screen shot of my Solcast folder on the right side and your original folder structure on the left. so that you may see the files that I have in my HA:

The helpers aren’t defined in code.
They are created through the UI.

There is a list in my GitHub.
(Not necessarily up to date)

documents/helpers.md

1 Like