HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: funworld on February 13, 2015, 04:56:04 PM

Title: pressDuration
Post by: funworld on February 13, 2015, 04:56:04 PM
I use this Code for a pressDuration.
But after updating i get an Error

When.ModuleParameterChanged( (module, parameter) =>
{
if (module.Is("Entry switch") && parameter.Is("Status.Level"))
{
var endTime = parameter.UpdateTime; // this is the timestamp of button release
var startTime = parameter.LastUpdateTime; // this is the timestamp of button press
var pressDuration = endTime - startTime;

if (pressDuration.TotalSeconds > 2)

ERROR
HomeGenie.Data.ModuleParameter' does not contain a definition for `LastUpdateTime' and no extension method `LastUpdateTime' of type `HomeGenie.Data.ModuleParameter' could be found. Are you missing an assembly reference?

THX for Help
Title: Re: pressDuration
Post by: Gene on February 13, 2015, 05:55:59 PM
In latest hg releases this has changed to:

Code: [Select]
parameter.Statistics.Last.Timestamp

more details about the Statistics field can be obtained from the source code:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Data/ValueStatistics.cs#L108

you can probably use:
Code: [Select]
var stats = parameter.Statistics;
var pressDuration = stats.LastOn.Timestamp - stats.LastOff.Timestamp;


g.
Title: Re: pressDuration
Post by: funworld on February 13, 2015, 08:48:06 PM
I canged to

var endTime = parameter.UpdateTime; // this is the timestamp of button release
var startTime = parameter.Statistics.Last.Timestamp; // this is the timestamp of button press
var pressDuration = endTime - startTime;

Your code make a different effect,

THX for helping