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

New Device: King Art - King Q4 Cover switch #5059

Closed
seea2005 opened this issue Jan 29, 2019 · 116 comments
Closed

New Device: King Art - King Q4 Cover switch #5059

seea2005 opened this issue Jan 29, 2019 · 116 comments
Labels
requested feature (hold over) Result - Feature that will not be added soon (out of scope)

Comments

@seea2005
Copy link

seea2005 commented Jan 29, 2019

I would like to control by MQTT two cover switch which are shown on ewelink as king Q4:

https://es.aliexpress.com/item/EWeLink-App-UE-Reino-Unido-Wifi-Smart-Touch-cortina-interruptor-de-Control-de-voz-por-Alexa/32956776611.html?spm=a2g0s.9042311.0.0.3fc163c0VL8sRB

From ewelink we can:

  • Open (state of device --> ON)
  • Close (state of device --> OFF)
  • Stop (state of device --> Pause)
  • Set a position (attribute setclose --> between 0 and 100)

Don't know really what else I have to send to develop it.

The device:

img_20190129_125152

img_20190129_125139

That's the board:

img_20190129_122547

img_20190129_122531

Thanks!

@Jason2866
Copy link
Collaborator

Sorry, same answer as in #5057 (comment)

@andrethomas2 andrethomas2 added Currently unsupported device requested feature (hold over) Result - Feature that will not be added soon (out of scope) labels Jan 29, 2019
@andrethomas2
Copy link
Collaborator

It's difficult to add support for these unless someone with coding experience can get their hands on a physical device to figure out how it could fit into Tasmota.

Closing it for now but users can still post here if there is more information forthcoming.

Support Information

See Wiki for more information.
See Chat for more user experience.

@mclaudiopt
Copy link

