Autor Thema: help with fhem command  (Gelesen 5167 mal)

Offline H3nr1

  • New Member
  • *
  • Beiträge: 43
help with fhem command
« am: 11 Februar 2014, 20:22:36 »
Who van help me. I want to read a value from a 1wire switch Ds2406 with a motion detection and then turn on a lamp.
.define lampaan notify EnO_switch_FFECXXXX { if (ReadingsVal (DS2406_688892000000,sensed.B,0) eq 1){ fhem("set EnO_switch_FFECXXXX on") } else { fhem("set EnO_switch_FFECXXXX off")
This code doesn't work. Please help

Henri
« Letzte Änderung: 13 Februar 2014, 23:17:07 von H3nr1 »

Offline UliM

  • Developer
  • Hero Member
  • ****
  • Beiträge: 2711
Antw:help with fhem command
« Antwort #1 am: 12 Februar 2014, 07:12:44 »
In readingsVal and in your condition, put the parameters between "
Readingsval("sensor","reading","default") eq "1"
RPi4/Raspbian, CUL V3 (ca. 30 HomeMatic-devices), LAN (HarmonyHub, alexa etc.).  Fördermitglied des FHEM e.V.

Offline H3nr1

  • New Member
  • *
  • Beiträge: 43
Antw:help with fhem command
« Antwort #2 am: 12 Februar 2014, 21:02:51 »
Thnx, still no light on. Is there a way to check the syntax? Or to check if the reading is going right?

define lampaan notify { if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1") { fhem("set EnO_switch_FFEC9F85 on") } else { fhem("set EnO_switch_FFEC9F85 off") } }

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 25322
Antw:help with fhem command
« Antwort #3 am: 12 Februar 2014, 21:13:17 »
Of course. Did you read http://fhem.de/commandref.html#perl ?

Offline H3nr1

  • New Member
  • *
  • Beiträge: 43
Antw:help with fhem command
« Antwort #4 am: 12 Februar 2014, 21:47:45 »
ok now i checked with this
{ if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1") { "Hello 1" } else { "Hello 0" } }
That works  :D "Hello 0" and if i trigger the motion sensor "Hello 1"
{ if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1") { fhem("set EnO_switch_FFEC9F85 on") } else { fhem("set EnO_switch_FFEC9F85 off") } }
Light goes on when sensed.B is 1  :D :D

define lampaan notify lampaan { if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1") { fhem("set EnO_switch_FFECXXXX on") } else { fhem("set EnO_switch_FFECXXXX off") } }
Ok now if i manually trigger lampaan it works. How can i put this in fhem that it automaticly works when sensed.B turns to 1?

Thanks
« Letzte Änderung: 13 Februar 2014, 08:10:07 von H3nr1 »

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 25322
Antw:help with fhem command
« Antwort #5 am: 13 Februar 2014, 09:22:56 »
By modifying the notify regexp, so that it matches the event sent by your Eno-Switch. You get the idea how this looks like, by opening the event-monitor, and genrating events.

Offline H3nr1

  • New Member
  • *
  • Beiträge: 43
Antw:help with fhem command
« Antwort #6 am: 13 Februar 2014, 23:16:48 »
Thanks Rudolf,

i see this in the Event monitor
OWDevice DS2406_688892000000 sensed.B: 0
I saw this in the reference
define wzMessLg notify wz:measured.* "/usr/local/bin/logfht $NAME "$EVENT""
So i changed my code to
define lampaan notify DS2406_688892000000:sensed.B* { if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1") { fhem("set EnO_switch_FFECXXXX on") } else { fhem("set EnO_switch_FFECXXXX off") } }
YES it works and i learned something. Great feeling  ;D ;D

Can you give me some pointers on how to set this with a time frame? I want to turn on the light between 00:00 and 06:00


« Letzte Änderung: 13 Februar 2014, 23:40:31 von H3nr1 »

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 25322
Antw:help with fhem command
« Antwort #7 am: 14 Februar 2014, 09:39:41 »
In the section mentioned above you'll also see, that there is a $hms Variable, so in the notify you can additionally check for
$hms gt "00:00:00" && $hms lt "06:00:00"

Offline H3nr1

  • New Member
  • *
  • Beiträge: 43
Antw:help with fhem command
« Antwort #8 am: 19 Februar 2014, 22:46:39 »
Danke Rudolf,

Now i have this and it works.
define lampaan notify DS2406_688892000000:sensed.* { if (ReadingsVal ("DS2406_688892000000","sensed.B","0") eq "1" && $hms gt "00:00:00" && $hms lt "06:00:00") { fhem("set EnO_switch_FFECXXXX on") } else { fhem("set EnO_switch_FFECXXXX off") } }
The only "problem" i have is that the Eno_switch gets turned off because of the "else" statement. Any thoughts on how to make this command better?

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 25322
Antw:help with fhem command
« Antwort #9 am: 20 Februar 2014, 07:47:26 »
I am slightly confused. If the else statement is annoying, than simply remove it. I suspect that you did not take a look at the events in the Event Monitor, so there are unsuspected ones causing havoc.