Basic scripting question

Begonnen von Lectere, 18 März 2013, 13:45:37

Vorheriges Thema - Nächstes Thema

Lectere

Basic scripting question;

I have this config file;


define sun Twilight 5 6
define frontdoor.mainhall FS20 5362 5a
attr frontdoor.mainhall group doorwindowsensors
attr frontdoor.mainhall model fs20tfk
define lamp.mainhall FS20 aa55 02
attr lamp.mainhall group lights


And I want to use a notify script. I've read some perl syntax, but I'm not sure if I can use the FHEM variables in Pearl. But I have come up with this; (not tested jet)


define maindoorscript notify frontdoor.mainhall:off {
  if (sun.light !=6) || (lamp.mainhall.state=off) {
set lamp.mainhall on-for 420
  }
  #fire notifry (notify me on my phone...)
  system("/opt/fhem/scripts/main_door_opening.sh")
}


So I want the hall light to go on for 7 minutes when the front door opens, only when it's not full sunlight...

Maybe there is a better way to achive this?

Thanks for your help!
SMSPassword redundant two-factor authentication for Netscaler, Vmware View, Cisco, Juniper, etc via SMS

http://www.smspassword.com

Groby

Hi,

I use ReadingsVal for this:



if ((ReadingsVal("sun","light","") ne "6") || (ReadingsVal("lamp.mainhall","state","") eq "off"))



brgds, Groby

Lectere

So that sums up as;



define maindoorscript notify frontdoor.mainhall:off {
  if ((ReadingsVal("sun","light","") ne "6") || (ReadingsVal("lamp.mainhall","state","") eq "off")) {
fhem("set lamp.mainhall on-for 420")
  }
  #fire notifry (notify me on my phone...)
  system("/opt/fhem/scripts/main_door_opening.sh")
}



I'm gonna try that Groby, vielen dank!
SMSPassword redundant two-factor authentication for Netscaler, Vmware View, Cisco, Juniper, etc via SMS

http://www.smspassword.com

redgee34

Chrome is the fastest browser, compared to Internet Explorer and Firefox. And yes, it is supported well in FHEM.