I just cannot understand what is wrong with this doif statement. It will not produce the expected result. I have three MQTT devices that represent the presence of a person. To see if anyone is at home I have a doif statement that defines the state of a dummy device: (([HansLease] eq "ON") or ([IngeLease] eq "ON") or ([TinyLease] eq "ON" ))(set Iemandaanwezig ON) DOELSE (set Iemandaanwezig OFF).
If I force execution via a "set checkall" it sometimes does deliver the expected result though in other cases does not.
What can this be?
As you can see below HansLease = ON and IngeLease = ON, yet the result is "cmd2" which means Iemandaanwezig = OFF.
defmod Aanwezigheid_bediening DOIF (([HansLease] eq "ON") or ([IngeLease] eq "ON") or ([TinyLease] eq "ON" ))(set Iemandaanwezig ON) DOELSE (set Iemandaanwezig OFF)
attr Aanwezigheid_bediening room Regelkamer
attr Aanwezigheid_bediening verbose 5
setstate Aanwezigheid_bediening cmd_2
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 Device IngeLease
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 cmd 2
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 cmd_event IngeLease
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 cmd_nr 2
setstate Aanwezigheid_bediening 2021-08-17 09:20:09 e_HansLease_STATE ON
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 e_IngeLease_STATE ON
setstate Aanwezigheid_bediening 2021-08-17 00:45:47 e_TinyLease_STATE OFF
setstate Aanwezigheid_bediening 2021-08-16 12:51:08 mode enabled
setstate Aanwezigheid_bediening 2021-08-17 09:27:08 state cmd_2
Looks like you miss a reading for the devices - or STATE is not providing/containing one of the values. Assuming the reading you want to react on is state on every device, then the def could look like:
defmod Aanwezigheid_bediening DOIF (([HansLease:state] eq "ON") or ([IngeLease:state] eq "ON") or ([TinyLease:state] eq "ON" ))(set Iemandaanwezig ON) DOELSE (set Iemandaanwezig OFF)
attr Aanwezigheid_bediening room Regelkamer
attr Aanwezigheid_bediening verbose 5
If this miracle ball hint won't work, plz provide a list output of the three devices and please use code tags (# button above text input field here).
list HansLease
In addition to yersinia's answer, the output of
list Aanwezigheid_bediening
when it is in the wrong state would be helpful.
I cannot answer your question. As already mentioned you need to provide more details.
As I read in your explanation you want to react or set a status in case all your family members are at home or gone.
Check out these standard FHEM functions (below), I guess your request could be implemented easily using one of them. Currently you have only 3 members, but what happens when you want to react on further mobile devices or triggers ... doif might become to complex
Structure: when all assigned devices have status on --> structure device gets status "on" as well
https://fhem.de/commandref.html#structure
More complex but pretty nice ... Residents which includes more functions ...
https://fhem.de/commandref.html#RESIDENTS
Hi,
just as a template, I do it that way:
defmod Anwesenheit DOIF ([Presence_Kathrin_Handy:presence] eq "present" or [Presence_Frank_Handy:presence] eq "present") {TelegramTimestamp('Anwesenheit JA')}\
DOELSEIF ([Presence_Kathrin_Handy:presence] eq "absent" and [Presence_Frank_Handy:presence] eq "absent") {TelegramTimestamp('Anwesenheit NEIN')}
attr Anwesenheit checkReadingEvent 1
attr Anwesenheit cmdState ja|nein
attr Anwesenheit setList ja nein
attr Anwesenheit wait 0:65
In addition to the Telegram message I use the DOIFs state to trigger other functions.
maybe it helps
br
Frank
Herzlichen Dank Yersina, die extra ":state" war die Lösung.