v5.8.0b - Add Domoticz Voltage and Current

5.8.0b
 * Fix command FullTopic entry when using serial or console
interface
 * Fix possible UDP syslog blocking
 * Add debug information
to MQTT subscribe
 * Add Domoticz sensors for Voltage and Current (#903)
This commit is contained in:
arendst 2017-09-26 15:10:58 +02:00
parent 5d9dab9340
commit e974dcb7b7
12 changed files with 80 additions and 53 deletions

View File

@ -1,7 +1,7 @@
## Sonoff-Tasmota ## Sonoff-Tasmota
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
Current version is **5.8.0a** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. Current version is **5.8.0b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions ### ATTENTION All versions

View File

@ -1,8 +1,14 @@
/* 5.8.0a /* 5.8.0b
* Fix command FullTopic entry when using serial or console interface
* Fix possible UDP syslog blocking
* Add debug information to MQTT subscribe
* Add Domoticz sensors for Voltage and Current (#903)
*
* 5.8.0a
* Add translations to I2Cscan * Add translations to I2Cscan
* Add translation to BH1750 unit lx * Add translation to BH1750 unit lx
* Set default WS2812 pixel count to WS2812_LEDS * Set default WS2812 pixel count to WS2812_LEDS
* Fix GPIOx JSON response (#897) * Fix command GPIOx JSON response (#897)
* *
* 5.8.0 20170918 * 5.8.0 20170918
* Remove the need for NeoPixelBus library for Hue support * Remove the need for NeoPixelBus library for Hue support

View File

@ -163,6 +163,7 @@
#define D_STOP "Stop" #define D_STOP "Stop"
#define D_SUBNET_MASK "Subnet Mask" #define D_SUBNET_MASK "Subnet Mask"
#define D_SUBNETMASK "Subnetmask" #define D_SUBNETMASK "Subnetmask"
#define D_SUBSCRIBE_TO "Subscribe to"
#define D_SUCCESSFUL "Successful" #define D_SUCCESSFUL "Successful"
#define D_SWITCH "Switch" #define D_SWITCH "Switch"
#define D_SYNC "Sync" #define D_SYNC "Sync"
@ -373,6 +374,8 @@
#define D_DOMOTICZ_POWER_ENERGY "Power,Energy" #define D_DOMOTICZ_POWER_ENERGY "Power,Energy"
#define D_DOMOTICZ_ILLUMINANCE "Illuminance" #define D_DOMOTICZ_ILLUMINANCE "Illuminance"
#define D_DOMOTICZ_COUNT "Count" #define D_DOMOTICZ_COUNT "Count"
#define D_DOMOTICZ_VOLTAGE "Voltage"
#define D_DOMOTICZ_CURRENT "Current"
#define D_DOMOTICZ_UPDATE_TIMER "Update timer" #define D_DOMOTICZ_UPDATE_TIMER "Update timer"
#define D_CONFIGURE_DOMOTICZ "Configure Domoticz" #define D_CONFIGURE_DOMOTICZ "Configure Domoticz"

View File

@ -163,6 +163,7 @@
#define D_STOP "Stop" #define D_STOP "Stop"
#define D_SUBNET_MASK "Subnet Masker" #define D_SUBNET_MASK "Subnet Masker"
#define D_SUBNETMASK "Subnetmasker" #define D_SUBNETMASK "Subnetmasker"
#define D_SUBSCRIBE_TO "Abonneer op"
#define D_SUCCESSFUL "Gelukt" #define D_SUCCESSFUL "Gelukt"
#define D_SWITCH "Schakelaar" #define D_SWITCH "Schakelaar"
#define D_SYNC "Sync" #define D_SYNC "Sync"
@ -373,6 +374,8 @@
#define D_DOMOTICZ_POWER_ENERGY "Power,Energy" #define D_DOMOTICZ_POWER_ENERGY "Power,Energy"
#define D_DOMOTICZ_ILLUMINANCE "Illuminance" #define D_DOMOTICZ_ILLUMINANCE "Illuminance"
#define D_DOMOTICZ_COUNT "Count" #define D_DOMOTICZ_COUNT "Count"
#define D_DOMOTICZ_VOLTAGE "Spanning"
#define D_DOMOTICZ_CURRENT "Stroom"
#define D_DOMOTICZ_UPDATE_TIMER "Bijwerk timer" #define D_DOMOTICZ_UPDATE_TIMER "Bijwerk timer"
#define D_CONFIGURE_DOMOTICZ "Configureer Domoticz" #define D_CONFIGURE_DOMOTICZ "Configureer Domoticz"

View File

@ -25,16 +25,16 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x05080001 // 5.8.0a #define VERSION 0x05080002 // 5.8.0b
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth}; enum week_t {Last, First, Second, Third, Fourth};
enum dow_t {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat}; enum dow_t {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat};
enum month_t {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}; enum month_t {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
enum wifi_t {WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, MAX_WIFI_OPTION}; enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; // SerialLog, Syslog, Weblog
enum swtch_t {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, MAX_SWITCH_OPTION}; enum wifi_t {WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, MAX_WIFI_OPTION}; // WifiConfig
enum led_t {LED_OFF, LED_POWER, LED_MQTTSUB, LED_POWER_MQTTSUB, LED_MQTTPUB, LED_POWER_MQTTPUB, LED_MQTT, LED_POWER_MQTT, MAX_LED_OPTION}; enum swtch_t {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, MAX_SWITCH_OPTION}; // SwitchMode
enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX}; enum led_t {LED_OFF, LED_POWER, LED_MQTTSUB, LED_POWER_MQTTSUB, LED_MQTTPUB, LED_POWER_MQTTPUB, LED_MQTT, LED_POWER_MQTT, MAX_LED_OPTION}; // LedState
enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX}; // Emulation
#include "user_config.h" #include "user_config.h"
#include "user_config_override.h" #include "user_config_override.h"
@ -73,7 +73,10 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
#undef USE_DS18x20 // Disable DS18x20 sensor #undef USE_DS18x20 // Disable DS18x20 sensor
#endif #endif
#ifdef USE_I2C #ifdef USE_I2C
#undef USE_I2C // Disable all I2C sensors #undef USE_I2C // Disable all I2C sensors and devices
#endif
#ifdef USE_SPI
#undef USE_SPI // Disable all SPI devices
#endif #endif
#ifdef USE_WS2812 #ifdef USE_WS2812
#undef USE_WS2812 // Disable WS2812 Led string #undef USE_WS2812 // Disable WS2812 Led string
@ -445,6 +448,14 @@ void setLed(uint8_t state)
/********************************************************************************************/ /********************************************************************************************/
void mqtt_subscribe(char *topic)
{
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic);
addLog(LOG_LEVEL_DEBUG);
mqttClient.subscribe(topic);
mqttClient.loop(); // Solve LmacRxBlk:1 messages
}
void mqtt_publish_sec(const char* topic, boolean retained) void mqtt_publish_sec(const char* topic, boolean retained)
{ {
if (sysCfg.flag.mqtt_enabled) { if (sysCfg.flag.mqtt_enabled) {
@ -550,17 +561,14 @@ void mqtt_connected()
mqtt_publish_topic_P(0, S_RSLT_POWER); mqtt_publish_topic_P(0, S_RSLT_POWER);
getTopic_P(stopic, 0, sysCfg.mqtt_topic, PSTR("#")); getTopic_P(stopic, 0, sysCfg.mqtt_topic, PSTR("#"));
mqttClient.subscribe(stopic); mqtt_subscribe(stopic);
mqttClient.loop(); // Solve LmacRxBlk:1 messages
if (strstr(sysCfg.mqtt_fulltopic, MQTT_TOKEN_TOPIC) != NULL) { if (strstr(sysCfg.mqtt_fulltopic, MQTT_TOKEN_TOPIC) != NULL) {
getTopic_P(stopic, 0, sysCfg.mqtt_grptopic, PSTR("#")); getTopic_P(stopic, 0, sysCfg.mqtt_grptopic, PSTR("#"));
mqttClient.subscribe(stopic); mqtt_subscribe(stopic);
mqttClient.loop(); // Solve LmacRxBlk:1 messages
fallbacktopic = 1; fallbacktopic = 1;
getTopic_P(stopic, 0, MQTTClient, PSTR("#")); getTopic_P(stopic, 0, MQTTClient, PSTR("#"));
fallbacktopic = 0; fallbacktopic = 0;
mqttClient.subscribe(stopic); mqtt_subscribe(stopic);
mqttClient.loop(); // Solve LmacRxBlk:1 messages
} }
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
domoticz_mqttSubscribe(); domoticz_mqttSubscribe();
@ -1450,7 +1458,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
} }
#ifdef USE_EMULATION #ifdef USE_EMULATION
else if (!strcasecmp_P(type, PSTR(D_CMND_EMULATION))) { else if (!strcasecmp_P(type, PSTR(D_CMND_EMULATION))) {
if ((payload >= 0) && (payload <= 2)) { if ((payload >= EMUL_NONE) && (payload < EMUL_MAX)) {
sysCfg.flag.emulation = payload; sysCfg.flag.emulation = payload;
restartflag = 2; restartflag = 2;
} }
@ -1732,7 +1740,8 @@ void do_cmnd(char *cmnd)
} }
snprintf_P(stopic, sizeof(stopic), PSTR("/%s"), (token == NULL) ? "" : token); snprintf_P(stopic, sizeof(stopic), PSTR("/%s"), (token == NULL) ? "" : token);
token = strtok(NULL, ""); token = strtok(NULL, "");
snprintf_P(svalue, sizeof(svalue), (token == NULL) ? "" : token); // snprintf_P(svalue, sizeof(svalue), (token == NULL) ? "" : token); // Fails with command FullTopic home/%prefix%/%topic% as it processes %p of %prefix%
strlcpy(svalue, (token == NULL) ? "" : token, sizeof(svalue)); // Fixed 5.8.0b
mqttDataCb(stopic, (byte*)svalue, strlen(svalue)); mqttDataCb(stopic, (byte*)svalue, strlen(svalue));
} }

