Je rencontre un soucis par manque de connaissance.
J'ai une camera wifi Xiaomi Dafang Hacker : https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks
Le hack apporte la fonction détecteur de mouvement, le message est transmit en MQTT :
Code : Tout sélectionner
myhome/dafang/motion : msg.payload : string[3]
"OFF"
Code : Tout sélectionner
myhome/dafang/motion : msg.payload : string[2]
"ON"
J'arrive a un début de quelque chose : allumer ou éteindre un dummy switch avec ce type de fonction :
Code : Tout sélectionner
msg1={};
if ( msg.payload.string) {
msg1.payload = {
"command" : "switchlight",
"idx" : 9274,
"switchcmd" : 'On'
}
} else {
msg1.payload = {
"command" : "switchlight",
"idx" : 9274,
"switchcmd" : 'Off'
}
}
return [msg1];
Mais le message envoyer est toujours le même :
Code : Tout sélectionner
09/02/2019 à 18:58:07node: 95d98189.f02ea
msg.payload : Object
{ command: "switchlight", idx: 9274, switchcmd: "Off" }
Avez Vous une idée ou une source pour parser ce fichu "String" ON ou OFF ?
Merci