-
Notifications
You must be signed in to change notification settings - Fork 639
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
Kingart curtain switch UI support #2250
Conversation
Added Web UI controls and view in status Added power up behaviour (nothing, close, open, last position) Added curtain style (Roller, etc...) for UI status and to be used in MQTT
…ling position from received messages. Added comment to debug tab to show how to enable debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
- If you don't mind going over code comments once more, please verify that those still apply.
- We should explain magic numbers in code (and, if possible, in log too). I've added some helpers for getSetting() 2nd arg, we can map any type from string. see
namespace settings { namespace internal
in relays / buttons / sensors. - We don't enforce any specific style / formatting... But one thing I am not a fan of is
if (cond) expr;
, unless those are one-liners likeif (something) return;
. Having brackets is preferable.
Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
Added public set position function and curtain count
…ot (00:00 after refresh). Default Hour is 12h
Schedule support. Light support is having an issue with new schedules corrected here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's think a bit more about the scheduler stuff? I am not sure restoring works like that, but I'd expect normal operation mode does. This can be a separate patch, not to complicate things further.
If you are ok with kingart .cpp stuff, I'll reformat it for the merge.
@@ -311,7 +337,7 @@ void schSetup() { | |||
|
|||
static bool restore_once = true; | |||
if (restore_once) { | |||
for (unsigned char i = 0; i < relayCount(); i++) { | |||
for (unsigned char i = 0; i < schedulableCount(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this step on schCheck id resolution? If we have 1 relay and 1 curtain, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done a big answer and as a result:
So the quick answer is that I tested all with a dummy switch in hardware.h and you can choose between both types and it works:
Switch and curtain schedule task worked.
This is how the light schedule bug has been detected (it stays as a switch schedule instead of light schedule)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific block, schCheck will recursively check every 'rule' that uses specific relayID (index from old relayCount()) and goes back a week day-by-day to check if rule applies in the past.
Although, we don't count light channels, so it's still sort-of broken because of non-matching ID / indexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood! In fact, we need specific processing for curtain.
Great work you are doing Eric, your work makes the Curtain switch usable for many people that are not using it only over MQTT. I did not have the knowledge and time to build the web interface so I took off after MQTT was finished and my 9 shutters where moving the way I wanted them to move. In your code I fount this: I can confirm it is mandatory to confirm to the N76E003AT20 that every message send by it is received. When I started working on it I found that after power up the switch it takes about 30sec before the N76E003AT20 starts sending messages (just not log enough to flash the ESP) so at first I had jumpers on the data lines to disconnect both chips from each other and be able to flash ESPURNA. After silencing the N76E003AT20 flashing is possible. Now a day's we have to OTA flash in two stages this is possible as long the N76E003AT20 stay's quiet after a power cycle flashing is not possible anymore as the N76E003AT20 is corrupting the flash process. I have been logging communication between both chips with the original software for quite some time to fully understand how it works. |
re. some discussions in the Core repository and general observations about reboot. |
b.t.w. Flashing over serial also fails as the N76E003AT20 starts sending data during flashing. This can be solved by holding it's pin 4 or on the rear side of the board RES1 to GND this keeps the N76E003AT20 in reset state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging as-is b/c curtain part is done, delaying scheduler changes (?) for later.
@AlbertWeterings the solution I found is to calibrate the curtain to a very long period for intial flash so the MCU does not send messages until the closed position is not reached. Do you confirm that this is the AT+UPDATE message "setclose":0 "switch":"off" sent at the end of the first move which breaks the update? If so, just calibrate curtain opening to > 60s - this will be enough to keep MCU quiet. |
@echauvet This is a nice work around at the moment you are blocked from flashing after something went wrong. I think good to document. I preferer to silence the MCU in the software by confirming the last message is understood. I did a quick test, you can preform a OTA 2 stage update without problems when ESP is rebooting the MCU doesn't. Only if someone is touching the buttons the MCU starts repeating it's last message and flashing is not possible. Disabling the serial port during OTA flash procedure as @mcspr referred to is the best sollution. |
This is a preliminary commit to extend KA work by @AlbertWeterings. Using AT+START commands, we know the real position of the curtain. Small MCU bugs are bypassed as commented in the code.
The UI is animated and displays :
A configuration panel as been created to choose:
Next steps are code cleaning, integrate any reviews from contributors and improve the MQTT stack with RedNode. For now, I can drive my curtain as a Google curtain, or a switch or a lamp bulb (for brightness setting). I'm preparing some demo flow with Google legacy curtain, and the hybrid solution.
Both core base and latest-base are working - with latest-base, a two steps upgrade is required.
I'm cheking the work done for OTA in RedNode to check if some code is ready for 2 steps upgrade.
All Tests has been done using a curtain switch, espurna UI, google home and RedNode UI and all seems to animate together without bugs.