hi. anyone knows the correct wiring for flashing? there are 2 3.3v and 2 gnd :-(

@DoraDeu
Copy link

DoraDeu commented Aug 23, 2019

Flashing is easy. At the last picture you see on the upper half the pins you need:
3.3V
RX
TX
GND
SW (is connected to GPIO0)

Then the normal procedure: Connect SW to GND at power on time and the device is in flash mode.
But I am still looking for the right setup of Tasmota for this device. (GPIO assignment and configuration).

@AWiseAd
Copy link

AWiseAd commented Oct 21, 2019

I managed to flash the device with Tasmota like above. What I was able to discover:

  1. There is a separate MCU taking care of most local functionality:
  • Control of the touch buttons
  • Steering the relays
  • Managing timing
  • Reporting the status
  1. The MCU communicates throught Rx.Tx, with commands like:
  • AT+UPDATE="switch":"on","setclose":0 (open button 1 pressed, current cover position = 0)
  • AT+UPDATE="switch":"off","setclose":100 (close button 3 pressed, current cover position = 100)
  • AT+UPDATE="switch":"pause","setclose":91 (pause button 2 pressed, current cover pos =91)
  1. The status of the cover is reported every ~10 sec, with messages as above.

As I flashed the device with tasmota I lost the communication from the ESP to the other MCU and have not been able to extract the commands to control the MCU. I expect it to be a similar command protocol (i.e. AT+.... ="switch":".....","setclose":...) but trial and error did not prove it.

Is anybody with an 'original' device able to find the commands from ESP to the MCU?
Connection is like @DoraDeu wrote on Aug 23. Serial speed to 19200.

@DoraDeu
Copy link

DoraDeu commented Oct 21, 2019

Sounds interesting!
Unfortunately I have just this device that I already flashed with Tasmota. Would it help to check if I saved the original firmware before flashing?

@AWiseAd
Copy link

AWiseAd commented Oct 21, 2019

If you are able to flash the original again, you could read the Serial commands by sending the Ewlink commands and monitor the Tx/Rx

@acrmelo
Copy link

acrmelo commented Oct 27, 2019

I can not flash it and I have 4 devices with original firmware, can you help?
Tx and Rx just flash bit (5%) if I set baudrate to 19200.
I connect sw to GND. maybe I am flashing the separate MCU?!?

Thanks
kingart

@Jason2866
Copy link
Collaborator

Probably, RESI is wrong.

@AWiseAd
Copy link

AWiseAd commented Oct 28, 2019

Like @Jason2866 said, RESI is wrong. SW is should be connected to ground to flash. Also you should set the baudrate for flashing high. The co processor grabs the Rx/Tx line after ~30 seconds. The flashing should complete before that takes place.

Before you flash them all, can you 'snif' the Rx/Tx commands between the co-processor and ESP.. ?

@acrmelo
Copy link

acrmelo commented Oct 29, 2019

What do you mean RESet1 is wrong? I connect SW to GND on boot (1 second only) and RES1 always to GND. Set baudrate to high 115200 but no flashing.
My sonoff.bin file is less than 500kb and tried with DIO and DOUT no luck...
(PS: flashing sonoff bridge only works with DOUT and never with DIO, don't know why)

Setting back to 19200 and I see commands from MCU to ESP like this when I push touch buttons:

AT+UPDATE="switch":"off","setclose":0
AT+UPDATE="switch":"off","setclose":32
(...)
AT+UPDATE="switch":"pause","setclose":86
(...)
AT+UPDATE="switch":"on","setclose":100
AT+UPDATE="switch":"on","setclose":0

Tomorrow with more time, I will get a fresh device, configure it on ewelink and snif the comms from ewelink and come back and post the results.

PS: I'm newbie to this flashing scene, till now just flashed ok one esp01-relay, one sonoff bridge and one mini.

Thanks for your help

@AWiseAd
Copy link

AWiseAd commented Oct 29, 2019

I have flashed the device with NodeMCU Pyflasher. Settings: baud '230400' ; Mode: DOUT ; Wipe all data. During flashing the SW soldered to GND. I did not connect RES1 (but this could be fine, don't know). The device seems to be very close to the King Art dimmer (PS-16-DZ Module). When using the PS-16-DZ template I can switch the cover to open/ close (on/off).
this corresponds to the "AT+UPDATE="switch":"on".
(Tasmota PS-16-DZ sends: "AT+UPDATE="sequence":"1572363888114","switch":"off","bright":25,"mode":1,
"colorR":255,"colorG":255,"colorB":255,"light_types":1). Probably sending sending a "setclose":20 will set the cover to 20%.

image

@acrmelo
Copy link

acrmelo commented Oct 31, 2019

The protocol I have found is something like this (I only capable of snif one comm at a time):

(power on)
ESP>AT+START[1B]

(send open from ewelink)
ESP>AT+UPDATE="sequence":"1572536577552","switch":"on"[1B]
MCU>AT+RESULT="sequence":"1572536188859"[1B]
ESP>AT+SEND=ok[1B]
(...window opening...)

(send pause from ewelink)
ESP>AT+UPDATE="sequence":"1572536601645","switch":"pause"[1B]
MCU>AT+RESULT="sequence":"1572536191808"[1B]
ESP>AT+SEND=ok[1B]
MCU>AT+UPDATE="switch":"pause","setclose":15[1B]
ESP>AT+SEND=ok[1B]

(send close from ewelink)
ESP>AT+UPDATE="sequence":"1572536766275","switch":"off"[1B]
MCU>AT+RESULT="sequence":"1572536191808"[1B]
ESP>AT+SEND=ok[1B]
(...window fully closed)
MCU>AT+UPDATE="switch":"off","setclose":100[1B]

(set to 63% in ewelink)
ESP>AT+UPDATE="sequence":"1572536873586","setclose":63[1B]
MCU>AT+RESULT="sequence":"1572537093019"[1B]
ESP>AT+SEND=ok[1B]
(... window openig to until 63%)
MCU>AT+UPDATE="switch":"on","setclose":63[1B]
ESP>AT+SEND=ok[1B]

(set to 80% in ewelink)
ESP>AT+UPDATE="sequence":"1572536873586","setclose":80[1B]
MCU>AT+RESULT="sequence":"1572537093019"[1B]
ESP>AT+SEND=ok[1B]
(... window closing to until 80%)
MCU>AT+UPDATE="switch":"off","setclose":80[1B]
ESP>AT+SEND=ok[1B]

Notes:

  1. At power on I don't know if START cmd is necessary
  2. EOL is ESC char 0x1B
  3. Sequences values are a timestamps but are wrong in this example, because I snif only one direction each time
  4. Physical touch buttons on MCU send command as I stated before.
  5. I will try to emulate this with tasmota but I still don't have a working device.

Hope this helps.

@acrmelo
Copy link

acrmelo commented Oct 31, 2019

Good news...
My flshing does not work because I defined on device a very small running time for curtains to go 100% and that was stopping flash procedure.
After flashing tasmota all commands worked ok...

Use this on console...
Baudrate 19200
SerialDelimiter 27

(turn on)
SerialSend2 AT+UPDATE="sequence":"1572542635565","switch":"on"
(turn off)
SerialSend2 AT+UPDATE="sequence":"1572542635565","switch":"off"
(pause)
SerialSend2 AT+UPDATE="sequence":"1572542635565","switch":"pause"
(move to XX)
SerialSend2 AT+UPDATE="sequence":"1572542635565","setclose":XX

The MCU retry each 10s the last message waiting for a "SerialSend2 AT+SEND=ok".

Anyone knows how to create the final template and rules? And also process the MCU messages to update the tasmota state.

Many thanks

@voodooo82
Copy link

I have the same switch curtain, I've flash with tasmota and only solution for use this switch is with sonoff t1 3ch mode but only with button...

@corvidus
Copy link

corvidus commented Dec 1, 2019

I went through much the same process as @AWiseAd, @acrmelo elo et al based on suggestions on the espurna board. Taking that information and reverse-engineering the PS-16-DZ driver (effectively removing non-relevant commands and changing the serial commands used) I knocked this together to replicate the Dimmer behaviour, but sending the shutter commands. It will need thorough checking by someone who knows these things better than me, but hopefully I've made it a little easier?

Re: template, this is what I've been using in testing. Only change from PS-16-DZ is inverting the LED at GPIO13. You could probably re-do it based on Generic with the SendSerial commands sent as Rules, but I haven't got that far.

{"NAME":"KingArt Cover","GPIO":[255,148,255,149,255,255,0,0,255,56,255,255,255],"FLAG":0,"BASE":58}

Hope that all helps.

xdrv_99_ka_cover.txt

@acrmelo
Copy link

acrmelo commented Dec 5, 2019

Thanks for helping, @corvidus can you send the precompiled .bin so I test it on my devices?

Thanks again...

acrmelo

@acrmelo
Copy link

acrmelo commented Dec 7, 2019

I worked a bit on the code and removed the button function and leave only de dimmer. Maybe if pause is really need can be done with rules. I replaced completely xdrv_19_ps16dz_dimmer.ino file with my code.

So I have my 5 kingart curtains with this new code. I use node red to connect to a dashboard and to google assistant.

Hope someone with more skills in tasmota to help a final version.

PS: Flash minimal tasmota first to make room for this 562kb .bin file.

Happy holidays 4u all.
ka-curtain.zip

@erelor
Copy link

erelor commented Dec 12, 2019

I confirm the acrmelo firmware works very well also with openhab and MQTT!
It will be great if this new device will be added to official Tasmota

@voodooo82
Copy link

Is possible convert to .bin?

@acrmelo
Copy link

acrmelo commented Dec 19, 2019

Hi again,

@voodooo82 bin is in zip file.

Now I added a dummy relay to control pause, changing template to:
{"NAME":"KingArt Curtai","GPIO":[255,148,255,149,255,255,0,0,255,56,255,255,21],"FLAG":0,"BASE":58}

On console add this rule:
rule1 on Power1#State=1 do backlog SerialSend2 AT+UPDATE="sequence":"1576774195000","switch":"pause" ; power1 0 endon

And activate it:
rule1 1

I now can use MQTT to send dimmer:
cmnd/<yourtopic>/dimmer <position>

And to pause with:
cmnd/<youttopic>/power1 1

@voodooo82
Copy link

Screenshot_20191219_213934_com android chrome
Command unknow

@acrmelo
Copy link

acrmelo commented Dec 20, 2019

Hi,

Command starts in "rule1..." all to "endon"

rule1 on Power1#State=1 do backlog SerialSend2 AT+UPDATE="sequence":"1576774195000","switch":"pause" ; power1 0 endon

This is not the best way to do it, but is the only I know ;)

Good luck

@voodooo82
Copy link

Thanks is very good 😍😍😍😍

@jonhgaspar
Copy link

I worked a bit on the code and removed the button function and leave only de dimmer. Maybe if pause is really need can be done with rules. I replaced completely xdrv_19_ps16dz_dimmer.ino file with my code.

So I have my 5 kingart curtains with this new code. I use node red to connect to a dashboard and to google assistant.

Hope someone with more skills in tasmota to help a final version.

PS: Flash minimal tasmota first to make room for this 562kb .bin file.

Happy holidays 4u all.
ka-curtain.zip

is there a possibility to turn the LED's on and off the buttons?
Currently only WIFI is possible

@acrmelo
Copy link

acrmelo commented Feb 5, 2020

I worked a bit on the code and removed the button function and leave only de dimmer. Maybe if pause is really need can be done with rules. I replaced completely xdrv_19_ps16dz_dimmer.ino file with my code.
So I have my 5 kingart curtains with this new code. I use node red to connect to a dashboard and to google assistant.
Hope someone with more skills in tasmota to help a final version.
PS: Flash minimal tasmota first to make room for this 562kb .bin file.
Happy holidays 4u all.
ka-curtain.zip

is there a possibility to turn the LED's on and off the buttons?
Currently only WIFI is possible

WiFi led is connected to ESP and can be controlled, but led buttons are controlled by the MCU and I think there is no way changed it.

@4139GGN
Copy link

4139GGN commented May 12, 2022

No need to cut wires, put res1 on ground to block coprocessor.

Only Rx, tx, Res1 and Gnd?

@alsacian
Copy link

3.3v to 3.3v
Gnd to Gnd
Sw to Gnd
Res1 to Gnd
Tx to Tx
Rx to Rx

@4139GGN
Copy link

4139GGN commented May 20, 2022

3.3v to 3.3v Gnd to Gnd Sw to Gnd Res1 to Gnd Tx to Tx Rx to Rx
In tasmotizer it tells me that it can't find the ESP8266 :(
pcb

@barbudor
Copy link
Contributor

Could be TX to RX and RX to TX depending on your adapter

@4139GGN
Copy link

4139GGN commented May 20, 2022

I already have it working! :D
Now what I don't know is how to put a bar, for example with a percentage for HomeAssistant and/or a button to go up and down.
Thank you!

@4139GGN
Copy link

4139GGN commented May 23, 2022

I need help to install the dimmer in HA.

@4139GGN
Copy link

4139GGN commented May 26, 2022

Captura de pantalla 2022-05-26 a las 14 12 49
Captura de pantalla 2022-05-26 a las 14 12 58
Captura de pantalla 2022-05-26 a las 14 16 17
Captura de pantalla 2022-05-26 a las 14 16 05

From here I can't get past... Also, the sensor doesn't give the real value...

@alsacian
Copy link

Check my code, everything is in the zip file.
This device is not working well with tasmota.

@4139GGN
Copy link

4139GGN commented May 27, 2022

Check my code, everything is in the zip file. This device is not working well with tasmota.

.ino, what flashed it with arduino?

@alsacian
Copy link

Yes

@4139GGN
Copy link

4139GGN commented May 28, 2022

Yes

Thank you!
It's already flashed with Arduino and it seems to be ok. But how do I configure now?
I see that it has connected to my web, and I even see it on the MQTT network. But only: "LWT = Online"

@alsacian
Copy link

OK,
In my code the shutter name is LivingShutter, you have to change it everywhere for your needs, ino file, configuration.yaml....
Not forget to change ssid, password and mqtt server in ino file
mqtt needs username and password now, change ino file line to:
if (client.connect(device, "mqttuser", "mqttpassword", device_state, 1, false, "OFF"))
Install Shutter Card with HACS
In Lovelace add card with this code:

type: 'custom:shutter-card'
title: Living Shutter
entities:

  • entity: cover.living_shutter
    name: Living Shutter

In configuration.yaml add:

cover:

  • platform: mqtt
    device_class: shutter
    name: "Living Shutter"
    command_topic: "LivingShutterC"
    state_topic: "LivingShutterS"
    position_topic: "LivingShutterP"
    set_position_topic: "LivingShutterV"
    availability_topic: "LivingShutter/State"
    qos: 1
    retain: false
    payload_open: "OPEN"
    payload_close: "CLOSE"
    payload_stop: "STOP"
    state_open: "open"
    state_opening: "opening"
    state_closed: "closed"
    state_closing: "closing"
    state_stopped: "stopped"
    payload_available: "ON"
    payload_not_available: "OFF"

restart home assistant and everything should be working
change percentsec (10 for 10 seconds, 5 for 20 seconds) relative to your opening time, this is needed for shutter animation in lovelace
LivingShutter/Strength: mqtt message for wifi signal strength
LivingShutter/State: mqtt message for device state, ON or OFF
All informations are in ino file header

@alsacian
Copy link

Sorry, the two dots before entity and platform for indentation are added by github editor, don't put them

@4139GGN
Copy link

4139GGN commented May 30, 2022

I think I'm not doing something right on the arduino.
I have put "erase all flash content" to remove the wifi options as well. But it keeps connecting to wifi and it doesn't show up in mqtt explorer...
I already have the card installed! And I even use it with the original software. But I can't find the entity that I have flashed with this code.
And the data is well placed. I only have to ask; How do I make sure of the device name? Can I change in the .ino the name with which it connects to the wifi network?
Thank you!

@alsacian
Copy link

If it is connected to WiFi, you have to make sure the mqtt broker ip, mqtt user and password are ok. You can change everything in the ino as long as it is the same in home assistant.

@4139GGN
Copy link

4139GGN commented Jun 3, 2022

I'm doing something wrong when I change the name... By doing it with the name that comes in the project, I can handle it. But inverted. It goes up when it goes down and vice versa. Looking for solution! :D

@alsacian
Copy link

alsacian commented Jun 3, 2022

This time easy 😉
Add last line

type: custom:shutter-card
title: Volets Roulants
entities:

  • entity: cover.terrace_shutter
    name: Volet Terrasse
    invert_percentage: true

@4139GGN
Copy link

4139GGN commented Jun 4, 2022

Okay! Working ok with "LivingShutter" and inverted :D
Now, I ask: Why don't I see it in HA devices or entities?
For example to make an automation at dawn.
Thank you for your work alsatian!

@alsacian
Copy link

alsacian commented Jun 4, 2022

You are welcome
You have services associated with the cover
Automation example :

alias: Rollershutters Sunset Close
description: ''
trigger:

  • platform: sun
    event: sunset
    offset: '00:30:00'
    condition: []
    action:
  • service: cover.close_cover
    target:
    entity_id: cover.terrace_shutter
    data: {}
    mode: single

@Apacelus
Copy link

Apacelus commented Jun 7, 2022

Some small non-Tasmota code for Home Assistant

KING-ART-Q4_MQTT_OTA.zip

@alsacian What is one supposed to do with this file? How does one flash it? Or am I supposed to connect an arduino to the board and then use the arduino instead of the esp built-in controller?

Am I supposed to compile it as bin and then flash it to the esp?

@Apacelus
Copy link

Apacelus commented Jun 9, 2022

I worked a bit on the code and removed the button function and leave only de dimmer. Maybe if pause is really need can be done with rules. I replaced completely xdrv_19_ps16dz_dimmer.ino file with my code.

So I have my 5 kingart curtains with this new code. I use node red to connect to a dashboard and to google assistant.

Hope someone with more skills in tasmota to help a final version.

PS: Flash minimal tasmota first to make room for this 562kb .bin file.

Happy holidays 4u all. ka-curtain.zip

Hey @acrmelo that bin you compiled is based on tasmota version 7.somthing, which is pretty old and doesnt integrate with home assistant. Could you recompile it for the latest version?

@4139GGN
Copy link

4139GGN commented Jun 15, 2022

Well, I don't know what's going on because it's been connected to Wi-Fi for a while, but it's not available in HA.

@4139GGN
Copy link

4139GGN commented Jul 11, 2022

At times, it appears and disappears. But without disconnecting from the wifi network.
In the state of the capture, I am not able to find it in home assistan
Captura de pantalla 2022-07-11 a las 13 56 18
t

@4139GGN
Copy link

4139GGN commented Jul 31, 2022

Check my code, everything is in the zip file. This device is not working well with tasmota.
Captura de pantalla 2022-07-31 a las 17 33 07
what could happen? And could you turn on the led as before?

@4139GGN
Copy link

4139GGN commented Sep 20, 2022

Well... I keep trying!
So far, what I have managed to do is flash Tasmota 11 in KingArt Q4 and apply the template PS-16-DZ (58) to it.
For now, I open full and close. But I can't use the dimmer.
"rule1 on Power1#State=1 do backlog SerialSend2 AT+UPDATE="sequence":"1576774195000","switch":"pause" ; power1 0 endon"
He answers me with:
"Stored uncompressed, would compress from 111 to 91 (-18%)".
All this from Tasmota.
In HA-Settings-integrations-Tasmota find the device. But I can't do anything with it. It appears as a switch, but shaded.
I can only use the "visit" button to go to Tasmota.
Any help?

@michal197609
Copy link

Hello,
do you have a new config for Tasmota 12.3.1(lite) ? I use King Art Q4 Curtai.
I need step by step guide.
Thank you.

@voodooo82
Copy link

Hello, do you have a new config for Tasmota 12.3.1(lite) ? I use King Art Q4 Curtai. I need step by step guide. Thank you.

But now tasmota not working with this device?
https://templates.blakadder.com/kingart_KING-Q4.html

@michal197609
Copy link

Hello, do you have a new config for Tasmota 12.3.1(lite) ? I use King Art Q4 Curtai. I need step by step guide. Thank you.

But now tasmota not working with this device? https://templates.blakadder.com/kingart_KING-Q4.html
No, unfortunately not

@michal197609
Copy link

michal197609 commented Jan 29, 2023

Well... I keep trying! So far, what I have managed to do is flash Tasmota 11 in KingArt Q4 and apply the template PS-16-DZ (58) to it. For now, I open full and close. But I can't use the dimmer. "rule1 on Power1#State=1 do backlog SerialSend2 AT+UPDATE="sequence":"1576774195000","switch":"pause" ; power1 0 endon" He answers me with: "Stored uncompressed, would compress from 111 to 91 (-18%)". All this from Tasmota. In HA-Settings-integrations-Tasmota find the device. But I can't do anything with it. It appears as a switch, but shaded. I can only use the "visit" button to go to Tasmota. Any help?

have you used new ka-curtain image ? Could you please give us this?

@4139GGN
Copy link

4139GGN commented Feb 10, 2023

have you used new ka-curtain image ? Could you please give us this?

The truth is that I have not made any progress on this topic. I read and try from time to time some change. But I get nothing.
I tried ka-curtain. But I couldn't get it to connect with mosquito either...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requested feature (hold over) Result - Feature that will not be added soon (out of scope)
Projects
None yet
Development

No branches or pull requests