hello, I have a problem from few week now with a notification base on mqtt action, and the ReadingsVal. I have esp32 connecting whit a RCWL-0516 and they are sending a mqtt message "client.publish("Beyren/ESP32/detect","1"); " or "client.publish("Beyren/ESP32/detect","0");" when some one is moving.
But I couldn't understanding the ReadingsVal, if some one can help me to understand who this ReadingsVal is working with mqtt, it will be fantastic. :)
Fhem is reading the value 1 or 0 to Beyren/ESP32/detect but notify is completely wrong.
This is a part of my code :
define espAlarm MQTT_DEVICE
attr espAlarm IODev Mosquitto
attr espAlarm room Alarme
attr espAlarm stateFormat transmission-state
attr espAlarm subscribeReading_0 Beyren/ESP32/detect
attr espAlarm subscribeReading_1 Beyren/ESP32/detect
attr espAlarm subscribeReading_2 Beyren/ESP32/detect
define FileLog_espAlarm FileLog ./log/espAlarm-%Y.log espAlarm
attr FileLog_espAlarm logtype text
attr FileLog_espAlarm room Alarme
define test_esp32 notify espAlarm {\
if(Value("switch_Alarm") eq "on") {\
if(ReadingsVal("espAlarm","state","2") eq "1") {\
#if(ReadingsVal("2","state",0) eq "1") {\
fhem("set Alarm_buzzer on")\
}\
}\
}
thanks for the help :)
hello again, maybe my explanation was not so clear, I will try to do it shorter. I'm sending mqtt message for example on my root "Beyren/ESP32/detect/0" and I'm trying to make a event like start the light, star a alarm if the value is 1 (from 0 to 1), but I can't manage or understanding how is working, I have try the ReadingsVal, but I'm sure that the writing is wrong, if some one can give me some light of what to put on my ReadingsVal, it's will be a big help.
Thanks :)
The result of "list espAlarm" could help.
Hello amenomade thank, i tried and get this :
Internals:
IODev Mosquitto
NAME espAlarm
NR 746
STATE incoming publish received
TYPE MQTT_DEVICE
qos 0
retain 0
READINGS:
2017-09-03 07:12:42 2 1
2017-09-03 07:12:41 transmission-state incoming publish received
message_ids:
sets:
subscribe:
Beyren/ESP32/detect
subscribeExpr:
^Beyren\/ESP32\/detect$
subscribeReadings:
Beyren/ESP32/detect 2
Attributes:
IODev Mosquitto
room Alarme
stateFormat transmission-state
subscribeReading_2 Beyren/ESP32/detect
--------------------
But still I can find the good write for the ReadingVal, I have try all this
if(ReadingsVal("espAlarm","state","2") eq "1") {\
if(ReadingsVal('espAlarm','2',"0") eq "1") {\
if(ReadingsVal("espAlarm","2","") eq "1") {\
if(ReadingsVal('detect$','2','1')) {\
if(ReadingsVal("detect$","2","0") eq "1") {\
if(ReadingsVal($detect, "2", 0) eq "1") {\
if(ReadingsVal("2","state",0) eq "1") {\
but nothing is working
if (ReadingsVal("espAlarm","2","") eq "1")
should work. If not, the problem is somewhere else.
Try define test_esp32 notify espAlarm.*
You can also use only fhem commands:
define test_esp32 notify espAlarm.* IF ([switch_Alarm] eq "on" and [espAlarm:2] eq "1") (set Alarm_buzzer on)
Many thanks amenomade ! yes it's working "if (ReadingsVal("espAlarm","2","") eq "1")" I was close but one value was to mutch "if(ReadingsVal('espAlarm','2',"0") eq "1")". :)