Sorry for the delay is posting this. It’s amazing how many projects come up while under lockdown
@dagcant – I’m not sure if the new model is able to be converted with TuyaConvert. The three I have have Wi-Fi dongles that looks like USB sticks, and communicate with a TuyaMCU on the main board. It will be awesome if you are able to convert the new style to Tasmota, but I know the newer style Tuya roller blinds are not convertible. Please let us know. The communication between the Tasmota (ex-Tuya) Wi-Fi dongle and the TuyaMCU are key to the correct functioning of the curtains.
@bule – I flashed the Tasmota firmware to the dongle. On Theo’s site there is some basic instruction where he split it apart and soldered on some wires. I didn’t do that - I was able to flash it using the curtain motor, getting the fast flashing led, and running TuyaConvert (I think… it’s been a while )
The curtains are still working like a charm, btw.
@rexkani At least you didn’t have to wait 2 months… Apologies to @dagcant and @bule
Tasmota uses the dimmer construct to simulate the position of the curtain, and suggests that 1 is closed and 100 is fully open. The other posts I’ve seen all have issues with the curtain switching off when closed with the remote, because the curtain will go all the way to 0. I flipped it around so 100 is closed and 0 is fully open. With some rule magic as well, it stays on now.
OK – Config:
Flash Tasmota on the Wi-Fi dongle using the curtain motor to place it in paring mode (fast flash) - I am using Tasmota firmware: 8.1.0.2
I have the following settings - not sure about all of them, they are a little hard to export so I’ve tried to remember as much as I can, and verified the status of the commands in the console. It should be pretty much complete.
Once the Tasmota firmware is flashed to the dongle, apply the following settings in the console:
template {"NAME":"Zemismart_Curt","GPIO":[0,0,0,0,0,0,0,0,0,108,0,107,0],"FLAG":0,"BASE":54} #You can do through the module editor as welll
tuyaMCU 1,11
tuyaMCU 21,101
dimmerrange 1,100
fade 0
speed 1
power1 1
poweronstate 4
powerretain 1
setoption4 0
topic guest_bedroom_curtains
grouptopic curtains
teleperiod 300
Next, add the Rules and switch them on. All the rules in a set go on one line, separated with spaces, so join all Rule1 and paste into the console, and do the same for Rule2:
Rule1 on Event#OPEN do TuyaSend4 102,01 endon
on Event#STOP do TuyaSend4 102,02 endon
on Event#CLOSE do TuyaSend4 102,00 endon
on TuyaReceived#Data=55AA00070008650200040000000079 do publish stat/guest_bedroom_curtains/RESULT {"Dimmer":0} endon
on POWER1#state!=1 do backlog DIMMER 0; POWER1 1 endon
Rule1 1
Rule2 on dimmer#state=0 do backlog event open; publish stat/guest_bedroom_curtains/RESULT {"Dimmer":0} endon
Rule2 1
The part that’s missing from Thoe’s page are the commands in Rule 1 that mimic the RF remote control: TuyaSend4 102, 01 / 02 / 00
Because the device will switch off when it reaches 0, the device will never send out the MQTT message when it reaches 0, so the fourth line in Rule1 listens for the Tuya event that indices the cover as reached the end stop, and issues the MQTT message. I used this document to decipher the information that the TuyaMCU sends back to Tasmota device - it makes for some fun reading
The last line in Rule 1 ensures that regardless of whether the device switches off or not, it will switch right back on again. On my devices, the power never switches off with this rule.
Rule 2 caters for notifying Home Assistant that the cover is fully open. The MQTT message is never sent due to the device thinking it should switch off at 0. Without this, the curtain will never show as fully open in Home Assistant.
Expect to see a lot of this in the console once setup - it’s the TuyaMCU sending a heartbeat to the Wi-Fi dongle
00:00:00 TYA: Send "55aa00000000ff"
00:00:00 {"TuyaReceived":{"Data":"55AA000000010101","Cmnd":0,"CmndData":"01"}}
00:00:00 TYA: Heartbeat
Okay, so now to setup the cover in Home Assistant:
cover:
- platform: mqtt
name: "Guest Bedroom Curtains"
unique_id: guest_bedroom_curtains
device_class: curtain
command_topic: "cmnd/guest_bedroom_curtains/EVENT"
position_topic: "stat/guest_bedroom_curtains/RESULT"
set_position_template: "{{ ((-100 + position)|int)|abs }}"
set_position_topic: "cmnd/guest_bedroom_curtains/DIMMER"
availability_topic: "tele/guest_bedroom_curtains/LWT"
qos: 1
payload_open: "OPEN"
payload_close: "CLOSE"
payload_stop: "STOP"
position_open: 100
position_closed: 0
payload_available: "Online"
payload_not_available: "Offline"
value_template: "{{ ((-100 + value_json.Dimmer)|int)|abs if value_json.Dimmer is
defined else state_attr('cover.guest_bedrooom_curtains', 'position') }}"
The last line above switches the open/close around so that 100 is closed and 0 is open. I realized afterwards that holding the middle button on the remote for about 5 seconds will switch the direction of the curtain as well. That’s much simpler ;o)
I also found that when Home Assistant is restarted, the position of the curtain goes missing, so I added this automation - it’s good practice to do this for all your MQTT devices:
automation:
- alias: Update State of Tasmotas on HA Restart
trigger:
platform: homeassistant
event: start
action:
- service: mqtt.publish
data:
topic: cmnd/curtains/state
payload: ''
- service: mqtt.publish
data:
topic: cmnd/tasmotas/state
payload: ''
- service: mqtt.publish
data:
topic: cmnd/curtains/state
payload: ''
- service: mqtt.publish
data:
topic: cmnd/shellys/state
payload: ''
- service: mqtt.publish
data:
topic: cmnd/lights/state
payload: ''
Something strange with the quotes in the preformatted text above - just follow regular convention, please. Aaaaannnd, you’re done! Go to Home Assistant and open up your curtains
Hope this is useful for someone. Good Luck - would love some feedback how it goes. Feel free to ask questions and I will try to answer them quicker than than I did these.
UPDATE: My config uses Tasmota 8.1.0.2 and the closed status publishes fine. There may be some updates in later versions that cause issues with publishing the Tuya closed status - thanks @TonyB for the solution. See here for details…