There are a couple of things you can do to enhance currentcost the first one is just to create a numeric input helper for the unit price. then you can easily change it when the unit price changes. the second is to break out the yaml into its own currentcost.yaml file.
# Configure a default setup of Home Assistant (frontend, api, etc)
homeassistant:
packages: !include_dir_named integrations
What these 2 lines at the start of your configuration.yaml file do, is tell HomeAssistant to look in the integrations folder for yaml files.
so you need to create a directory called integrations and in that directory called integrations create a file called currentcost.yaml copy paste the yaml code given in the currentcost integration docs when you installed it from hacs and save it.
what you have done effectively is create a single integration module for currentcost and you shouldn’t have to touch it again unless there is an upgrade to the currentcost integration.
I highly recommend watching this video It goes into splitting configuration.yaml in detail.
Almost every tutorial on any integration says at some point put this yaml in your configuration.yaml file and it’s very bad advice! very little should go in your configuration.yaml file Instead create a new yaml file for each integration you add into a folder called integrations.
It makes it more modular for home assistant and bugs in one integration don’t affect your other integrations. This speeds up Home Assistant a lot and makes it easier to figure out where you have problems.
If I make an indentation wrong in my currentcost.yaml file my configuration will not validate and it will point to the offending line. If it passes validation and still doesn’t work right i know that that file is the first place to look.
In configuration.yaml errors in adding a new integration can lead to being told an existing line is now wrong and if you try to ‘fix’ that existing line it will just result in more lines of existing code being flagged as being wrong.
Maybe one of the best things is that the yaml that you are given to add to your configuration.yaml file is exactly the same as goes in your separate yaml integration file.
Your configuration.yaml file truly gets in a mess when you add a second or third integration.
You end up with sensors from integration A mixed with integration B and Integration C… This is a bit like using goto in basic as HA switches between A to B to A to C spaghetti code.
Much better to setup A then B then C by having A.yaml B.yaml and C.yaml just don’t use A or B C as filenames use a sensible name like currentcost.yaml and add comments.
I think HomeAssistant will setup little worker tasks. Separated that’s 3 workers for A B and C. Mixed together and you get one worker to do ABC together. That’s a problem because if A has to wait for something tasks B and C also wait.
This results in a slow unresponsive system.
Hopefully this is enough to convince you not to lump everything into configuration.yaml.