Project

General

Profile

Feature #570

Add "LastChanged" for individual Values (not just Device) to Conditional check (Events.module) -> Code provided - 1 line :)

Added by thechad over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
04/25/2015
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Hi Guys,
I have a condition variable that I would like to add to the "Events.module"

I have a sensor on the garage door that send the state and the state and the battery level to Domotiga. The battery level (value3) updates every minute.The state is only updates when it changes.

I want to check if the sensor state has changed in the last 10 minutes.
ie.

(Now()>Dateadd(Dev_69_Value1_LastChanged, gb.second, 599))

But this is not allowed and the problem is that the current condition check (ie. "Dev_69_LastChanged")only looks at the device update time (which is updated by the battery value changing) ...ie. you can not access the individual "Value" update time.

(I think) It is just one line of code that need to be added to "Events.module" in "AddDevicesToContext"

    cContext["Dev_" & rResult!device_id & "_Value" & rResult!device_value_valuenum & "_LastChanged"] = rResult!device_value_lastchanged

ie.

Private Sub AddDevicesToContext(cContext As Collection)

  Dim rResult As Result

  rResult = Devices.GetDevicesAndValues(["sortOrder": "name"])
  If Not rResult Then Return

  For Each rResult
    cContext["Dev_" & rResult!device_id & "_Value" & rResult!device_value_valuenum & "_LastChanged"] = rResult!device_value_lastchanged
    cContext["Dev_" & rResult!device_id & "_Value" & rResult!device_value_valuenum] = rResult!device_value_value
    cContext["Dev_" & rResult!device_id & "_LastChanged"] = rResult!device_lastchanged
    cContext["Dev_" & rResult!device_id & "_LastSeen"] = rResult!device_lastseen
    cContext["Dev_" & rResult!device_id & "_BatteryStatus"] = rResult!device_batterystatus
  Next

End

History

#1 Updated by rdnzl over 3 years ago

  • Status changed from New to Feedback

I have added it to beta branch, can you test if all works well?
Thanks!
Added new variable to event formula described in feature request #570 (example Dev_1_Value1_LastChanged)

#2 Updated by wwolkers about 3 years ago

  • Status changed from Feedback to Closed

Fixed in 1.0.022

Also available in: Atom PDF