Add command SetOption65 0/1 and more Tuya Serial based device support

Add command SetOption65 0/1 and more Tuya Serial based device support (#5815)
This commit is contained in:
Theo Arends 2019-06-08 11:38:45 +02:00
parent aaacb20d55
commit 53ecde7637
5 changed files with 9 additions and 8 deletions

View File

@ -3,6 +3,7 @@
* Change pubsubclient MQTT_KEEPALIVE from 10 to 30 seconds in preparation of AWS IoT support
* Add support for AWS IoT with TLS 1.2 on core 2.5.2. Full doc here: https://github.com/arendst/Sonoff-Tasmota/wiki/AWS-IoT
* Add some MQTT housekeeping which might solve issue (#5755)
* Add command SetOption65 0/1 and more Tuya Serial based device support (#5815)
*
* 6.5.0.14 20190602
* Change webserver HTML input, button, textarea, and select name based on id

View File

@ -78,7 +78,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t no_hold_retain : 1; // bit 12 (v6.4.1.19) - SetOption62 - Don't use retain flag on HOLD messages
uint32_t no_power_feedback : 1; // bit 13 (v6.5.0.9) - SetOption63 - Don't scan relay power state at restart
uint32_t use_underscore : 1; // bit 14 (v6.5.0.12) - SetOption64 - Enable "_" instead of "-" as sensor index separator
uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.12) - SetOption65 - Enable or Disable Dimmer slider control
uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - Enable or Disable Dimmer slider control
uint32_t spare16 : 1;
uint32_t spare17 : 1;
uint32_t spare18 : 1;

View File

@ -109,7 +109,6 @@ unsigned long pulse_timer[MAX_PULSETIMERS] = { 0 }; // Power off timer
unsigned long blink_timer = 0; // Power cycle timer
unsigned long backlog_delay = 0; // Command backlog delay
power_t power = 0; // Current copy of Settings.power
power_t deviceid = 1; // hold current deviceid
power_t blink_power; // Blink power state
power_t blink_mask = 0; // Blink relay active mask
power_t blink_powersave; // Blink start power save state
@ -143,6 +142,7 @@ uint8_t backlog_pointer = 0; // Command backlog pointer
uint8_t sleep; // Current copy of Settings.sleep
uint8_t blinkspeed = 1; // LED blink rate
uint8_t pin[GPIO_MAX]; // Possible pin configurations
uint8_t active_device = 1; // Active device in ExecuteCommandPower
uint8_t leds_present = 0; // Max number of LED supported
uint8_t led_inverted = 0; // LED inverted flag (1 = (0 = On, 1 = Off))
uint8_t led_power = 0; // LED power state
@ -1653,8 +1653,6 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
// ShowSource(source);
deviceid = device;
if (SONOFF_IFAN02 == my_module_type) {
blink_mask &= 1; // No blinking on the fan relays
Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller
@ -1668,7 +1666,10 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
state &= 1;
publish_power = 0;
}
if ((device < 1) || (device > devices_present)) device = 1;
active_device = device;
if (device <= MAX_PULSETIMERS) { SetPulseTimer(device -1, 0); }
power_t mask = 1 << (device -1); // Device to control
if (state <= POWER_TOGGLE) {

View File

@ -922,8 +922,7 @@ void HandleRoot(void)
if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) {
WSContentSend_P(HTTP_MSG_SLIDER1, LightGetColorTemp());
}
if(Settings.flag3.tuya_show_dimmer == 0)
{
if (!Settings.flag3.tuya_show_dimmer) {
WSContentSend_P(HTTP_MSG_SLIDER2, Settings.light_dimmer);
}
}

View File

@ -123,7 +123,7 @@ bool TuyaSetPower(void)
int16_t source = XdrvMailbox.payload;
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
TuyaSendBool(deviceid, bitRead(rpower, deviceid-1));
TuyaSendBool(active_device, bitRead(rpower, active_device-1));
status = true;
}
return status;
@ -207,7 +207,7 @@ void TuyaPacketProcess(void)
else if (tuya_buffer[5] == 8) { // dim packet
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
if(Settings.flag3.tuya_show_dimmer == 0) //
if(Settings.flag3.tuya_show_dimmer == 0) //
{
if (!Settings.param[P_TUYA_DIMMER_ID]) {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);