Autor Thema: off-in-timer ?  (Gelesen 3519 mal)

franc

  • Gast
off-in-timer ?
« am: 14 April 2015, 04:33:11 »
Hi,

I have a motion sensors in each room that turn the lights for some period of time. When I go in to a room it also sets timers to turn lights in other rooms off (it's not immediate in case I am moving between rooms).

I am wondering if their is a standard way of doing this as my solution is pretty messy

thanks

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 24908
Antw:off-in-timer ?
« Antwort #1 am: 15 April 2015, 15:51:14 »
I have just added the defmod command, which may help.

define mdRoom1Ntfy notify motionDetect.* {
  my $room = AttrVal($NAME, "room", "");
  if(!data{mdRoom} || $data{mdRoom} ne $room) {
    fhem("defmod mdOff at +00:05 set room!=$room:FILTER=comment=mdSwitch:FILTER=STATE!=off off");
  }
  $data{mdRoom} = $room;
}

I assumed that all your motiondetectors are prefixed with motionDetect, that they have the same room attribute, as the corresponding switches, that all of your switches can be switched off with the off command, and that only the devices with the comment attribute containing mdSwitch should be affected.

Note that you have to add ;; and \ if changing the code directly in fhem.cfg

Caveat: you have to stay at least 5 minutes in the same room.
« Letzte Änderung: 15 April 2015, 15:53:55 von rudolfkoenig »

franc

  • Gast
Antw:off-in-timer ?
« Antwort #2 am: 16 April 2015, 10:31:46 »
thanks,

I'll read through your approach to understand it

cheers

franc

  • Gast
Antw:off-in-timer ?
« Antwort #3 am: 22 April 2015, 14:51:01 »

The defmod command is useful - thanks

However, Rre-reading my original email, I realised that I did not describe situation correctly.

The messy part of what I want to do is that I only want to modify the off timer if it would make the lights turn off sooner. If a light in one room was just about to turn off I don't want a new 'off timer' to come along and give it another 'N' minutes.

cheers