We have moved at community.getvera.com

Author Topic: Watch house mode changed  (Read 1697 times)

Offline Damian R

  • Jr. Member
  • **
  • Posts: 67
  • Karma: +2/-0
Watch house mode changed
« on: October 01, 2014, 01:24:11 am »
Wondering if there is a way to use variable_watch to get notified of house mode changes.. Nothing I do seems to work.

I know i can get the house mode with

Code: [Select]
mode = luup.inet.wget("http://127.0.0.1:3480/data_request?id=variableget&Variable=Mode")
But I wanted a way of watching the variable for changes to test which mode was triggered and run the appropriate code... Without manually triggering yet another scene that does what I need it to do.

Offline konstsch

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-2
Re: Watch house mode changed
« Reply #1 on: August 25, 2015, 01:45:58 pm »
I think that's a really important question.
I tried to do so:
Code: [Select]
luup.variable_watch("device_homemode_change", "urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetHouseMode", 29)
function device_homemode_change(dev_id,service, variable, old_val, new_val) 
    --some code
end

but this code don't work

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Watch house mode changed
« Reply #2 on: August 25, 2015, 03:14:48 pm »
I believe there's a HouseModes plugin to do this sort of thing?

House mode is a top-level attribute, not a variable, and you can access it through
Code: [Select]
luup.attr_get "Mode"

You can't watch attributes like variables, but you could use call_delay to poll, say, every one minute.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline konstsch

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-2
Re: Watch house mode changed
« Reply #3 on: August 25, 2015, 03:54:49 pm »
Yes you are right, house modes plugin can do it, but how?

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Watch house mode changed
« Reply #4 on: August 25, 2015, 04:01:43 pm »
It polls!

Offline konstsch

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-2
Re: Watch house mode changed
« Reply #5 on: August 26, 2015, 01:58:57 am »
Using the delay pools with small periods, is it good practise?

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Watch house mode changed
« Reply #6 on: August 26, 2015, 08:29:33 am »
I believe it uses a 15 minute polling interval.

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Watch house mode changed
« Reply #7 on: August 26, 2015, 09:00:31 am »