I don't understand IF function

Begonnen von d4vid, 31 Oktober 2015, 18:04:28

Vorheriges Thema - Nächstes Thema

d4vid

Hello.

Can anybody explain to me how to compare reading "temperature" with numbers or even better with attribute owg_th?

I found an example in commandref but it doesn't work.

IF ([outdoor:humidity] > 70) (set switch1 off)

Any ideas how to make this work?

fruit

I haven't used IF but a short extract from a similar statement in commandref..
IF state query of the device "outdoor" in the condition:

Do you have a device named outdoor that has a humidity reading?
Feel free to follow up in German if you prefer

d4vid

This is an example. Of course I edited it and it didnt work.

Bennemannc

Hello,

could you please post the output of "list DEVICENAME". There the readings are listed.
Hey there must be a notify before IF.
define check_humidity notify outdoor.* IF ([outdoor:humidity] > 70) (set switch1 off)
If there was a new reading / new data from the device "outdoor" the reading humidity was checked.
Cubietruck, Fhem 5.8
CC-RT-DN|LC-SW2-FM|RC-12|RC-19|LC-SW4-BA-PCB|LCp-SW1-BA-PCB|ES-PMSw1-Pl|LC-Bl1PBU-FM|PBI-4-FM|CC-VD|CC-TC|SEC-SC(2)|RC-KEY3-B|LC-Sw1PBU-FM|PB-2-FM|WDS100-C6-O|WDC7000|LC-Bl1-FM
Module: Dewpoint,FB_Callmonitor,HCS,Panstamp,at,notify,THRESHOLD,average,DOIF

fruit

I guessIF ([your_device:temperature > 70) (set switch1 off)
would test reading temperature in your_device greater than the value 70

If it's not a number then you need to use gt, lt, eq, ne etc. and enclose the characters in quotes - see other IF examples

With respect to an attribute, see http://fhem.de/commandref.html#perl section in commandref, specifically AttrVal(<devicename>,<attribute>,<defaultvalue>)

Feel free to follow up in German if you prefer

d4vid

define heating_notify1 notify OWX_T {IF ([OWX_T:temperature] gt 53) { fhem("set relay blink 10 1")}}

This is an actual code.

fruit

It would still help to see list DEVICENAME as suggested above, and for relay too!

If 53 is char and not numeric then use of gt is OK but 53 should be "53" - as noted in my earlier post and the examples

Is relay a defined device? Does set relay blink 10 1 do what you expect from the fhem commandline?
Feel free to follow up in German if you prefer

Bennemannc

Why {} ?
I have a working notify like:
define xxx notify Fensterkontakt_01.open IF (ReadingsVal("Rollo_01","pct",0) != 100)  (set Rollo_01 100)
try this one
define heating_notify1 notify OWX_T.* IF ([OWX_T:temperature] gt 53) (set relay blink 10 1)
Cubietruck, Fhem 5.8
CC-RT-DN|LC-SW2-FM|RC-12|RC-19|LC-SW4-BA-PCB|LCp-SW1-BA-PCB|ES-PMSw1-Pl|LC-Bl1PBU-FM|PBI-4-FM|CC-VD|CC-TC|SEC-SC(2)|RC-KEY3-B|LC-Sw1PBU-FM|PB-2-FM|WDS100-C6-O|WDC7000|LC-Bl1-FM
Module: Dewpoint,FB_Callmonitor,HCS,Panstamp,at,notify,THRESHOLD,average,DOIF

d4vid

Thank you, I finally got it working!