CurrentCost Component for Home Assistant

Good spot, I’ll update the git page. It should indeed have an s at the end

The code in configuiration.yaml should be under the sensor header

[EDIT]
Now fixed

I too have just got the CurrentCost custom integration working but had to ad a few lines that were not included in the configuration.yaml example. I’ve been using my equipment to upload Gas, Elec, solar and several individual items to the PVOutput website for about 8 years.
I’m loving the whole Home Assistant think and just keep adding more and more to it (it really is limitless)
Thanks loluk44 for creating the custom component its a great piece of work, if only I’d come across it a few days earlier I might not have bothered buying the RTLSDR USB stick I was going to use to try and extract the Current Cost data via the 433 frequency but I’d probably still have a play around with that at some point.
I have a question about the yaml setup, what is the [:-2] for? I thought it might be some sort of data correction as in reduce temp by 2 degrees or reduce power value by 2w but I changed the figure and it appeared to have no effect.
On the subject of data correction do you know how that could be integrated.
I’ve noticed that the temperature from the EnviR has always been a few degrees too high so how could I instruct the integration to subtract 2 degrees from the indicted value.
Thanks again for your good work, its very much appreciated

this removes the unit (ºC or W) to return only a number instead of a string

value_template: '{{ state_attr("sensor.current_cost", "Temperature")[:-3] | float -2 }}'

1 Like

Ah! Thank you

Well, golly gosh, it just worked :grinning: Impressed. Next I need to cogitate on exactly why sensor: did the deed.

For the record, and anyone reading this who is also running an R Pi and HA Supervised, the R Pi needs the serial port enabling and the serial console disabling, all done with sudo raspi-config.

Grafana/influxDB next, if my brain can take it. @lolouk44 , any pointers within your github work (at first trawl, I didn’t see any) ? Thanks again for your time taken.

This is sensor, it needs to be in the sensor: section
If you had no previous sensors, you would have had to add this section, if not just add below existing sensors.

If you follow the InfluxDB doc, you should understand how it’s setup.
I personally don’t want to track everything, as I’m only interested in tracking some values over a longer time.
Then follow this guide by the excellent @arsaboo

lolouk44, is it possible to use one of the entity id value templates to then create another sensor such as daily total, weekly total, rolling total etc.
Also in the days when Current Cost hosted a web service to upload the data collected using there equipment is was possible to display a meter reading for Gas & Elec (and water if you had one I think)
is it possible to extract some data then calibrate a figure to correspond with your meter reading.

Hi @xion2000,

I only have the Elec data so can’t test.
If you’re able to give me an extract of the data I can look into it.
Are you able to open an issue on my github please?
I’ll create a script to extract the data into a file…

The first question was relating to the Elec data.

I have 2 OptiSmart sensors (Elec & Solar) & 1 GaSmart sensor which thanks to your integration I can now pull data directly into HA via a 2nd EnviR unit (my original one is still connected to a pc and uploads to PVOutput).

How do I extract the data to send to you?

I’ve upload 2 questions to GitHub after creating an account. Cheers

Apologies, I mean to raise an issue on github for the additional data.
For your totals, you can use the statistics
Though I think there may be such data inside the currentcost already, I’ll investigate

Sorry, I’m not grasping what you want me to post on GitHub.
Spell it out to me & I’ll happily post it (I’m a bit of a numpty at times!!)

@xion2000 Looking at the CurrentCost page for your GaSmart sensor, and age of the device design, is it designed for the non-smart meters ? Possibly it looks at the meter red winking light, or reed relay ?

I guess what we all want is an API to our energy supplier. Not that would give a gas kW, for which we would probably need a gas flow meter, downstream of the energy supplier meter, all installed by a Gas Safe contractor. :grin:

lol yes. The currentcost is actually a clamp that goes around the wire on one of the phases. I had this and wanted the data in HA (so I can convert an appliance into a smart one by knowing when it’s on since it’s using power)
I don’t know how/if we can capture the data from the smart meters yet.

Yes my Gas meter is dumb, the GaSmart sensor is activated by a magnet (I think) on the meter reading.

My Elec meter is a Smart Meter. The OptiSmart reads the pulse light, I do not use the current clamp type as I don’t think they are as accurate.

You are correct re accuracy. Your electricity meter will be carefully designed, manufactured, type tested, certified, routinely replaced. Every man and his dog can make a current clamp, install it any old how and generally abuse it.

But the humble current clamp provides more frequent data (Current Cost every 6 seconds) against the pulse value of 1 kWh which probably takes many minutes or hours depending on electrical load. So, this makes for prettier graphs, and is good enough for many purposes.

I see it all as a stop gap, until we generally have access to energy supplier APIs. Googles… at least one in the UK, so progress is being made.

I’ve uploaded a copy of my log to GitHub.

Thanks for the pointer to statistics which I’ve given a test, and yes it works as expected. Not exactly pretty, nor bespoke enough for my liking but then I’ve not got a grip on Grafana at the moment.

1 Like

Update !
I’ve updated the custom_component to support impulse meters

Thanks @xion2000 for your help with the troubleshooting

Thanks for this, effortless to get it up and running compared to how hard it was last time I tried.
However, I have 3 current clamps attached to the transmitter which is meant for 3 phase commercial supplies. Instead I use them for monitoring different circuits in the home.
It is ages since I had this running but when I used to access the current cost tranmitter from 433Mhz RTL-SDR it was just a text line with the three values plus a total that got sent out. Any idea how I can get access to these values from within your component please? I had a look in the state topics in Developer Tools but didn’t look hopeful.
Anyway great work.

I had a quick look in your sensor.py and found the bit where you add the 3 channels:

            try:
                wattsch1 = int(data['msg']['ch1']['watts'])
            except:
                wattsch1 = 0
                pass
            try:
                wattsch2 = int(data['msg']['ch2']['watts'])
            except:
                wattsch2 = 0
                pass
            try:
                wattsch3 = int(data['msg']['ch3']['watts'])
            except:
                wattsch3 = 0
                pass
            total_watts = wattsch1 + wattsch2 + wattsch3
            if appliance == 0:
                if total_watts != 0:
                    self._state = total_watts

The problem is I have no idea how to offer any changes to Python script. I don’t even know if I have to compile it? I would be really grateful if you could point me in the right direction. Happy to do the donkey work and test it all and update accordingly. Thanks.