I was reading a lot but can´t find a solution for my use case.
I want to have the kWh from my smart meter (huawei sun2000) item which gets updated every 5 seconds. In first step it´s the item Huawei_Grid = energy I have to buy from my provider.
The item is persisted in my influxdb (version XX?) and with the following script I get the following result:
Okay I created my cumulated Watt Item now by just filling up the values in between the Huawei_Grid updates from persistence with previousState.
This item gets reset at midnight every day.
rule "energy"
when
Time cron "* * * * * ?"
then
Huawei_Grid_cumulated.postUpdate(Huawei_Grid_cumulated.state as Number + Huawei_Grid.previousState.state as Number)
end
I don´t like to spam my openhab with a Time cron job every second so I´m trying to find a better solution and give your suggestion a try. Anyhow the kwH values we´re pretty accurate after a whole day. I checked it against my Fusion Solar app of my inverter.
I´m struggeling with getting a timestamp from my Huawei_Grid item and compare it with the next timestamp update from the same item.
How to do this? I didn´t find any solutions for me that fits…this is the code i´m having so far (I know it´s not much…):
rule "calculate energy"
when
Item Huawei_Grid changed
then
var update = Huawei_Grid.lastUpdate()
end
How to get two lastUpdates status from the same item and how to calculate with TimeDate variables?
There is no kWh-reading from your smart meter available? that would be the goto-version. Converting kW/interval is prone for errors like if you miss a beat or similar you won’t get the exact kWh out of it. If you’ve really only got kW-readings, you can go the linked route.
That’s one issue, if you only have kW delivered. You can either assume there’s a strict 5second interval and just use the delta between two item states and hope for the best.
or you can read out the timestamps like this and still hope for the
or this:
Yes, I only have Watt Meter reading out of my DTSU666 via modbus and no kWH calculated. The kwH value is only available in the Fusion solar app from Huawei.
Modbus gets the updates every ~ 5 seconds. I can decrease interval but I´m not sure if its running safe then.
So I´m looking for a way to calculate it somehow in the best accurate way.