mirror of https://github.com/arendst/Tasmota.git
v5.8.0h - Add IR Receive
5.8.0h * Rename command IRRemote to IRSend (#956) * Add IR Receiver support. Disable in user_config.h (#956) * Change default PWM assignment for Witty Cloud to support optional Color/Dimmer control (#976) * GPIO12 (Green) from GPIO_PWM4 to GPIO_PWM2 * GPIO13 (Blue) from GPIO_PWM5 to GPIO_PWM3 * GPIO15 (Red) from GPIO_PWM3 to GPIO_PWM1
This commit is contained in:
parent
7817199b59
commit
3bc7dd4e83
|
@ -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.0g** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
Current version is **5.8.0h** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
### ATTENTION All versions
|
### ATTENTION All versions
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
/* 5.8.0g
|
/* 5.8.0h
|
||||||
|
* Rename command IRRemote to IRSend (#956)
|
||||||
|
* Add optional IR Receiver support (#956)
|
||||||
|
* Change default PWM assignment for Witty Cloud to support optional Color/Dimmer control (#976)
|
||||||
|
* GPIO12 (Green) from GPIO_PWM4 to GPIO_PWM2
|
||||||
|
* GPIO13 (Blue) from GPIO_PWM5 to GPIO_PWM3
|
||||||
|
* GPIO15 (Red) from GPIO_PWM3 to GPIO_PWM1
|
||||||
|
*
|
||||||
|
* 5.8.0g
|
||||||
* Fix inverted PWM index (#960)
|
* Fix inverted PWM index (#960)
|
||||||
* Fix some PWM related issues (#967)
|
* Fix some PWM related issues (#967)
|
||||||
* Fix timezone range from -12/12 to -13/13 (#968)
|
* Fix timezone range from -12/12 to -13/13 (#968)
|
||||||
|
|
|
@ -383,14 +383,15 @@
|
||||||
// xdrv_ir-send.ino
|
// xdrv_ir-send.ino
|
||||||
#define D_INVALID_JSON "Invalid JSON"
|
#define D_INVALID_JSON "Invalid JSON"
|
||||||
#define D_PROTOCOL_NOT_SUPPORTED "Protocol not supported"
|
#define D_PROTOCOL_NOT_SUPPORTED "Protocol not supported"
|
||||||
#define D_IRSEND_PROTOCOL "PROTOCOL"
|
#define D_IR_PROTOCOL "PROTOCOL"
|
||||||
#define D_IRSEND_BITS "BITS"
|
#define D_IR_BITS "BITS"
|
||||||
#define D_IRSEND_DATA "DATA"
|
#define D_IR_DATA "DATA"
|
||||||
#define D_IRHVAC_VENDOR "VENDOR"
|
#define D_IRHVAC_VENDOR "VENDOR"
|
||||||
#define D_IRHVAC_POWER "POWER"
|
#define D_IRHVAC_POWER "POWER"
|
||||||
#define D_IRHVAC_MODE "MODE"
|
#define D_IRHVAC_MODE "MODE"
|
||||||
#define D_IRHVAC_FANSPEED "FANSPEED"
|
#define D_IRHVAC_FANSPEED "FANSPEED"
|
||||||
#define D_IRHVAC_TEMP "TEMP"
|
#define D_IRHVAC_TEMP "TEMP"
|
||||||
|
#define D_IRRECEIVED "IrReceived"
|
||||||
|
|
||||||
// xdrv_snfbridge.ino
|
// xdrv_snfbridge.ino
|
||||||
#define D_RFRECEIVED "RfReceived"
|
#define D_RFRECEIVED "RfReceived"
|
||||||
|
@ -456,13 +457,14 @@
|
||||||
#define D_SENSOR_I2C_SCL "I2C SCL"
|
#define D_SENSOR_I2C_SCL "I2C SCL"
|
||||||
#define D_SENSOR_I2C_SDA "I2C SDA"
|
#define D_SENSOR_I2C_SDA "I2C SDA"
|
||||||
#define D_SENSOR_WS2812 "WS2812"
|
#define D_SENSOR_WS2812 "WS2812"
|
||||||
#define D_SENSOR_IRREMOTE "IRremote"
|
#define D_SENSOR_IRSEND "IRsend"
|
||||||
#define D_SENSOR_SWITCH "Switch" // Suffix "1"
|
#define D_SENSOR_SWITCH "Switch" // Suffix "1"
|
||||||
#define D_SENSOR_BUTTON "Button" // Suffix "1"
|
#define D_SENSOR_BUTTON "Button" // Suffix "1"
|
||||||
#define D_SENSOR_RELAY "Relay" // Suffix "1I"
|
#define D_SENSOR_RELAY "Relay" // Suffix "1I"
|
||||||
#define D_SENSOR_LED "Led" // Suffix "1I"
|
#define D_SENSOR_LED "Led" // Suffix "1I"
|
||||||
#define D_SENSOR_PWM "PWM" // Suffix "1"
|
#define D_SENSOR_PWM "PWM" // Suffix "1"
|
||||||
#define D_SENSOR_COUNTER "Counter" // Suffix "1"
|
#define D_SENSOR_COUNTER "Counter" // Suffix "1"
|
||||||
|
#define D_SENSOR_IRRECV "IRrecv"
|
||||||
#define D_SENSOR_SPI_CS "SPI CS"
|
#define D_SENSOR_SPI_CS "SPI CS"
|
||||||
#define D_SENSOR_SPI_DC "SPI DC"
|
#define D_SENSOR_SPI_DC "SPI DC"
|
||||||
#define D_SENSOR_BACKLIGHT "BLight"
|
#define D_SENSOR_BACKLIGHT "BLight"
|
||||||
|
@ -493,6 +495,7 @@
|
||||||
#define D_LOG_DSB "DSB: "
|
#define D_LOG_DSB "DSB: "
|
||||||
#define D_LOG_HTTP "HTP: "
|
#define D_LOG_HTTP "HTP: "
|
||||||
#define D_LOG_I2C "I2C: "
|
#define D_LOG_I2C "I2C: "
|
||||||
|
#define D_LOG_IRR "IRR: "
|
||||||
#define D_LOG_LOG "LOG: "
|
#define D_LOG_LOG "LOG: "
|
||||||
#define D_LOG_MODULE "MOD: "
|
#define D_LOG_MODULE "MOD: "
|
||||||
#define D_LOG_MDNS "DNS: "
|
#define D_LOG_MDNS "DNS: "
|
||||||
|
|
|
@ -383,14 +383,15 @@
|
||||||
// xdrv_ir-send.ino
|
// xdrv_ir-send.ino
|
||||||
#define D_INVALID_JSON "Ongeldig JSON"
|
#define D_INVALID_JSON "Ongeldig JSON"
|
||||||
#define D_PROTOCOL_NOT_SUPPORTED "Protocol wordt niet ondersteund"
|
#define D_PROTOCOL_NOT_SUPPORTED "Protocol wordt niet ondersteund"
|
||||||
#define D_IRSEND_PROTOCOL "PROTOCOL"
|
#define D_IR_PROTOCOL "PROTOCOL"
|
||||||
#define D_IRSEND_BITS "BITS"
|
#define D_IR_BITS "BITS"
|
||||||
#define D_IRSEND_DATA "DATA"
|
#define D_IR_DATA "DATA"
|
||||||
#define D_IRHVAC_VENDOR "VENDOR"
|
#define D_IRHVAC_VENDOR "VENDOR"
|
||||||
#define D_IRHVAC_POWER "POWER"
|
#define D_IRHVAC_POWER "POWER"
|
||||||
#define D_IRHVAC_MODE "MODE"
|
#define D_IRHVAC_MODE "MODE"
|
||||||
#define D_IRHVAC_FANSPEED "FANSPEED"
|
#define D_IRHVAC_FANSPEED "FANSPEED"
|
||||||
#define D_IRHVAC_TEMP "TEMP"
|
#define D_IRHVAC_TEMP "TEMP"
|
||||||
|
#define D_IRRECEIVED "IrReceived"
|
||||||
|
|
||||||
// xdrv_snfbridge.ino
|
// xdrv_snfbridge.ino
|
||||||
#define D_RFRECEIVED "RfReceived"
|
#define D_RFRECEIVED "RfReceived"
|
||||||
|
@ -456,13 +457,14 @@
|
||||||
#define D_SENSOR_I2C_SCL "I2C SCL"
|
#define D_SENSOR_I2C_SCL "I2C SCL"
|
||||||
#define D_SENSOR_I2C_SDA "I2C SDA"
|
#define D_SENSOR_I2C_SDA "I2C SDA"
|
||||||
#define D_SENSOR_WS2812 "WS2812"
|
#define D_SENSOR_WS2812 "WS2812"
|
||||||
#define D_SENSOR_IRREMOTE "IRremote"
|
#define D_SENSOR_IRSEND "IRsend"
|
||||||
#define D_SENSOR_SWITCH "Switch" // Suffix "1"
|
#define D_SENSOR_SWITCH "Switch" // Suffix "1"
|
||||||
#define D_SENSOR_BUTTON "Button" // Suffix "1"
|
#define D_SENSOR_BUTTON "Button" // Suffix "1"
|
||||||
#define D_SENSOR_RELAY "Relais" // Suffix "1I"
|
#define D_SENSOR_RELAY "Relais" // Suffix "1I"
|
||||||
#define D_SENSOR_LED "Led" // Suffix "1I"
|
#define D_SENSOR_LED "Led" // Suffix "1I"
|
||||||
#define D_SENSOR_PWM "PWM" // Suffix "1"
|
#define D_SENSOR_PWM "PWM" // Suffix "1"
|
||||||
#define D_SENSOR_COUNTER "Teller" // Suffix "1"
|
#define D_SENSOR_COUNTER "Teller" // Suffix "1"
|
||||||
|
#define D_SENSOR_IRRECV "IRrecv"
|
||||||
#define D_SENSOR_SPI_CS "SPI CS"
|
#define D_SENSOR_SPI_CS "SPI CS"
|
||||||
#define D_SENSOR_SPI_DC "SPI DC"
|
#define D_SENSOR_SPI_DC "SPI DC"
|
||||||
#define D_SENSOR_BACKLIGHT "BLight"
|
#define D_SENSOR_BACKLIGHT "BLight"
|
||||||
|
@ -493,6 +495,7 @@
|
||||||
#define D_LOG_DSB "DSB: "
|
#define D_LOG_DSB "DSB: "
|
||||||
#define D_LOG_HTTP "HTP: "
|
#define D_LOG_HTTP "HTP: "
|
||||||
#define D_LOG_I2C "I2C: "
|
#define D_LOG_I2C "I2C: "
|
||||||
|
#define D_LOG_IRR "IRR: "
|
||||||
#define D_LOG_LOG "LOG: "
|
#define D_LOG_LOG "LOG: "
|
||||||
#define D_LOG_MODULE "MOD: "
|
#define D_LOG_MODULE "MOD: "
|
||||||
#define D_LOG_MDNS "DNS: "
|
#define D_LOG_MDNS "DNS: "
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||||
====================================================*/
|
====================================================*/
|
||||||
|
|
||||||
#define VERSION 0x05080007 // 5.8.0g
|
#define VERSION 0x05080008 // 5.8.0h
|
||||||
|
|
||||||
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};
|
||||||
|
@ -2317,6 +2317,14 @@ void stateloop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_IR_REMOTE
|
||||||
|
#ifdef USE_IR_RECEIVE
|
||||||
|
if (pin[GPIO_IRRECV] < 99) {
|
||||||
|
ir_recv_check(); // check if there's anything on IR side
|
||||||
|
}
|
||||||
|
#endif // USE_IR_RECEIVE
|
||||||
|
#endif // USE_IR_REMOTE
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------------------------*\
|
||||||
* Every 0.05 second
|
* Every 0.05 second
|
||||||
\*-------------------------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------------------------*/
|
||||||
|
@ -2723,7 +2731,12 @@ void GPIO_init()
|
||||||
if (pin[GPIO_IRSEND] < 99) {
|
if (pin[GPIO_IRSEND] < 99) {
|
||||||
ir_send_init();
|
ir_send_init();
|
||||||
}
|
}
|
||||||
#endif // USE_IR_REMOTE
|
#ifdef USE_IR_RECEIVE
|
||||||
|
if (pin[GPIO_IRRECV] < 99) {
|
||||||
|
ir_recv_init();
|
||||||
|
}
|
||||||
|
#endif // USE_IR_RECEIVE
|
||||||
|
#endif // USE_IR_REMOTE
|
||||||
|
|
||||||
counter_init();
|
counter_init();
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ enum upins_t {
|
||||||
GPIO_PWM3_INV, // RGB Blue
|
GPIO_PWM3_INV, // RGB Blue
|
||||||
GPIO_PWM4_INV, // RGBW (Cold) White
|
GPIO_PWM4_INV, // RGBW (Cold) White
|
||||||
GPIO_PWM5_INV, // RGBCW Warm White
|
GPIO_PWM5_INV, // RGBCW Warm White
|
||||||
|
GPIO_IRRECV, // IR receiver
|
||||||
GPIO_SENSOR_END };
|
GPIO_SENSOR_END };
|
||||||
|
|
||||||
// Text in webpage Module Parameters and commands GPIOS and GPIO
|
// Text in webpage Module Parameters and commands GPIOS and GPIO
|
||||||
|
@ -78,7 +79,7 @@ const char sensors[GPIO_SENSOR_END][9] PROGMEM = {
|
||||||
D_SENSOR_I2C_SCL,
|
D_SENSOR_I2C_SCL,
|
||||||
D_SENSOR_I2C_SDA,
|
D_SENSOR_I2C_SDA,
|
||||||
D_SENSOR_WS2812,
|
D_SENSOR_WS2812,
|
||||||
D_SENSOR_IRREMOTE,
|
D_SENSOR_IRSEND,
|
||||||
D_SENSOR_SWITCH "1",
|
D_SENSOR_SWITCH "1",
|
||||||
D_SENSOR_SWITCH "2",
|
D_SENSOR_SWITCH "2",
|
||||||
D_SENSOR_SWITCH "3",
|
D_SENSOR_SWITCH "3",
|
||||||
|
@ -116,7 +117,8 @@ const char sensors[GPIO_SENSOR_END][9] PROGMEM = {
|
||||||
D_SENSOR_PWM "2I",
|
D_SENSOR_PWM "2I",
|
||||||
D_SENSOR_PWM "3I",
|
D_SENSOR_PWM "3I",
|
||||||
D_SENSOR_PWM "4I",
|
D_SENSOR_PWM "4I",
|
||||||
D_SENSOR_PWM "5I"
|
D_SENSOR_PWM "5I",
|
||||||
|
D_SENSOR_IRRECV
|
||||||
};
|
};
|
||||||
|
|
||||||
// Programmer selectable GPIO functionality offset by user selectable GPIOs
|
// Programmer selectable GPIO functionality offset by user selectable GPIOs
|
||||||
|
@ -647,10 +649,10 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
||||||
GPIO_KEY1, // GPIO04 D2 push button on ESP-12F board
|
GPIO_KEY1, // GPIO04 D2 push button on ESP-12F board
|
||||||
GPIO_USER, // GPIO05 D1 optional sensor
|
GPIO_USER, // GPIO05 D1 optional sensor
|
||||||
0, 0, 0, 0, 0, 0, // Flash connection
|
0, 0, 0, 0, 0, 0, // Flash connection
|
||||||
GPIO_PWM4, // GPIO12 D6 RGB LED Green
|
GPIO_PWM2, // GPIO12 D6 RGB LED Green
|
||||||
GPIO_PWM5, // GPIO13 D7 RGB LED Blue
|
GPIO_PWM3, // GPIO13 D7 RGB LED Blue
|
||||||
GPIO_USER, // GPIO14 D5 optional sensor
|
GPIO_USER, // GPIO14 D5 optional sensor
|
||||||
GPIO_PWM3, // GPIO15 D8 RGB LED Red
|
GPIO_PWM1, // GPIO15 D8 RGB LED Red
|
||||||
GPIO_USER, // GPIO16 D0 optional sensor
|
GPIO_USER, // GPIO16 D0 optional sensor
|
||||||
GPIO_ADC0 // ADC0 A0 Light sensor / Requires USE_ADC_VCC in user_config.h to be disabled
|
GPIO_ADC0 // ADC0 A0 Light sensor / Requires USE_ADC_VCC in user_config.h to be disabled
|
||||||
},
|
},
|
||||||
|
|
|
@ -168,6 +168,7 @@
|
||||||
|
|
||||||
#define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+3k code, 0.3k mem)
|
#define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+3k code, 0.3k mem)
|
||||||
// #define USE_IR_HVAC // Support for HVAC system using IR (+2k code)
|
// #define USE_IR_HVAC // Support for HVAC system using IR (+2k code)
|
||||||
|
#define USE_IR_RECEIVE // Support for IR receiver (+4k code)
|
||||||
|
|
||||||
#define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem) - Disable by //
|
#define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem) - Disable by //
|
||||||
#define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB)
|
#define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
xdrv_ir_send.ino - infra red support for Sonoff-Tasmota
|
xdrv_ir_send.ino - infra red support for Sonoff-Tasmota
|
||||||
|
|
||||||
Copyright (C) 2017 Heiko Krupp and Theo Arends
|
Copyright (C) 2017 Heiko Krupp, Lazar Obradovic and Theo Arends
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#ifdef USE_IR_REMOTE
|
#ifdef USE_IR_REMOTE
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* IR Remote send using IRremoteESP8266 library
|
* IR Remote send and receive using IRremoteESP8266 library
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifndef USE_IR_HVAC
|
#ifndef USE_IR_HVAC
|
||||||
|
@ -55,6 +55,20 @@ void ir_send_init(void)
|
||||||
#endif //USE_IR_HVAC
|
#endif //USE_IR_HVAC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_IR_RECEIVE
|
||||||
|
#define IR_TIME_AVOID_DUPLICATE 500 // Milliseconds
|
||||||
|
|
||||||
|
IRrecv *irrecv = NULL;
|
||||||
|
unsigned long ir_lasttime = 0;
|
||||||
|
|
||||||
|
void ir_recv_init(void)
|
||||||
|
{
|
||||||
|
irrecv = new IRrecv(pin[GPIO_IRRECV]); // an IR led is at GPIO_IRRECV
|
||||||
|
irrecv->enableIRIn(); // Start the receiver
|
||||||
|
// addLog_P(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized"));
|
||||||
|
}
|
||||||
|
#endif // USE_IR_RECEIVE
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Commands
|
* Commands
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -90,9 +104,9 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBuf, uint16_t data
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_INVALID_JSON "\"}")); // JSON decode failed
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_INVALID_JSON "\"}")); // JSON decode failed
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_DONE "\"}"));
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_DONE "\"}"));
|
||||||
protocol = ir_json[D_IRSEND_PROTOCOL];
|
protocol = ir_json[D_IR_PROTOCOL];
|
||||||
bits = ir_json[D_IRSEND_BITS];
|
bits = ir_json[D_IR_BITS];
|
||||||
data = ir_json[D_IRSEND_DATA];
|
data = ir_json[D_IR_DATA];
|
||||||
if (protocol && bits && data) {
|
if (protocol && bits && data) {
|
||||||
if (!strcasecmp_P(protocol, PSTR("NEC"))) irsend->sendNEC(data, bits);
|
if (!strcasecmp_P(protocol, PSTR("NEC"))) irsend->sendNEC(data, bits);
|
||||||
else if (!strcasecmp_P(protocol, PSTR("SONY"))) irsend->sendSony(data, bits);
|
else if (!strcasecmp_P(protocol, PSTR("SONY"))) irsend->sendSony(data, bits);
|
||||||
|
@ -108,7 +122,7 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBuf, uint16_t data
|
||||||
}
|
}
|
||||||
} else error = true;
|
} else error = true;
|
||||||
if (error) {
|
if (error) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_NO D_IRSEND_PROTOCOL ", " D_IRSEND_BITS " " D_OR " " D_IRSEND_DATA "\"}"));
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_NO " " D_IR_PROTOCOL ", " D_IR_BITS " " D_OR " " D_IR_DATA "\"}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_IR_HVAC
|
#ifdef USE_IR_HVAC
|
||||||
|
@ -140,7 +154,7 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBuf, uint16_t data
|
||||||
}
|
}
|
||||||
} else error = true;
|
} else error = true;
|
||||||
if (error) {
|
if (error) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRHVAC "\":\"" D_WRONG D_IRHVAC_VENDOR ", " D_IRHVAC_MODE " " D_OR " " D_IRHVAC_FANSPEED "\"}"));
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRHVAC "\":\"" D_WRONG " " D_IRHVAC_VENDOR ", " D_IRHVAC_MODE " " D_OR " " D_IRHVAC_FANSPEED "\"}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_IR_HVAC
|
#endif // USE_IR_HVAC
|
||||||
|
@ -282,4 +296,39 @@ boolean ir_hvac_mitsubishi(const char *HVAC_Mode,const char *HVAC_FanMode, boole
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // USE_IR_HVAC
|
#endif // USE_IR_HVAC
|
||||||
|
|
||||||
|
#ifdef USE_IR_RECEIVE
|
||||||
|
void ir_recv_check()
|
||||||
|
{
|
||||||
|
char sirtype[100];
|
||||||
|
char *protocol;
|
||||||
|
int8_t iridx = 0;
|
||||||
|
|
||||||
|
decode_results results;
|
||||||
|
if (irrecv->decode(&results)) {
|
||||||
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_IRR "RawLen %d, Bits %d, Value %08X, Decode %d"),
|
||||||
|
results.rawlen, results.bits, results.value, results.decode_type);
|
||||||
|
addLog(LOG_LEVEL_DEBUG);
|
||||||
|
unsigned long now = millis();
|
||||||
|
if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) {
|
||||||
|
ir_lasttime = now;
|
||||||
|
iridx = results.decode_type;
|
||||||
|
if ((iridx < 0) || (iridx > 14)) {
|
||||||
|
iridx = 0;
|
||||||
|
}
|
||||||
|
// Based on IRremoteESP8266.h enum decode_type_t
|
||||||
|
snprintf_P(sirtype, sizeof(sirtype), PSTR("UNKNOWN RC5 RC6 NEC SONY PANASONIC JVC SAMSUNG WHYNTER AIWA_RC_T501 LG SANYO MITSUBISHI DISH SHARP"));
|
||||||
|
protocol = strtok(sirtype, " ");
|
||||||
|
while (iridx) {
|
||||||
|
iridx--;
|
||||||
|
protocol = strtok(NULL, " ");
|
||||||
|
}
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_IRRECEIVED "\":{\"" D_IR_PROTOCOL "\":\"%s\", \"" D_IR_BITS "\":%d, \"" D_IR_DATA "\":\"%X\"}}"),
|
||||||
|
protocol, results.bits, results.value);
|
||||||
|
mqtt_publish_topic_P(6, PSTR(D_IRRECEIVED));
|
||||||
|
}
|
||||||
|
irrecv->resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // USE_IR_RECEIVE
|
||||||
#endif // USE_IR_REMOTE
|
#endif // USE_IR_REMOTE
|
||||||
|
|
Loading…
Reference in New Issue