HI All
I need to get a script to add or subract a rolling value to another value.
I am trying to get my power consumption worked out on a 30 min timescale, and then added to another value to work out the usage.
I am doing this in mind of doing a comparison with Octopus Agile. Thanks to Jon00 i now have the current rate in Pence in a device.
I have a KWH counter that will give me the amount of KWH used in 30 mins (i will reset after that)
I wish to take this devices value (1036) and add it to my daily cumlative KWH consumed (1409)
Looking though my past questions - Mokus provided an answer for a similar requirement over 10 years ago (probably for HS2 or even 1) :-
"'Adds current KWH reading for last 30 mins onto cumlative KWH for the day
Sub Main(Byval Parms As Object)
Dim diff As Double = hs.devicevalue(1409) + hs.devicevalue(1036)
hs.setdevicevalue(1409, diff)
End Sub"
This does not seem to work - there are no errors in the log, but device 1409 does not increase from 0.
My next script (when i have the above working) would calculate the cost of the KWH used so far at a flat rate (0.15) by taking device 1409 and mutilply by 0.15 and place this value in a further device 1410 - which would give my my cost so far to plot using Device History.
My next script (when i have the above working) would calculate the cost of the KWH used so far at the agile rate and i would take the current value of the 30 minute KWH consumption (1036), multiply this by my Agile rate (Device 1407) and place this result into further device 1408 - which would give my my cost so far to plot using Device History.
I then could see the cost using different tarrifs, using the live Octopus rates.
Does anyone know if the script above should work, or if there is a better way to go around adding or subtracting values from different devices a setting other devices?
Many thanks for any help provided!
Cheers
Mike
I need to get a script to add or subract a rolling value to another value.
I am trying to get my power consumption worked out on a 30 min timescale, and then added to another value to work out the usage.
I am doing this in mind of doing a comparison with Octopus Agile. Thanks to Jon00 i now have the current rate in Pence in a device.
I have a KWH counter that will give me the amount of KWH used in 30 mins (i will reset after that)
I wish to take this devices value (1036) and add it to my daily cumlative KWH consumed (1409)
Looking though my past questions - Mokus provided an answer for a similar requirement over 10 years ago (probably for HS2 or even 1) :-
"'Adds current KWH reading for last 30 mins onto cumlative KWH for the day
Sub Main(Byval Parms As Object)
Dim diff As Double = hs.devicevalue(1409) + hs.devicevalue(1036)
hs.setdevicevalue(1409, diff)
End Sub"
This does not seem to work - there are no errors in the log, but device 1409 does not increase from 0.
My next script (when i have the above working) would calculate the cost of the KWH used so far at a flat rate (0.15) by taking device 1409 and mutilply by 0.15 and place this value in a further device 1410 - which would give my my cost so far to plot using Device History.
My next script (when i have the above working) would calculate the cost of the KWH used so far at the agile rate and i would take the current value of the 30 minute KWH consumption (1036), multiply this by my Agile rate (Device 1407) and place this result into further device 1408 - which would give my my cost so far to plot using Device History.
I then could see the cost using different tarrifs, using the live Octopus rates.
Does anyone know if the script above should work, or if there is a better way to go around adding or subtracting values from different devices a setting other devices?
Many thanks for any help provided!
Cheers
Mike
Comment