help with fhem command

Begonnen von H3nr1, 11 Februar 2014, 20:22:36

Vorheriges Thema - Nächstes Thema

H3nr1

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

UliM

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.

H3nr1

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") } }

rudolfkoenig


H3nr1

#4
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

rudolfkoenig

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.

H3nr1

#6
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



rudolfkoenig

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"

H3nr1

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?

rudolfkoenig

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.