Commit Graph

78 Commits

Author SHA1 Message Date
Shantur Rathore 1d7a058155 Tuya MCU: Add support for Switches1 to 4 FunctionIDs 1 to 4 2019-09-04 17:29:45 +01:00
Shantur Rathore efd1870d5e Tuya: Make Tuya Mcu implementation more configurable.
More and more Tuya MCU based devices are coming in the market and people requesting to support them. This patch makes Tuya module more configurable and easier to add new functionalities. Its not just a dimmer or a switch anymore.

After this Patch Tuya MCU module has a list of supported functions and the user would need to map the functionId to dpId of their device. Once mapped correctly the Tuya module will take care for handling proper function for dpId.

Currently functions supported are

1. Relays1 to 8 : FunctionID 11 to 18
2. Dimmer : FunctionID 21
3. Power ( Deca Watt )  : Function ID 31
4. Current ( milli Amps ) : Function ID 32
5. Voltage ( deca Volts ) : Function ID 33

The changes are

- Use a TuyaMCU command to map DPs to Functions instead of many different SetOptions. SetOption41, 44, 45, 46, 65 won't be needed after this patch.
- TuyaMCU command takes argument like `11,1` which means Map Function id 11 (Relay1) to DPID 1
- Migrates old settings flags and options to new TuyaMap command
2019-09-04 17:29:44 +01:00
Theo Arends 387c10f118 Fix lost energy values
Fix lost energy values (#6302)
2019-08-28 11:08:23 +02:00
Shantur Rathore 6c3d9d2ff5 Fix sonoff-display compilation after Tuya Power metering changes 2019-08-27 14:40:43 +01:00
Shantur Rathore 231a1ba137 Tuya Serial: Add support for power metering
Capable Tuya serial devices send power metering data over serial interface. User needs to identify the ids of all power metering functions and set as
SetOption44 -> Voltage
SetOption45 -> Current
SetOption46 -> Power
2019-08-27 10:50:34 +01:00
Shantur Rathore 579f68cf2f Tuya Dimmer: Add support for dimmers with max 24
New Tuya Dimmer has dim values from 0 to 24. Currently the code expects it to be 0-100 or 0-255.
With this change we move the flag to a param and use that to calculate correct dim percentage.

This change also makes sure to update settings on version upgrade.
2019-08-27 10:46:27 +01:00
Shantur Rathore 92a6f6672c Tuya Fix: Dimmer doesn't switch on from HASS
Tuya serial dimmer doesn't switch on from HASS because when powered off, HASS sends dimmer command.
Internally, dimmer update and power command are sent too quickly to serial out and switch doesn't turn on.
Adding a delay fixes things.
2019-08-23 10:02:24 +01:00
Shantur Rathore 9fb804b426 Fix: Tuya Switches are detected as dimmers.
Tuya switches are detected as dimmers even after setting SetOption65 to 1.
Currently SetOption65 just hides the dimmer from Web UI for Tuya switches with SetOption65 to 1 but they are advertised as dimmer to HASS.
With this change we set light_type to LT_BASIC (on/off) instead of LT_SERIAL1 (dimmable) when option 65 is set.
2019-08-23 10:02:24 +01:00
Shantur Rathore 1c7fd88ec4 Tuya: Rename tuya_show_dimmer to tuya_disable_dimmer to make the option clear.
By default the option is set to 0 in which case the tuya serial will act as dimmer
When its set to 1 tuya serial will disable dimmer functions.
2019-08-23 10:02:24 +01:00
Theo Arends ef63883a1c Refactor Button, Switch and Rotary to save code space
Refactor Button, Switch and Rotary to save code space
2019-08-17 16:19:58 +02:00
Theo Arends 12d17030ca Refactor Tuya driver saving code space
Refactor Tuya driver saving code space
2019-08-17 15:00:57 +02:00
Theo Arends 741ad7c26a
Merge pull request #6227 from shantur/development
Tuya Dimmer fixes
2019-08-14 16:47:40 +02:00
Shantur Rathore 0235bc0f8c Tuya Dimmer: Make dimmer lower limit optional.
Not all Tuya dimmers have a lower limit of 10% (25)
2019-08-14 14:52:37 +01:00
Shantur Rathore f08e7ff5df tuya-dimmer: Fix dimmer skipping power/dimmer commands
This tuya dimmer mcu sends data for multiple dimmer ids which breaks `tuya_ignore_dim` logic and sometimes when `power on` is sent its blocked due to multiple serial commands being sent at the same time. This patch makes sure we send dimmer commands only when we need to.
Bug is explained in https://github.com/arendst/Sonoff-Tasmota/issues/6215#issuecomment-521191828
2019-08-14 14:32:52 +01:00
Stephan Hadinger a2b8f783c4 Removed float conversion and used changeUIntScale instead 2019-08-05 14:24:50 +02:00
thirug010 943dc524ea Update Code for Issue #6066- Dimmer Value not equal to Rx Dim State #
Change Summary

1. Added Option to select Dimmer Range (1-100 and 1-255) through SetOption66 (default is 1-100 for legacy device support

2. Updated Dimmer code to set range based on the option66 100 / 225
2019-07-11 22:28:08 -05:00
Theo Arends 86314e24e5 Fix ambiguous Tuya set relay option by adding command SetOption41 allowing to control number of virtual relays
Fix ambiguous Tuya set relay option by adding command SetOption41 allowing to control number of virtual relays (#6039)
2019-07-08 12:42:46 +02:00
Theo Arends 4938b1e31e Code refactoring
Code refactoring
2019-07-02 15:49:08 +02:00
Theo Arends 1b69502d9b Code optimization - Change for(uint8_t in for (uint32_t
Code optimization - Change for(uint8_t in for (uint32_t
2019-06-30 16:44:36 +02:00
Theo Arends 30adce5648 Revert "Code optimization - Change for(uint8_t in for (uint32_t"
This reverts commit 5e1eac3f74.
2019-06-30 15:56:55 +02:00
Theo Arends 5e1eac3f74 Code optimization - Change for(uint8_t in for (uint32_t
Code optimization - Change for(uint8_t in for (uint32_t
2019-06-30 15:47:32 +02:00
Theo Arends 12da2fd6f9 Add define USE_COUNTER to my_user_config.h to save space in sonoff-basic.bin and sonoff-minimal.bin
Add define USE_COUNTER to my_user_config.h to save space in sonoff-basic.bin and sonoff-minimal.bin
2019-06-16 16:43:23 +02:00
Theo Arends 53ecde7637 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)
2019-06-08 11:38:45 +02:00
thirug010 ab9baf2ac0 Resolved conflit and Updated the code Skop dimmer packets for non-dimmer configuration
1. Rsolved the build conflict on sonoff/_changelog.ino
tools/decode-config.py

2. Updated the code Skop dimmer packets for non-dimmer configuration
2019-05-22 01:28:38 -05:00
thirug010 86af0df712 update the Code to prevent the multiple power mqtt
update the xdrv_16_tuyadimmer.ino to prevent the multiple mqtt msg for power status.
2019-05-20 16:37:23 -05:00
thirug010 ffbd1af0d1 Revert "Revert "Update xdrv_16_tuyadimmer.ino""
This reverts commit 27dd98c539.
2019-05-19 09:47:51 -05:00
thirug010 27dd98c539 Revert "Update xdrv_16_tuyadimmer.ino"
This reverts commit 7b71331cf6.
2019-05-19 09:46:44 -05:00
thirug010 7b71331cf6 Update xdrv_16_tuyadimmer.ino
Repalced TuyaGetPower() BitRead().
2019-05-19 09:44:34 -05:00
thirug010 6b013144ab Updated the code based on the feedback
* Updated xdrv_01_webserver.ino to show dimmer slider2 by default for Tuya Dimmer Module

 * Updated xdrv_16_tuyadimmer.ino remove the use of XdrvMailbox and removed the pow functions now the size for 6.5.0 build is 510kb

 * updated sonoff.ino to hold current device id
2019-05-18 18:13:57 -05:00
thirug010 d59d631e40 New Tuya Serial Based Devices support
Updated the Code to support most of the new Tuya Serial devices like 4Gang Serail switch, 1 Dimmer + 1 relay, 3 Gang  ...
2019-05-17 22:03:53 -05:00
digiblur 39615c0700
Add Tuya Dimmer 10 second heartbeat
Some newer dimmer modules require the stock firmware method of sending a heartbeat packet every 10-11 seconds to the secondary MCU.  This was tested on 2 other Tuya based dimmers that did not require this heartbeat packet and no adverse impacts have been found.
2019-04-17 21:41:58 -05:00
Theo Arends eb9617e3f9 Tune some functionality
Tune some functionality
2019-03-30 13:03:45 +01:00
Theo Arends e1c92b701b Change NULL to nullptr
Change NULL to nullptr
2019-03-26 18:26:50 +01:00
Theo Arends 06a9fbd792 Changed logging message handling
Changed logging message handling
2019-03-08 15:15:42 +01:00
Theo Arends 98ae3eaf54 6.4.1.16 Online template change
6.4.1.16 20190211
 * Initial support for online template change using command Template (#5177)
2019-02-11 19:21:49 +01:00
Theo Arends 304ac6fe44 6.4.1.12 code changes (byte/boolean)
6.4.1.12 20190128
 * Change code use of boolean to bool and byte to uint8_t
 * Change code uint8_t flags to bool flags
2019-01-28 14:08:33 +01:00
Theo Arends 447ec6256e 6.4.1.4 Update Copyright (C) 2019
6.4.1.4 20190101
 * Update Copyright (C) 2019
2019-01-01 13:55:01 +01:00
Theo Arends 7ebb7a6067 6.4.1.3 Change sonoff_template.h
6.4.1.3 20181229
 * Change sonoff_template.h module lay-out by removing non-configurable GPIOs
2018-12-29 19:46:28 +01:00
Joel Stein b2005fba40 introduce new api-call for dimmer-devices 2018-12-17 18:29:42 +01:00
Theo Arends 0df7df9b08 Fix dynamic buffer handling
Fix dynamic buffer handling
2018-11-27 12:18:27 +01:00
Theo Arends a360ac4ef6 Add dynamic buffer space
Make serial buffer space reservation dynamic
2018-11-27 11:55:54 +01:00
Theo Arends e284e78b4d Add support for Armtronix dimmers
Add support for Armtronix dimmers. See wiki for info (#4321)
2018-11-16 12:22:15 +01:00
andrethomas 4a7e7b0dbb Change C functions with () to (void) 2018-11-14 15:32:09 +02:00
Joel Stein 0d78ec4fad tuya: change Sent -> TX, Rcvd -> RX 2018-11-10 18:08:31 +01:00
Joel Stein d573f7641a tuya: formatting 2018-11-09 01:28:11 +01:00
Theo Arends 4a21d3270d Restrict hardware serial
Restrict hardware serial
2018-11-07 15:37:06 +01:00
Theo Arends 9fef82736d Prep drivers for management
Prep drivers for management
2018-11-07 10:30:03 +01:00
Joel Stein a2b7bdac45 tuya: name flag SetOption54 2018-11-06 23:27:49 +01:00
Joel Stein 7003435b34 tuya: use SetOption54 instead of SetOption22 2018-11-06 22:58:07 +01:00
Joel Stein 134a10d2c4 tuya: Add SetOption22 to select if brightness-commands from faceplate should be ignored while powered off 2018-11-06 20:06:25 +01:00