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
In readingsVal and in your condition, put the parameters between "
Readingsval("sensor","reading","default") eq "1"
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") } }
Of course. Did you read http://fhem.de/commandref.html#perl ?
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
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.
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
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"
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?
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.