We have moved at community.getvera.com

Author Topic: Property variable needed in LUA action code  (Read 114 times)

Offline Chelseagroup

  • Jr. Member
  • **
  • Posts: 63
  • Karma: +2/-0
Property variable needed in LUA action code
« on: January 03, 2019, 01:32:47 pm »
Property variable needed in LUA action code
I need to access plg properties in Action LUA code - what is the syntax?
Other PLG variables available to action LUA code?
Does anyone have a specific example of the following?
For each input Variable name or Condition name xxx you have access to it from LUA as

Where XXX is the uppercase of the input or condion name. And XXX.state is the value, XXX.seq is the On timestamp and XXX.oseq is the Off timestamp, and XXX.seqh is a history of the last N on timestamps (max of 10, not saved across restarts, only the most recent one is) XXX.seq should always equal XXX.seqh[1]. The seqh is currently only used internally for the Multi-Trigger checks.
The LUA context is unique for each Plugin. You can share global variables between Actions, but not between PLEG/PLTS devices or Vera Scenes.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: Property variable needed in LUA action code
« Reply #1 on: January 03, 2019, 02:55:43 pm »
So you can use the "Exports" options on Conditions to make the value of those conditions available outside of that PLEG.  I use this in a few places to send values between PLEGs.  Once it is set as an export, you can pull the value into another PLEG via an input property.  I have not referenced via LUA, but it would be the service ID urn:rts-services-com:serviceId:User plus the name you gave the exported condition.

I don't think you can reference the timestamps, but the value of the condition is doable.  Sorry I don't have a LUA example...
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)