Purchase of a dimmer I bought the product some time ago. It can be found by searching for MoesHouse DIY Smart WiFi Light LED Dimmer Switch Smart Life / Tuya APP Remote Control 1 Way Switch Works With Alexa Google Home - 1pcs . Now its price has probably increased a bit, but you can also find it cheaper on various websites:
The maximum power of lighting for this dimmer is 150W. The WiFi standard is 2.4GHz 802.11 b/g/n. It works with Tuya Smart / Smart Life applications. Its size is 51x46x22mm.
The set also includes instructions:
The interior of the dimmer Now it's time to look inside.
It is really easy to remove the casing.
Here, the photo gallery will be a bit unusual, because I also have the same dimmer damaged, I got it from one of our users, so I will put both in the photos Two dimmers next to each other, functional and damaged:
What does the dimmer have inside? First of all, the WB2S WiFi module + Holtek HT66F3195 microcontroller. They communicate via UART.
They are powered by BP2525 (transformerless power supply), and next to it we have a whole circuit associated with a dimmer (S3M rectifier diodes), an optocoupler to detect the sine cycle, an unmarked controller circuit and ... SIF12N65F. Originally I was expecting a triac here, but this is an N-channel MOSFET (Vds = 650V, RdsOn = 0.6Ohm, Id = 12A). This explains these four rectifier diodes. This dimmer apparently rectifies the mains voltage and then keyed it with a transistor.
OpenBeken configuration After the basic configuration that I discussed in the previous topics in the series, prepare a startup script (a file named autorun.bat with the following content):
Log in, to see the code
And in the App panel, drag it to the OBK file system:
This script will execute after device boot. After dragging itself, it will not be executed, you have to restart device manually (e.g. with a button from the WWW panel).
Meaning of individual commands:
- startDriver TuyaMCU - runs the TuyaMCU driver
- setChannelType 1 toggle - set the type of channel number 1 to On / Off
- setChannelType 2 dimmer - sets the type of channel number 2 on the dimmer
- tuyaMcu_setDimmerRange 0 1000 - sets the value range of the TuyaMCU dimmer (for GUI it is from 0 to 100 always, to 0 to 1000 it is converted only for MCU)
- linkTuyaMCUOutputToChannel 1 bool 1 - connects TuyaMCU dpID number 1 with bool type channel number 1
- linkTuyaMCUOutputToChannel 2 val 2 - connects dpID number 2 of TuyaMCU with channel number 2 of value type
The dpID values can be different for different kinds of devices. If we want to add support for something new, we need to get to know it, e.g. by listening for packages. The dpID values can also be taken from the descriptions of devices intended for Tasmota, because Tuya often only changes the WiFi module and the rest remains the same. After a restart in the OpenBK panel, we have a separate switch and dimmer:
This is how the different levels of brightness look like:
How does the button work? At first glance, you might think that the button is not supported by OpenBeken. But nothing could be more wrong!
In this product, the button is connected to the TuyaMCU, not to the module with WiFi. This TuyaMCU supports the button. We have everything ready. We connect the button to the appropriate pin (S for switch):
Both bistable and monostable buttons can be used. The button works in such a way that after switching on the brightness gradually increases and we can choose what level we want by simply switching it again. If, on the other hand, the light is on, the quick switching on and off of the button will turn it off completely. All of this is done by HT66F3195.
Home Assistant support Pairing with Home Assistant is very simple, all thanks to the automatic mapping of OpenBeken channels to TuyaMCU variables. The TuyaMCU dimmer is operated from the HA level in the same way as an ordinary PWM-based dimmer. Here is a sample Yaml code:
Log in, to see the code
We have two separate channels - one determines the state of the device (on / off), the other - the brightness level.
Final application test:
[movie: 9a87cdbc15] https://filmy.elektroda.pl/95_1654602681.mp4 [/ movie: 9a87cdbc15]
Final button test:
[movie: 9a87cdbc15] https://filmy.elektroda.pl/4_1654602765.mp4 [/ movie: 9a87cdbc15]
What is noticeable in the movies? First of all, a step-by-step animation of the brightness shift that comes from Holtek's layout and cannot be changed. This is why the Home Assistant slider "clicks".
Also, there is a slight delay in reporting the status, but that's normal.
Support for scripts and commands over HTTP OpenBeken supports sending Tasmota-style commands via the so-called "Tasmota HTTP". You can even send them via an ordinary browser.
This command will turn the lamp on at full brightness:
Summary It seems that TuyaMCU is already well supported. Everything works well with MQTT and Home Assistant (along with both-way communication and status updates), and even allows you to script simple automations within OpenBeken itself.
Soon I will test more devices from TuyaMCU and also add more possibilities for the command interpreter (maybe possibility to execute simple scripts).
PS: And if you are interested in a slightly different dimmer with a different UART protocol (no longer TuyaMCU, but a different text protocol), please read this topic .
A very interesting suggestion. Thanks, I haven't seen this before.
The only thing I do not like is that under the BK7252 password in Google, this topic from the HA forum is second and there is some (fortunately) documentation and SDK ... but this proves that BK7252 is not popular and is not used in many devices. And if it is not popular, it has a lower priority than, for example, support for WiFi systems from Realtek, type WBR3, WBR2, etc.
Well, okay, you convinced me, I bought one A9 mini camera and we'll see what it will be when the package arrives.
@ p.kaczmarek2 Super. I see you put in a lot of effort, there are results and you share them! - You like SoC Beken It is known that producers are looking for savings. BK is cheaper than Realtek and hence the choice. I'm more interested in zigbee devices, but streaming requires something else. The camera is cheap, it has some power, IR and motion detection as well as SD card recording. If we could keep these functionalities and enable integration with HA, it would be a very interesting solution. The picture itself probably does not break anything, but at this price. I just ordered it, so I don't know which converter is there. I would still lack a Lan connection to monitor the parking space in the underground garage, ... but not the cash register.
Have you heard of something like Supla? I recently bought a Nous A1 socket. It was supposed to be a gosund sp111 clone on the ESP8266 / 8285 and there was a BK chip in the middle. What are the differences to esp? Can you upload the firmware from ESP to BK?