View File

@ -1153,6 +1153,7 @@ void syslog()
// Destroys log_data // Destroys log_data
char syslog_preamble[64]; // Hostname + Id char syslog_preamble[64]; // Hostname + Id
yield(); // Fix possible UDP syslog blocking
if (portUDP.beginPacket(sysCfg.syslog_host, sysCfg.syslog_port)) { if (portUDP.beginPacket(sysCfg.syslog_host, sysCfg.syslog_port)) {
snprintf_P(syslog_preamble, sizeof(syslog_preamble), PSTR("%s ESP-"), Hostname); snprintf_P(syslog_preamble, sizeof(syslog_preamble), PSTR("%s ESP-"), Hostname);
memmove(log_data + strlen(syslog_preamble), log_data, sizeof(log_data) - strlen(syslog_preamble)); memmove(log_data + strlen(syslog_preamble), log_data, sizeof(log_data) - strlen(syslog_preamble));

View File

@ -1349,7 +1349,8 @@ void handleCmnd()
if (valid) { if (valid) {
byte curridx = logidx; byte curridx = logidx;
if (strlen(webServer->arg("cmnd").c_str())) { if (strlen(webServer->arg("cmnd").c_str())) {
snprintf_P(svalue, sizeof(svalue), webServer->arg("cmnd").c_str()); // snprintf_P(svalue, sizeof(svalue), webServer->arg("cmnd").c_str()); // Processes FullTopic %p
strlcpy(svalue, webServer->arg("cmnd").c_str(), sizeof(svalue)); // Fixed 5.8.0b
// byte syslog_now = syslog_level; // byte syslog_now = syslog_level;
// syslog_level = 0; // Disable UDP syslog to not trigger hardware WDT - Seems to work fine since 5.7.1d (global logging) // syslog_level = 0; // Disable UDP syslog to not trigger hardware WDT - Seems to work fine since 5.7.1d (global logging)
do_cmnd(svalue); do_cmnd(svalue);
@ -1413,7 +1414,8 @@ void handleAjax()
byte counter = 99; byte counter = 99;
if (strlen(webServer->arg("c1").c_str())) { if (strlen(webServer->arg("c1").c_str())) {
snprintf_P(svalue, sizeof(svalue), webServer->arg("c1").c_str()); // snprintf_P(svalue, sizeof(svalue), webServer->arg("c1").c_str()); // Processes FullTopic %p
strlcpy(svalue, webServer->arg("c1").c_str(), sizeof(svalue)); // Fixed 5.8.0b
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), svalue); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), svalue);
addLog(LOG_LEVEL_INFO); addLog(LOG_LEVEL_INFO);
// byte syslog_now = syslog_level; // byte syslog_now = syslog_level;

View File

@ -19,7 +19,7 @@
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
#define DOMOTICZ_MAX_SENSORS 6 #define DOMOTICZ_MAX_SENSORS 8
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
const char HTTP_FORM_DOMOTICZ[] PROGMEM = const char HTTP_FORM_DOMOTICZ[] PROGMEM =
@ -38,7 +38,7 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
const char domoticz_sensors[DOMOTICZ_MAX_SENSORS][DOMOTICZ_SENSORS_MAX_STRING_LENGTH] PROGMEM = const char domoticz_sensors[DOMOTICZ_MAX_SENSORS][DOMOTICZ_SENSORS_MAX_STRING_LENGTH] PROGMEM =
{ D_DOMOTICZ_TEMP, D_DOMOTICZ_TEMP_HUM, D_DOMOTICZ_TEMP_HUM_BARO, D_DOMOTICZ_POWER_ENERGY, D_DOMOTICZ_ILLUMINANCE, D_DOMOTICZ_COUNT }; { D_DOMOTICZ_TEMP, D_DOMOTICZ_TEMP_HUM, D_DOMOTICZ_TEMP_HUM_BARO, D_DOMOTICZ_POWER_ENERGY, D_DOMOTICZ_ILLUMINANCE, D_DOMOTICZ_COUNT, D_DOMOTICZ_VOLTAGE, D_DOMOTICZ_CURRENT };
char domoticz_in_topic[] = DOMOTICZ_IN_TOPIC; char domoticz_in_topic[] = DOMOTICZ_IN_TOPIC;
char domoticz_out_topic[] = DOMOTICZ_OUT_TOPIC; char domoticz_out_topic[] = DOMOTICZ_OUT_TOPIC;
@ -100,8 +100,7 @@ void domoticz_mqttSubscribe()
if (domoticz_subscribe) { if (domoticz_subscribe) {
char stopic[TOPSZ]; char stopic[TOPSZ];
snprintf_P(stopic, sizeof(stopic), PSTR("%s/#"), domoticz_out_topic); // domoticz topic snprintf_P(stopic, sizeof(stopic), PSTR("%s/#"), domoticz_out_topic); // domoticz topic
mqttClient.subscribe(stopic); mqtt_subscribe(stopic);
mqttClient.loop(); // Solve LmacRxBlk:1 messages
} }
} }
@ -259,7 +258,7 @@ uint8_t dom_hum_stat(char *hum)
return (!h) ? 0 : (h < 40) ? 2 : (h > 70) ? 3 : 1; return (!h) ? 0 : (h < 40) ? 2 : (h > 70) ? 3 : 1;
} }
void dom_sensor(byte idx, char *data) void domoticz_sensor(byte idx, char *data)
{ {
if (sysCfg.domoticz_sensor_idx[idx]) { if (sysCfg.domoticz_sensor_idx[idx]) {
char dmess[64]; char dmess[64];
@ -272,46 +271,46 @@ void dom_sensor(byte idx, char *data)
} }
} }
void domoticz_sensor1(char *temp) // domoticz_sensor(0, temp);
{
dom_sensor(0, temp);
}
void domoticz_sensor2(char *temp, char *hum) void domoticz_sensor2(char *temp, char *hum)
{ {
char data[16]; char data[16];
snprintf_P(data, sizeof(data), PSTR("%s;%s;%d"), temp, hum, dom_hum_stat(hum)); snprintf_P(data, sizeof(data), PSTR("%s;%s;%d"), temp, hum, dom_hum_stat(hum));
dom_sensor(1, data); domoticz_sensor(1, data);
} }
void domoticz_sensor3(char *temp, char *hum, char *baro) void domoticz_sensor3(char *temp, char *hum, char *baro)
{ {
char data[32]; char data[32];
snprintf_P(data, sizeof(data), PSTR("%s;%s;%d;%s;5"), temp, hum, dom_hum_stat(hum), baro); snprintf_P(data, sizeof(data), PSTR("%s;%s;%d;%s;5"), temp, hum, dom_hum_stat(hum), baro);
dom_sensor(2, data); domoticz_sensor(2, data);
} }
void domoticz_sensor4(uint16_t power, char *energy) void domoticz_sensor4(uint16_t power, char *energy)
{ {
char data[16]; char data[16];
snprintf_P(data, sizeof(data), PSTR("%d;%s"), power, energy); snprintf_P(data, sizeof(data), PSTR("%d;%s"), power, energy);
dom_sensor(3, data); domoticz_sensor(3, data);
} }
void domoticz_sensor5(uint16_t lux) void domoticz_sensor5(uint16_t lux)
{ {
char data[8]; char data[8];
snprintf_P(data, sizeof(data), PSTR("%d"), lux); snprintf_P(data, sizeof(data), PSTR("%d"), lux);
dom_sensor(4, data); domoticz_sensor(4, data);
} }
void domoticz_sensor6(uint32_t count) void domoticz_sensor6(uint32_t count)
{ {
char data[16]; char data[16];
snprintf_P(data, sizeof(data), PSTR("%d"), count); snprintf_P(data, sizeof(data), PSTR("%d"), count);
dom_sensor(5, data); domoticz_sensor(5, data);
} }
// domoticz_sensor(6, voltage);
// domoticz_sensor(7, current);
/*********************************************************************************************\ /*********************************************************************************************\
* Presentation * Presentation
\*********************************************************************************************/ \*********************************************************************************************/
@ -380,11 +379,11 @@ void domoticz_saveSettings()
sysCfg.domoticz_relay_idx[0], sysCfg.domoticz_relay_idx[1], sysCfg.domoticz_relay_idx[2], sysCfg.domoticz_relay_idx[3], sysCfg.domoticz_relay_idx[0], sysCfg.domoticz_relay_idx[1], sysCfg.domoticz_relay_idx[2], sysCfg.domoticz_relay_idx[3],
sysCfg.domoticz_update_timer); sysCfg.domoticz_update_timer);
addLog(LOG_LEVEL_INFO); addLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ D_CMND_KEYIDX " %d, %d, %d, %d, " D_CMND_SWITCHIDX " %d, %d, %d, %d, " D_CMND_SENSORIDX " %d, %d, %d, %d, %d, %d"), snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ D_CMND_KEYIDX " %d, %d, %d, %d, " D_CMND_SWITCHIDX " %d, %d, %d, %d, " D_CMND_SENSORIDX " %d, %d, %d, %d, %d, %d, %d, %d"),
sysCfg.domoticz_key_idx[0], sysCfg.domoticz_key_idx[1], sysCfg.domoticz_key_idx[2], sysCfg.domoticz_key_idx[3], sysCfg.domoticz_key_idx[0], sysCfg.domoticz_key_idx[1], sysCfg.domoticz_key_idx[2], sysCfg.domoticz_key_idx[3],
sysCfg.domoticz_switch_idx[0], sysCfg.domoticz_switch_idx[1], sysCfg.domoticz_switch_idx[2], sysCfg.domoticz_switch_idx[3], sysCfg.domoticz_switch_idx[0], sysCfg.domoticz_switch_idx[1], sysCfg.domoticz_switch_idx[2], sysCfg.domoticz_switch_idx[3],
sysCfg.domoticz_sensor_idx[0], sysCfg.domoticz_sensor_idx[1], sysCfg.domoticz_sensor_idx[2], sysCfg.domoticz_sensor_idx[3], sysCfg.domoticz_sensor_idx[0], sysCfg.domoticz_sensor_idx[1], sysCfg.domoticz_sensor_idx[2], sysCfg.domoticz_sensor_idx[3],
sysCfg.domoticz_sensor_idx[4], sysCfg.domoticz_sensor_idx[5]); sysCfg.domoticz_sensor_idx[4], sysCfg.domoticz_sensor_idx[5], sysCfg.domoticz_sensor_idx[6], sysCfg.domoticz_sensor_idx[7]);
addLog(LOG_LEVEL_INFO); addLog(LOG_LEVEL_INFO);
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER

