FHEM Forum

FHEM => English Corner => Thema gestartet von: Lectere am 18 März 2013, 13:45:37

Titel: Basic scripting question
Beitrag von: Lectere am 18 März 2013, 13:45:37
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!
Titel: Aw: Basic scripting question
Beitrag von: Groby am 18 März 2013, 15:43:16
Hi,

I use ReadingsVal for this:



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



brgds, Groby
Titel: Aw: Basic scripting question
Beitrag von: Lectere am 18 März 2013, 15:59:21
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!
Titel: Antw:Basic scripting question
Beitrag von: redgee34 am 12 März 2015, 05:54:11
Chrome is the fastest browser, compared to Internet Explorer and Firefox. And yes, it is supported well in FHEM.