From 74e27eebea9fa333c2f64e3024534f57fb8cc8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 13 Jun 2018 11:28:36 +0200 Subject: [PATCH] Change pulse units (for MQTT and HTTP API) to seconds for coherence (#831) --- code/espurna/relay.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index e5e5788e..1c361a60 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -631,11 +631,11 @@ void relaySetupAPI() { snprintf_P(key, sizeof(key), PSTR("%s/%d"), MQTT_TOPIC_PULSE, relayID); apiRegister(key, [relayID](char * buffer, size_t len) { - snprintf_P(buffer, len, PSTR("%lu"), _relays[relayID].pulse_ms); + dtostrf((double) _relays[relayID].pulse_ms / 1000, 1-len, 3, buffer); }, [relayID](const char * payload) { - unsigned long pulse = String(payload).toInt(); + unsigned long pulse = 1000 * String(payload).toFloat(); if (0 == pulse) return; if (RELAY_PULSE_NONE != _relays[relayID].pulse) { @@ -751,7 +751,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo return; } - unsigned long pulse = String(payload).toInt(); + unsigned long pulse = 1000 * String(payload).toFloat(); if (0 == pulse) return; if (RELAY_PULSE_NONE != _relays[id].pulse) {