From 504236382fd8eaa072a53001750a50380e1161a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 12 Jun 2018 22:08:13 +0200 Subject: [PATCH] Added pulse API, pulses in ms, topic set to /pulse/+ (#896, #902) --- README.md | 6 +++--- code/espurna/relay.ino | 45 +++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0fa4cd5e..f2526e8b 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smar It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. [![version](https://img.shields.io/badge/version-1.13.0c-brightgreen.svg)](CHANGELOG.md) -[![branch](https://img.shields.io/badge/branch-mcspr-mqtt-dynamic-pulse-orange.svg)](https://github.org/xoseperez/espurna/tree/mcspr-mqtt-dynamic-pulse/) -[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=mcspr-mqtt-dynamic-pulse)](https://travis-ci.org/xoseperez/espurna) -[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/mcspr-mqtt-dynamic-pulse.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard) +[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.org/xoseperez/espurna/tree/dev/) +[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna) +[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard) [![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE)
[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 5fade454..e5e5788e 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -601,9 +601,9 @@ void relaySetupAPI() { // API entry points (protected with apikey) for (unsigned int relayID=0; relayID= relayCount()) { DEBUG_MSG_P(PSTR("[RELAY] Wrong relayID (%d)\n"), id); return; } - unsigned long pulse = 1000 * String(payload).toFloat(); - if (pulse == 0) return; + unsigned long pulse = String(payload).toInt(); + if (0 == pulse) return; - if (_relays[id].pulse != RELAY_PULSE_NONE) { + if (RELAY_PULSE_NONE != _relays[id].pulse) { DEBUG_MSG_P(PSTR("[RELAY] Overriding relay #%d pulse settings\n"), id); } @@ -737,6 +763,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo relayToggle(id, true, false); return; + } // magnitude is relay/#