FHEM Forum

FHEM => English Corner => Thema gestartet von: H3nr1 am 11 Februar 2014, 20:22:36

Titel: help with fhem command
Beitrag von: H3nr1 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
Titel: Antw:help with fhem command
Beitrag von: UliM am 12 Februar 2014, 07:12:44
In readingsVal and in your condition, put the parameters between "
Readingsval("sensor","reading","default") eq "1"
Titel: Antw:help with fhem command
Beitrag von: H3nr1 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") } }
Titel: Antw:help with fhem command
Beitrag von: rudolfkoenig am 12 Februar 2014, 21:13:17
Of course. Did you read http://fhem.de/commandref.html#perl ?
Titel: Antw:help with fhem command
Beitrag von: H3nr1 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
Titel: Antw:help with fhem command
Beitrag von: rudolfkoenig 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.
Titel: Antw:help with fhem command
Beitrag von: H3nr1 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


Titel: Antw:help with fhem command
Beitrag von: rudolfkoenig 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"
Titel: Antw:help with fhem command
Beitrag von: H3nr1 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?
Titel: Antw:help with fhem command
Beitrag von: rudolfkoenig 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.