mirror of https://github.com/arendst/Tasmota.git
v5.8.0e - SnfBrdge RF code as Domoticz Counter
5.8.0e * Add Domoticz counter sensor to Sonoff Bridge representing Received RF code (#943) * Add support for Luani HVIO board (https://luani.de/projekte/esp8266-hvio/) (#953)
This commit is contained in:
parent
48faeaa2ce
commit
12af1af01b
|
@ -1,7 +1,7 @@
|
|||
## 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.
|
||||
|
||||
Current version is **5.8.0d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **5.8.0e** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
### ATTENTION All versions
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* 5.8.0d
|
||||
/* 5.8.0e
|
||||
* Add Domoticz counter sensor to Sonoff Bridge representing Received RF code (#943)
|
||||
* Add support for Luani HVIO board (https://luani.de/projekte/esp8266-hvio/) (#953)
|
||||
*
|
||||
* 5.8.0d
|
||||
* Remove previous GPIO configuration when another module is selected
|
||||
* Fix inverted relay power on state (#909)
|
||||
* Change default PWM assignments for H801 RGB(CW) led controller to support optional Color/Dimmer control
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||
====================================================*/
|
||||
|
||||
#define VERSION 0x05080004 // 5.8.0d
|
||||
#define VERSION 0x05080005 // 5.8.0e
|
||||
|
||||
enum week_t {Last, First, Second, Third, Fourth};
|
||||
enum dow_t {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat};
|
||||
|
|
|
@ -160,6 +160,7 @@ enum module_t {
|
|||
WITTY,
|
||||
YUNSHAN,
|
||||
MAGICHOME,
|
||||
LUANIHVIO,
|
||||
MAXMODULE };
|
||||
|
||||
/********************************************************************************************/
|
||||
|
@ -202,6 +203,7 @@ const uint8_t nicelist[MAXMODULE] PROGMEM = {
|
|||
ELECTRODRAGON,
|
||||
EXS_RELAY,
|
||||
SUPLA1,
|
||||
LUANIHVIO,
|
||||
YUNSHAN,
|
||||
WION,
|
||||
H801,
|
||||
|
@ -664,6 +666,21 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White)
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Luani HVIO", // ESP8266_HVIO - https://luani.de/projekte/esp8266-hvio/
|
||||
0, // GPIO00 Flash jumper
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_USER, // GPIO02 Optional sensor / I2C SDA pad
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_REL1, // GPIO04 Relay 1 (0 = Off, 1 = On)
|
||||
GPIO_REL2, // GPIO05 Relay 2 (0 = Off, 1 = On)
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_SWT1, // GPIO12 External input 1 (0 = On, 1 = Off)
|
||||
GPIO_SWT2, // GPIO13 External input 2 (0 = On, 1 = Off)
|
||||
GPIO_USER, // GPIO14 Optional sensor / I2C SCL pad
|
||||
GPIO_LED1, // GPIO15 Led (1 = On, 0 = Off)
|
||||
0,
|
||||
GPIO_ADC0 // ADC0 A0 Analog input
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#ifdef USE_DOMOTICZ
|
||||
|
||||
#define DOMOTICZ_MAX_SENSORS 8
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_FORM_DOMOTICZ[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_DOMOTICZ_PARAMETERS " </b></legend><form method='post' action='sv'>"
|
||||
|
@ -37,8 +35,26 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
|
|||
"<tr><td><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td><input id='ut' name='ut' length=32 placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
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_VOLTAGE, D_DOMOTICZ_CURRENT };
|
||||
enum domoticz_sensors_t {
|
||||
DZ_TEMP,
|
||||
DZ_TEMP_HUM,
|
||||
DZ_TEMP_HUM_BARO,
|
||||
DZ_POWER_ENERGY,
|
||||
DZ_ILLUMINANCE,
|
||||
DZ_COUNT,
|
||||
DZ_VOLTAGE,
|
||||
DZ_CURRENT,
|
||||
DZ_MAX_SENSORS };
|
||||
|
||||
const char domoticz_sensors[DZ_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_VOLTAGE,
|
||||
D_DOMOTICZ_CURRENT };
|
||||
|
||||
char domoticz_in_topic[] = DOMOTICZ_IN_TOPIC;
|
||||
char domoticz_out_topic[] = DOMOTICZ_OUT_TOPIC;
|
||||
|
@ -49,10 +65,10 @@ byte domoticz_update_flag = 1;
|
|||
|
||||
void mqtt_publishDomoticzPowerState(byte device)
|
||||
{
|
||||
if ((device < 1) || (device > Maxdevice)) {
|
||||
device = 1;
|
||||
}
|
||||
if (sysCfg.flag.mqtt_enabled && sysCfg.domoticz_relay_idx[device -1]) {
|
||||
if ((device < 1) || (device > Maxdevice)) {
|
||||
device = 1;
|
||||
}
|
||||
if (sfl_flg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"idx\":%d,\"nvalue\":2,\"svalue\":\"%d\"}"),
|
||||
sysCfg.domoticz_relay_idx[device -1], sysCfg.led_dimmer[device -1]);
|
||||
|
@ -135,7 +151,7 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin
|
|||
int16_t found = 0;
|
||||
|
||||
domoticz_update_flag = 1;
|
||||
if (!strncmp(topicBuf, domoticz_out_topic, strlen(domoticz_out_topic)) != 0) {
|
||||
if (!strncmp(topicBuf, domoticz_out_topic, strlen(domoticz_out_topic))) {
|
||||
if (sdataBuf < 20) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -153,12 +169,13 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin
|
|||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue);
|
||||
addLog(LOG_LEVEL_DEBUG_MORE);
|
||||
|
||||
if (nvalue >= 0 && nvalue <= 2) {
|
||||
if ((idx > 0) && (nvalue >= 0) && (nvalue <= 2)) {
|
||||
for (byte i = 0; i < Maxdevice; i++) {
|
||||
if ((idx > 0) && (idx == sysCfg.domoticz_relay_idx[i])) {
|
||||
if (idx == sysCfg.domoticz_relay_idx[i]) {
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), i +1);
|
||||
if (2 == nvalue) {
|
||||
nvalue = domoticz["svalue1"];
|
||||
// if (sfl_flg && (sysCfg.led_dimmer[i] == nvalue) && ((power >> i) &1)) { // Unable to power off using webpage due to Domoticz re-sends dimmer state
|
||||
if (sfl_flg && (sysCfg.led_dimmer[i] == nvalue)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -218,7 +235,7 @@ boolean domoticz_command(const char *type, uint16_t index, char *dataBuf, uint16
|
|||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_DOMOTICZ D_CMND_SWITCHIDX "%d\":%d}"), index, sysCfg.domoticz_key_idx[index -1]);
|
||||
}
|
||||
else if (!strcasecmp_P(type +dmtcz_len, PSTR(D_CMND_SENSORIDX)) && (index > 0) && (index <= DOMOTICZ_MAX_SENSORS)) {
|
||||
else if (!strcasecmp_P(type +dmtcz_len, PSTR(D_CMND_SENSORIDX)) && (index > 0) && (index <= DZ_MAX_SENSORS)) {
|
||||
if (payload >= 0) {
|
||||
sysCfg.domoticz_sensor_idx[index -1] = payload;
|
||||
}
|
||||
|
@ -271,46 +288,34 @@ void domoticz_sensor(byte idx, char *data)
|
|||
}
|
||||
}
|
||||
|
||||
// domoticz_sensor(0, temp);
|
||||
void domoticz_sensor(byte idx, uint32_t value)
|
||||
{
|
||||
char data[16];
|
||||
snprintf_P(data, sizeof(data), PSTR("%d"), value);
|
||||
domoticz_sensor(idx, data);
|
||||
}
|
||||
|
||||
void domoticz_sensor2(char *temp, char *hum)
|
||||
{
|
||||
char data[16];
|
||||
snprintf_P(data, sizeof(data), PSTR("%s;%s;%d"), temp, hum, dom_hum_stat(hum));
|
||||
domoticz_sensor(1, data);
|
||||
domoticz_sensor(DZ_TEMP_HUM, data);
|
||||
}
|
||||
|
||||
void domoticz_sensor3(char *temp, char *hum, char *baro)
|
||||
{
|
||||
char data[32];
|
||||
snprintf_P(data, sizeof(data), PSTR("%s;%s;%d;%s;5"), temp, hum, dom_hum_stat(hum), baro);
|
||||
domoticz_sensor(2, data);
|
||||
domoticz_sensor(DZ_TEMP_HUM_BARO, data);
|
||||
}
|
||||
|
||||
void domoticz_sensor4(uint16_t power, char *energy)
|
||||
{
|
||||
char data[16];
|
||||
snprintf_P(data, sizeof(data), PSTR("%d;%s"), power, energy);
|
||||
domoticz_sensor(3, data);
|
||||
domoticz_sensor(DZ_POWER_ENERGY, data);
|
||||
}
|
||||
|
||||
void domoticz_sensor5(uint16_t lux)
|
||||
{
|
||||
char data[8];
|
||||
snprintf_P(data, sizeof(data), PSTR("%d"), lux);
|
||||
domoticz_sensor(4, data);
|
||||
}
|
||||
|
||||
void domoticz_sensor6(uint32_t count)
|
||||
{
|
||||
char data[16];
|
||||
snprintf_P(data, sizeof(data), PSTR("%d"), count);
|
||||
domoticz_sensor(5, data);
|
||||
}
|
||||
|
||||
// domoticz_sensor(6, voltage);
|
||||
// domoticz_sensor(7, current);
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
@ -343,7 +348,7 @@ void handleDomoticz()
|
|||
}
|
||||
page.replace("{1", String(i +1));
|
||||
}
|
||||
for (int i = 0; i < DOMOTICZ_MAX_SENSORS; i++) {
|
||||
for (int i = 0; i < DZ_MAX_SENSORS; i++) {
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ_SENSOR);
|
||||
page.replace("{1", String(i +1));
|
||||
snprintf_P(stemp, sizeof(stemp), domoticz_sensors[i]);
|
||||
|
@ -370,7 +375,7 @@ void domoticz_saveSettings()
|
|||
snprintf_P(stemp, sizeof(stemp), PSTR("s%d"), i +1);
|
||||
sysCfg.domoticz_switch_idx[i] = (!strlen(webServer->arg(stemp).c_str())) ? 0 : atoi(webServer->arg(stemp).c_str());
|
||||
}
|
||||
for (byte i = 0; i < DOMOTICZ_MAX_SENSORS; i++) {
|
||||
for (byte i = 0; i < DZ_MAX_SENSORS; i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i +1);
|
||||
sysCfg.domoticz_sensor_idx[i] = (!strlen(webServer->arg(stemp).c_str())) ? 0 : atoi(webServer->arg(stemp).c_str());
|
||||
}
|
||||
|
|
|
@ -89,6 +89,9 @@ void sb_received()
|
|||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_RFRECEIVED "\":{\"" D_SYNC "\":%d, \"" D_LOW "\":%d, \"" D_HIGH "\":%d, \"" D_DATA "\":\"%06X\", \"" D_CMND_RFKEY "\":%s}}"),
|
||||
rsy, rlo, rhi, rid, rfkey);
|
||||
mqtt_publish_topic_P(6, PSTR(D_RFRECEIVED));
|
||||
#ifdef USE_DOMOTICZ
|
||||
domoticz_sensor(DZ_COUNT, rid); // Send rid as Domoticz Counter value
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +142,10 @@ void sb_send(uint8_t idx, uint8_t key)
|
|||
Serial.write(code);
|
||||
Serial.write(0x55); // End of Text
|
||||
Serial.flush();
|
||||
#ifdef USE_DOMOTICZ
|
||||
// uint32_t rid = sysCfg.sfb_code[idx][6] << 16 | sysCfg.sfb_code[idx][7] << 8 | code;
|
||||
// domoticz_sensor(DZ_COUNT, rid); // Send rid as Domoticz Counter value
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
|
||||
void sb_learn(uint8_t key)
|
||||
|
|
|
@ -120,7 +120,7 @@ void sc_mqttPresent(uint8_t* djson)
|
|||
*djson = 1;
|
||||
#ifdef USE_DOMOTICZ
|
||||
domoticz_sensor2(stemp1, stemp2);
|
||||
domoticz_sensor5(sc_value[2]);
|
||||
domoticz_sensor(DZ_ILLUMINANCE, sc_value[2]);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ void bh1750_mqttPresent(uint8_t* djson)
|
|||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_ILLUMINANCE "\":%d}"), mqtt_data, bh1750stype, l);
|
||||
*djson = 1;
|
||||
#ifdef USE_DOMOTICZ
|
||||
domoticz_sensor5(l);
|
||||
domoticz_sensor(DZ_ILLUMINANCE, l);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void counter_mqttPresent(uint8_t* djson)
|
|||
*djson = 1;
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (1 == dsxflg) {
|
||||
domoticz_sensor6(rtcMem.pCounter[i]);
|
||||
domoticz_sensor(DZ_COUNT, rtcMem.pCounter[i]);
|
||||
dsxflg++;
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
|
|
|
@ -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);
|
||||
*djson = 1;
|
||||
#ifdef USE_DOMOTICZ
|
||||
domoticz_sensor(0, stemp1);
|
||||
domoticz_sensor(DZ_TEMP, stemp1);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ void ds18x20_mqttPresent(uint8_t* djson)
|
|||
strcpy(stemp1, ", ");
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (1 == dsxflg) {
|
||||
domoticz_sensor(0, stemp2);
|
||||
domoticz_sensor(DZ_TEMP, stemp2);
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
|
|
|
@ -654,8 +654,8 @@ void hlw_mqttStat(byte option)
|
|||
if (option) { // Only send if telemetry
|
||||
dtostrfd(pet * 1000, 1, spet);
|
||||
domoticz_sensor4((uint16_t)pw, spet); // PowerUsage, EnergyToday
|
||||
domoticz_sensor(6, spu); // Voltage
|
||||
domoticz_sensor(7, spi); // Current
|
||||
domoticz_sensor(DZ_VOLTAGE, spu); // Voltage
|
||||
domoticz_sensor(DZ_CURRENT, spi); // Current
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue