Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuya mcu support #6353

Merged
merged 6 commits into from
Sep 5, 2019
Merged

Tuya mcu support #6353

merged 6 commits into from
Sep 5, 2019

Conversation

shantur
Copy link
Contributor

@shantur shantur commented Sep 4, 2019

Description:

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. Switches 1 to 4 : FunctionID 1 to 4
  2. Relays1 to 8 : FunctionID 11 to 18
  3. Dimmer : FunctionID 21
  4. Power ( Deca Watt ) : Function ID 31
  5. Current ( milli Amps ) : Function ID 32
  6. Voltage ( deca Volts ) : Function ID 33
  7. Inverted Relays1 to 8 : Function ID 41 to 48

The changes are

  • Use a TuyaMCU command to map DPs to Functions instead of many different SetOptions. SetOption41, 44, 45, 46, 65 and many future ones won't be needed after this patch.
  • Each Tuya device a maximum of 16 functions is supported
  • 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
  • Renames Tuya Dimmer module to Tuya MCU

A wiki page for new Tuya MCU implementation will be created once this PR is merged in.

As per plan each SetOption can be removed as well after this goes in.

Related issue (if applicable): fixes #6319

Checklist:

  • The pull request is done against the latest dev branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR.
  • The code change is tested and works on core 2.3.0, 2.4.2 and 2.5.2
  • The code change pass travis tests. Your PR cannot be merged unless tests pass
  • I accept the CLA.

Shantur Rathore added 5 commits September 4, 2019 17:29
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
@arendst arendst merged commit 2aedfc6 into arendst:development Sep 5, 2019
@arendst
Copy link
Owner

arendst commented Sep 5, 2019

Many Thx

@shantur
Copy link
Contributor Author

shantur commented Sep 5, 2019

@arendst : Thanks for merging this in.

Given that this is now merged, I would suggest removal of SetOption41, 44, 45, 46, 65 in next stable development release. Given that SetOption 44, 45, 46 were added in 6.6.0.8+, these can be easily dropped.

@arendst
Copy link
Owner

arendst commented Sep 5, 2019

Right.

I will investigate the consequences and get rid of them ASAP to make the user base as small as possible.

@arendst
Copy link
Owner

arendst commented Sep 5, 2019

While preparing for clean up I came across Settings.flag3.tuya_disable_dimmer which still seems to be used in tuyamcu.ino lines 300 and 309.

Shouldn't they be replaced by the new functionality? If not then SetOption65 is still needed.

arendst added a commit that referenced this pull request Sep 5, 2019
Redesign Tuya support by Shantur Rathore (#6353)
@shantur
Copy link
Contributor Author

shantur commented Sep 5, 2019

Yes, tuya_disable_dimmer needs to go. Its my bad, i will raise a PR with the change

@shantur
Copy link
Contributor Author

shantur commented Sep 5, 2019

Cleaned up in #6355

@vajonam
Copy link

vajonam commented Sep 6, 2019

@shantur this did work for some period, I left it alone for a while and the MCU stopped responding, is this a known issue? how can I help debug this?

@blackscreener
Copy link

Are you planning support for 2 channel tuya mcu dimmer?

@shantur
Copy link
Contributor Author

shantur commented Jun 9, 2020

@blackscreener : Open a new issue and post some logs

@blackscreener
Copy link

@shantur
#8663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wofea WiFi Switch Smart Garage Door Opener support (Tuya)
4 participants