domotruc / jMQTT

Jeedom plugin to interface as a client with an MQTT broker.
16 stars 8 forks source link

problème avec les commandes action dont la payload a pour valeur true ou false #80

Closed domotruc closed 4 years ago

domotruc commented 4 years ago

Les commandes action ayant pour message true/false publient 1 et (null) au lieu de true/false. Problème remonté sur le forum par Ultraboss, voir ces messages:

domotruc commented 4 years ago

Une solution qui marche consiste à encoder la payload via json_encode lorsqu'elle est de type boolean. Voici le code corrigé:

if (is_bool($payload)) {
    // Fix #80
    // One can wonder why not encoding systematically the message?
    // Answer is that it does not work in some cases:
    //   * If payload is empty => "(null)" is sent instead of (null)
    //   * If payload contains ", they are backslashed \"
    $payload = json_encode($payload);
}