View File

@ -475,7 +475,7 @@ void hue_global_cfg(String *path)
{ {
String response; String response;
path->remove(0,1); // cut leading / to get <id> path->remove(0,1); // cut leading / to get <id>
response = F("{\"lights\":{\""); response = F("{\"lights\":{\"");
for (uint8_t i = 1; i <= Maxdevice; i++) { for (uint8_t i = 1; i <= Maxdevice; i++) {
response += i; response += i;
@ -521,8 +521,8 @@ void hue_lights(String *path)
bool change = false; bool change = false;
char id[4]; char id[4];
path->remove(0,path->indexOf("/lights")); // Remove until /lights path->remove(0,path->indexOf("/lights")); // Remove until /lights
if (path->endsWith("/lights")) { // Got /lights if (path->endsWith("/lights")) { // Got /lights
response = "{\""; response = "{\"";
for (uint8_t i = 1; i <= Maxdevice; i++) { for (uint8_t i = 1; i <= Maxdevice; i++) {
response += i; response += i;
@ -539,9 +539,9 @@ void hue_lights(String *path)
response += "}"; response += "}";
webServer->send(200, FPSTR(HDR_CTYPE_JSON), response); webServer->send(200, FPSTR(HDR_CTYPE_JSON), response);
} }
else if (path->endsWith("/state")) { // Got ID/state else if (path->endsWith("/state")) { // Got ID/state
path->remove(0,8); // Remove /lights/ path->remove(0,8); // Remove /lights/
path->remove(path->indexOf("/state")); // Remove /state path->remove(path->indexOf("/state")); // Remove /state
device = atoi(path->c_str()); device = atoi(path->c_str());
if ((device < 1) || (device > Maxdevice)) { if ((device < 1) || (device > Maxdevice)) {
device = 1; device = 1;
@ -614,7 +614,7 @@ void hue_lights(String *path)
response.replace("{res}", String(tmp)); response.replace("{res}", String(tmp));
change = true; change = true;
} }
if (hue_json.containsKey("ct")) { // Color temperature 153 (Cold) to 500 (Warm) if (hue_json.containsKey("ct")) { // Color temperature 153 (Cold) to 500 (Warm)
ct = hue_json["ct"]; ct = hue_json["ct"];
if (resp) { if (resp) {
response += ","; response += ",";
@ -642,8 +642,8 @@ void hue_lights(String *path)
webServer->send(200, FPSTR(HDR_CTYPE_JSON), response); webServer->send(200, FPSTR(HDR_CTYPE_JSON), response);
} }
else if(path->indexOf("/lights/") >= 0) { // Got /lights/ID else if(path->indexOf("/lights/") >= 0) { // Got /lights/ID
path->remove(0,8); // Remove /lights/ path->remove(0,8); // Remove /lights/
device = atoi(path->c_str()); device = atoi(path->c_str());
if ((device < 1) || (device > Maxdevice)) { if ((device < 1) || (device > Maxdevice)) {
device = 1; device = 1;
@ -696,16 +696,16 @@ void handle_hue_api(String *path)
path->remove(0, 4); // remove /api path->remove(0, 4); // remove /api
uint16_t apilen = path->length(); uint16_t apilen = path->length();
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str()); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str());
addLog(LOG_LEVEL_DEBUG_MORE); addLog(LOG_LEVEL_DEBUG_MORE); // HTP: Hue API (//lights/1/state)
for (args = 0; args < webServer->args(); args++) { for (args = 0; args < webServer->args(); args++) {
String json = webServer->arg(args); String json = webServer->arg(args);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str());
addLog(LOG_LEVEL_DEBUG_MORE); addLog(LOG_LEVEL_DEBUG_MORE); // HTP: Hue POST args ({"on":false})
} }
if (path->endsWith("/invalid/")) {} // Just ignore if (path->endsWith("/invalid/")) {} // Just ignore
else if (!apilen) hue_auth(path); // New HUE App setup else if (!apilen) hue_auth(path); // New HUE App setup
else if (path->endsWith("/")) hue_auth(path); // New HUE App setup else if (path->endsWith("/")) hue_auth(path); // New HUE App setup
else if (path->endsWith("/config")) hue_config(path); else if (path->endsWith("/config")) hue_config(path);
else if (path->indexOf("/lights") >= 0) hue_lights(path); else if (path->indexOf("/lights") >= 0) hue_lights(path);
else if (path->indexOf("/groups") >= 0) hue_groups(path); else if (path->indexOf("/groups") >= 0) hue_groups(path);

View File

@ -195,7 +195,7 @@ void dsb_mqttPresent(uint8_t* djson)
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18B20\":{\"" D_TEMPERATURE "\":%s}"), mqtt_data, stemp1); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18B20\":{\"" D_TEMPERATURE "\":%s}"), mqtt_data, stemp1);
*djson = 1; *djson = 1;
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
domoticz_sensor1(stemp1); domoticz_sensor(0, stemp1);
#endif // USE_DOMOTICZ #endif // USE_DOMOTICZ
} }
} }

View File

@ -201,7 +201,9 @@ void ds18x20_mqttPresent(uint8_t* djson)
mqtt_data, stemp1, i +1, dsbstype, ds18x20_address(i).c_str(), stemp2); mqtt_data, stemp1, i +1, dsbstype, ds18x20_address(i).c_str(), stemp2);
strcpy(stemp1, ", "); strcpy(stemp1, ", ");
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
if (1 == dsxflg) domoticz_sensor1(stemp2); if (1 == dsxflg) {
domoticz_sensor(0, stemp2);
}
#endif // USE_DOMOTICZ #endif // USE_DOMOTICZ
} }
} }

View File

@ -653,7 +653,9 @@ void hlw_mqttStat(byte option)
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
if (option) { // Only send if telemetry if (option) { // Only send if telemetry
dtostrfd(pet * 1000, 1, spet); dtostrfd(pet * 1000, 1, spet);
domoticz_sensor4((uint16_t)pw, spet); domoticz_sensor4((uint16_t)pw, spet); // PowerUsage, EnergyToday
domoticz_sensor(6, spu); // Voltage
domoticz_sensor(7, spi); // Current
} }
#endif // USE_DOMOTICZ #endif // USE_DOMOTICZ
} }