In general, if you get an exception - you need to add exception handler around the code and inspect the exception.
DeviceValue returns double, so you can't format it using "hh:mm". I think you should convert it to TimeSpan first, i.e. TimeSpan.FromSeconds(Double)
Announcement
Collapse
No announcement yet.
Trying to copy a timer value to a (memory) device
Collapse
X
-
Trying to copy a timer value to a (memory) device
Hi,
I've got a timer (2383) that increments when the boiler is running to show me a running total of the time it's been on today. I'd like to copy this total value at midnight before it resets to a new device (2398) so I can compare today with yesterday but I'm struggling with the simplest of scripts......
Sub Main(ByVal Params As Object)
Dim dteLast = hs.DeviceValue(2383)
hs.SetDeviceString(2398, dteLast.ToString("hh:mm"), True)
End Sub
This gives me an error "Running script: Exception has been thrown by the target of an invocation."
and if I use this script:
Sub Main(ByVal Params As Object)
Dim dteLast = hs.DeviceValue(2383)
hs.SetDeviceString(2398, dteLast, True)
End Sub
I just get the numeric, non-formatted value of the time into the 2398 device, this currently being "16720"
What am I doing wrong please ??Tags: None
Leave a comment: