>D | |
sw=0 | |
tmp=0 | |
cnt=0 | |
tmr=0 | |
hold=0 | |
powert=0 | |
slider=0 | |
dim="" | |
shortprl=2 ;short press lo limit | |
shortpru=10;short press up limit | |
dimdir=0 ;dim direction 0/1 | |
dimmlp=2.2 ;dim multiplier 1..2.55 | |
dimstp=2 ;dim step/speed 1..5 | |
dimll=15 ;dim lower limit min. 0 | |
dimul=95 ;dim upper limit max. 100 | |
dimval=70 ;start dim level 0..100 | |
>B | |
=>print > WiFi-Dimmer-Script-v1.0 < | |
=>Counter1 0 | |
=>Baudrate 9600 | |
; boot sequence | |
=#senddim(dimval) | |
delay(1000) | |
=#senddim(0) | |
>F | |
cnt=pc[1] | |
if chg[cnt]>0 | |
; sw pressed | |
then sw=1 | |
else sw=0 | |
; sw not pressed | |
endif | |
; 100ms timer | |
tmr+=1 | |
; short press | |
if sw==0 | |
and tmr>shortprl | |
and tmr<shortpru | |
then | |
powert^=1 | |
; change light on/off | |
if powert==1 | |
then | |
=#senddim(dimval) | |
else | |
=#senddim(0) | |
endif | |
endif | |
; long press | |
if sw>0 | |
then | |
if hold==0 | |
then | |
; change dim direction | |
dimdir^=1 | |
endif | |
if tmr>shortpru | |
then | |
hold=1 | |
if powert>0 | |
; dim when on & hold | |
then | |
if dimdir>0 | |
then | |
; increase dim level | |
dimval+=dimstp | |
if dimval>dimul | |
then | |
; upper limit | |
dimval=dimul | |
endif | |
=#senddim(dimval) | |
else | |
; decrease dim level | |
dimval-=dimstp | |
if dimval<dimll | |
then | |
; lower limit | |
dimval=dimll | |
endif | |
=#senddim(dimval) | |
endif | |
endif | |
endif | |
else | |
tmr=0 | |
hold=0 | |
endif | |
>E | |
slider=Dimmer | |
; slider change | |
if chg[slider]>0 | |
then | |
; dim according slider | |
if slider>0 | |
then | |
dimval=slider | |
else | |
powert=0 | |
endif | |
endif | |
if pwr[1]==1 | |
; on/off webui | |
then | |
powert=1 | |
=#senddim(dimval) | |
else | |
powert=0 | |
=#senddim(0) | |
endif | |
; subroutine dim | |
#senddim(tmp) | |
dim="FF55"+hn(tmp*dimmlp)+"05DC0A" | |
=>SerialSend5 %dim% | |
=>Dimmer %tmp% | |
# |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for the script. I modified it a bit. I fixed a bug that did not allow me to turn on the dimmer immediately with the desired brightness by wifi. And he did so that after turning off the power, the previously set brightness was restored. Unfortunately, I do not know how to put the code here so that the site does not spoil it. Well, at least so:
; 100ms timer ; long press
if pwr[1]==1 ; subroutine dim |
This comment has been minimized.
This comment has been minimized.
Thanks @askold2, personally, I don't like "Light ON" after power failure / reset / restart... |
This comment has been minimized.
This comment has been minimized.
There is a PowerOnState command for this. It works great in my version of the script. |
This comment has been minimized.
This comment has been minimized.
Great work! Thanks for the script. When powered off, the attached light bulb (halogen 40w E27 screw fitting) sometimes starts to glow faintly. I fixed this by adding a few lines to the script and by basically repeating the serial command every few seconds when in off state. Looks like whenever the ESP MCU is transmitting over wifi, this somehow influences the secondary MCU. |
This comment has been minimized.
This comment has been minimized.
Out of interest, what have people seen their loadAvg to be when using this solution? My devices are working fine - and when off, the loadAvg is very low. But when the light is on, the loadAvg rises to 999 and stays there: 22:34:19 MQT: light/tele/STATE = {"Time":"2019-11-21T22:34:19","Uptime":"0T01:20:15","UptimeSec":4815,"Heap":27,"SleepMode":"Normal","Sleep":250,"LoadAvg":3,"MqttCount":1,"POWER":"OFF","Dimmer":0,"Fade":"OFF","Speed":1,"LedTable":"ON","Wifi":{"AP":1,"SSId":"xxxxxx","BSSId":"xxxxxxx","Channel":11,"RSSI":48,"LinkCount":1,"Downtime":"0T00:00:10"}} Turned light on, then... 22:44:24 MQT: hall_light/tele/STATE = {"Time":"2019-11-21T22:44:24","Uptime":"0T01:30:20","UptimeSec":5420,"Heap":27,"SleepMode":"Normal","Sleep":0,"LoadAvg":273,"MqttCount":2,"POWER":"ON","Dimmer":70,"Fade":"OFF","Speed":1,"LedTable":"ON","Wifi":{"AP":1,"SSId":"xxxx","BSSId":"xxxx","Channel":11,"RSSI":48,"LinkCount":1,"Downtime":"0T00:00:10"}} This doesn't seem to affect performance.... |
This comment has been minimized.
This comment has been minimized.
@thxthx0 this is great! Yesterday I reflashed a Tuya dimmer OTA with tuya-convert. Worked like expected (did some Tuya switches before). Then upgrade to newest version (OTA, thehackbox.org) and uploaded the scriptenabled Tasmota (https://github.com/arendst/Tasmota/files/3776333/Tasmota-v7.0.0.1-w-Scripting-2.6.x-1MB.zip) to one of my own servers (took the .bin out of it). Upgraded (OTA) to that version and the device was 'bricked'. So, took a soldering iron, opened the box en flashed it using serial. Tried upgrading using 'file upload' and got an error. THEN I used Google (should have done that before) and 'upgraded' to the minimal version of Tasmota FIRST and the uploaded the scriptable version. That is running fine now! I still have to template the device, run the script and make it MQTT, but some questions first:
|
This comment has been minimized.
This comment has been minimized.
@keesdekraker @dbrb2 in new Tasmota 7.0.0.6 version it shows "LoadAvg":99 instead of 999 The temperature and power consumption of the ESP8266 doesn't really increase,
I'm afraid it's because of changing Cores (2.6.0 -> 2.6.1 -> pre2.6)
|
This comment has been minimized.
This comment has been minimized.
Hej, I would like to thank you as well. I have 8 dimmers and 7 of them have done spooky things like turning off without any action taken or glowing like @keesdekraker reported above. Only an accidentically WLAN-Downtime solved this problems. But ok, a Wifi Dimmer that only works if Wifi is off doesn't make a lot of sense or fun.....based on your and blakaddder great work I was able to flash them via tuya-convert and adding your script.....what should I say: Working, no problems!! As an addditional info: The linked firmware can't be flashed via OTA/tuya-convert as it is greater than 512kb which is the maximum for OTA (half of the flash). I have compiled the actual 7.0.0.6 version on Gitpod with scripting, mqtt, Hue, web & timers included which is below 512kb so that I can be flashed via tuya-convert/OTA. If anybody is interested, let me know. Thanks again |
This comment has been minimized.
This comment has been minimized.
ah, just forgotten: I know what the variable powert does, but could you tell what powert stands for? regs |
This comment has been minimized.
This comment has been minimized.
@sqw534, I have resolved the issue by reverting back to a Tasmota build from the current master branche. I am very interested in your precompiled binary file. Could you share this bin file plz? BTW: there is a minimal pre-compiled version of Tasmota, which can be used for two step OTA. |
This comment has been minimized.
This comment has been minimized.
@sqw534, I'm also very interested in your pre-compiled version 7.0.0.6. I had MAJOR stability issues (WiFi?) with the supplied Tasmota-v7.0.0.1-w-Scripting-2.6.x-1MB.zip. Using GetPod I compiled a 6.7.1 (2.3.0 core) version and running tests on a Sonoff Basic now. Because I kept losing connection with the Tuya Dimmer using 7.0.0.1 it took a lot of time and I need to be sure that my version (using GitPod for the first time) is stable enough to use it on the Dimmer. |
This comment has been minimized.
This comment has been minimized.
@sqw534, are you still running your build without any stability or dimming issues? Could you share your build? I really could ue some good news, as this dimmer is giving me quite a few headaches. |
This comment has been minimized.
This comment has been minimized.
Hej, @keesdekraker & @RalphMeuse: Yes, I am still running the build and will share it. I also have added the ability to dim up if the dimmer is off and fading on/off to the script. Will share this as well. This is only tested on the QS-Wifi D01 Dimmer (https://blakadder.github.io/templates/qs-wifi_D01_dimmer.html) So I can‘t tell you if it it is working on other tuya dimmer. @RalphMeuse: Yes I have compiled mqtt and scripting and Hue within the build. Hue is unfortunately not stable when using Alexa. I just have tried to recompile my 7.0.0.6 version, but it fails on gitpod. So I have recompiled it on 7.1.1.1. First tests runs ok but no long term tests right now... I have compiled it without any wifi settings, so device will come up in AP mode. Just connect to the Wifi tasmota-xxxx and open http://192.168.4.1. You now can connect it to your own Wifi. Device will use DHCP so you have to find your local IP after the reboot. (ping tasmota-xxxx worked in my environment) I have added the file my_user_config.h as well, so if you want to change the bin or preconfigure your Wifi/IP on gitpod (Have a look at: https://github.com/arendst/Tasmota/wiki/Compiling-Tasmota-on-Gitpod) just upload this one. I described the steps a little bit more detailed, just in case somebody else find this post.. Would be great if you could share, if this runs for you or otherwise share your device type and the misbehaviour. We might can work together on this. Files are located here: Enjoy testing... |
This comment has been minimized.
This comment has been minimized.
@RalphMeuse Just to answer your other questions: I do not use HomeAssitent, I am on openhab, so I can't help you on the configuration. Mqtt is enabled within the bin. So you could use it. I have read something about the LSC while searching on the dimmer. There should already be some information around, but can't point you to a specific link. Best regards |
This comment has been minimized.
This comment has been minimized.
@sqw534 MANY thanks for sharing. I hope to find time in the weekend to try it. The last week I invested (many and frustrating) hours to find what the problem with my device is. I think I found my problem: if the WiFi signal is low, the minute I activate PWM1 on GPIO14 (or GPIO2 for that matter) I loose connection to the device. I have to move it closer to the WiFi point and issue some http:... cm?cmnd=reset 5 to reset the device so the PWM is deactivated and then the WiFi runs fine again. The device is a 'real' QS-WiFi-D01-TRIAC (from MOES). I read somewhere that the 'clones' have WiFi stability issues when (software) PWM is used. So, the next question is: do I have to active a PWM at all? Or will it work without it, because of the separate CPU? And will MQTT work automatically then (probably not) or should I implement that in the script? I'm very willing to share. I have to find the time to test and also ordered some more devices, in case I brick one... I have 5 of these dimmers in my house (next to about 20 switches) and it would be GREAT if working with MQTT/HA, because the time delay from Tuya to HA when the state changes is between 5 and 30 seconds. And my wife has the same feelings about that as Kees'es :) Best regards |
This comment has been minimized.
This comment has been minimized.
@RalphMeuse: I started with these dimmers around a year ago as there havn't been any other (cheap) Wifi-Dimmer available. I have had as well a lot of trouble. Bulbs starts glimming, turned sometime sporadically off and sometimes often off. This all stopped as a friend of my daughter accidentically turn our WLAN off by tapping on button of router. No more glimming, turning off...so I decided to connect the dimmer to another/old router and turn this router off. This dramatically reduces the annoyance of my wife ;)....No more voice control via alexa, but the lights are still dimmable and stays on/off as expected. So there is a problem with the firmware-wifi combination. In my case, tasmota solved this issue. Looking back (and seeing your comment about frustrating hours) it should have waited for the Shelly Dimmers. They are on the market now, much easier to handle, works out of the box, having much more features, costs are simliar small (20€), having support from manufacturer are prepared to be flashed serial via easy accessable pins. I even think I would have exchanged all of the 9 QS-Wifi-D01 with shellys if blakadder and thxthx0 hadn't had the idea to research and share this. I have learned a lot regarding openhab, tasmota, programming, electrical installations, LEDs, etc while I have tried solving this problem. But I might have been even nice to grab a good book or doing something else as spending time on a more or less faulty product. So keep on testing, but stay happy! |
This comment has been minimized.
This comment has been minimized.
@sqw534 @RalphMeuse To improve WiFi you could try There are already some LSC templates at https://blakadder.github.io/templates/ |
This comment has been minimized.
This comment has been minimized.
@sqw534 and @thxthx0
Maybe this is Tasmota default behaviour. Then I have to find a way to automatically copy the right json part from the packet to it's own topic. Node-RED? |
This comment has been minimized.
This comment has been minimized.
Hej, great that is working for you. Regarding the build/hue/mqtt: This seems to be the tasmota default settings/behaviour. I json statement in result differs if you send a dimmer value (contains Dimmer) or a Power on/off command (doesn‘t contain Dimmer). In openhab I could use jsonpath transformation but the missing Dimmer value causes an error within openhab. I takes me as well a little bit to get an openhab rule for @thxthx0 Thanks for your reply. Indeed I realized that a little bit later. Best regards. |
This comment has been minimized.
This comment has been minimized.
@sqw534 I made a Node-RED flow that (in case the MQTT Dimmer member is supplied) the json properties Dimmer and POWER are copied over to .../stat/.../Dimmer and .../stat/.../POWER topics. Those topics are used in my HA configuration. And also by Google (using gBridge.io). Seems to work fine that way... BTW: the copiïng of the POWER value seems necessary, because when the Tasmota Dimmer is off and the SLIDER is used to turn it on, the RESULT json indicates POWER ON, but the POWER topic is still OFF. Don't know if this is Tasmota default or a flaw in the script... |
This comment has been minimized.
This comment has been minimized.
Made one addition to the Node-RED flow: when the physical switch is used (and the light fades out) in the end the json in the RESULT topic states "OFF", but the POWER topic is NOT set to "OFF". So HA (and Google) doesn't know it's off. Added it to the flow and now it works as expected! |
This comment has been minimized.
This comment has been minimized.
@sqw534 is it possible to compile a version that supports more possible characters for the script? I ordered a 2 gang dimmer and would like to try to make that work. But with 40 chars left... |
This comment has been minimized.
This comment has been minimized.
Hej, @RalphMeuse: I have noticed the difference between the Power-state values as well. Setting the SetOption59 to 1 Tasmota updates the telemetry topic on each power/dimmer change. The works quite reliable, as I can use a JSONPath transform within openhab 2.4 which elsewise breaks if a value isn't included in the RESULT topic. Increases the traffic a little bit, but that's ok for me. Regarding the available characters in the scipting editor: Yes, that would be great as I even want to implement fading when switching via Alexa/Google/WebUI/MQtt. But this isn't related to the build. As far as I have recognized this has @gemu2015 reused the available RAM from rules. So a change of available RAM for the script editor would need a rearrangement of the available RAM within the tasmota project. If you use the script from thxthx0 you will loose fading but gains more characters left. Dimming-Up could be realized with a couple of lines. @gemu2015: Perhaps you might help us by answering the question if it this would be possible to gain more RAM for the script editor? Best regards |
This comment has been minimized.
This comment has been minimized.
@RalphMeuse: Just one question: I have realized that when the light is off and I send a value to the Dimmer (via mqtt/Alexa or via the console: Dimmer 20) the light turns on but doesn't use the value I have entered. Doing this twice the value is used. It would be great if you could test this as well before I raise an issue on github to exclude an error within my local infrastructure. |
This comment has been minimized.
This comment has been minimized.
@sqw534 i myself and a couple of users expand the buffer with a cheap i2c EEPROM (https://www.ebay.de/itm/AT24C256-Serial-EEPROM-I2C-Interface-EEPROM-Data-Storage-Module-for-Arduino-NEU/233026828988?hash=item36417b3abc:g:tq4AAOSwMO9cALBC) |
This comment has been minimized.
This comment has been minimized.
@gemu2015 I have recently tried the decode-config.py and there are a lot values within regarding other modules which I do not need/use. If I clear this out of the config, I would be able to add more characters to the script on upload it to the device? |
This comment has been minimized.
This comment has been minimized.
@sqw534 |
This comment has been minimized.
This comment has been minimized.
@sqw534 |
This comment has been minimized.
This comment has been minimized.
@thxthx0 Hej, as you night have seen did I have compiled a slim (<512k) version of the 7.1.1.1 tasmota branch. Here I observe that by sending i.e. „Dimmer 30“ via the console while power is off the light comes up ignoring the given value and uses the last given value before powering off. Afterwards the command is executed as expected. I have tested this with your script as well. Same behaviour. |
This comment has been minimized.
This comment has been minimized.
@sqw534, a bug with incorrect setting of the dimmer level is fixed in my version of the script given in the 4th post of this topic |
This comment has been minimized.
This comment has been minimized.
Hello I hope someone can help me. I'm looking for a script or rule for Tasmota to be able to dim an RGB strip with a button (MagicHome, Shelly RGBW2). for example: 1x press on / off; hold: dimming up and down; Press twice to choose a color (#ffffff). It would also be nice if when switching on / off a relay also switches that the large power supply is not always on. Unfortunately I don't know anything about Rule / Script at Tasmota. |
This comment has been minimized.
This comment has been minimized.
@DpunktS Hej, sorry can‘t help you as I do not have an RGB Dimmer. regs Sven |
This comment has been minimized.
This comment has been minimized.
Hallo an alle, ich habe ein kleines Problem! ich habe alles, wie in der Anleitung beschrieben, gemacht. wenn ich eine LED 230V dort anschließe funktioniert alles, wenn ich eine Halogen anschließe geht auch alles, wenn ich aber 9 LEDs 230V anschließe geht es über den Taster S aber über MQTT geht es nicht mehr. Hello everyone, I have a small problem! I did everything as described in the instructions. If I display a LED 230V, everything works, if I display a halogen, everything works, but if I display 9 LEDs 230V, you can use the S button, but you can no longer use MQTT |
This comment has been minimized.
This comment has been minimized.
@OlfrygtACAB Hej, does it work if you use the web-interface? Up to how many LEDs are working? regs |
This comment has been minimized.
This comment has been minimized.
Im working on a script that is working with two dimmers. This is what I got so far
But its to long. Can you pass two parameters to one sub? |
This comment has been minimized.
This comment has been minimized.
Hi, plz give it a try (with I don't have a QS-WiFi-D02 2-way dimmer for testing. Yes, "=Dimmer" refers to the WebUI slider and PWM1. |
This comment has been minimized.
This comment has been minimized.
It's better to let the orginal firmware or switch to tasmota? |
This comment has been minimized.
This comment has been minimized.
hey im using this script as set out in https://templates.blakadder.com/qs-wifi_D01_dimmer.html is it suppose to, or would it be easy to change it so that... so when maxed out, brief pause, and then it would flip and start dimming, and then when at min, brief pause, then start brightening up, till it hits max, brief pause, and then flip and start dimming etc etc etc |
This comment has been minimized.
This comment has been minimized.
@gadget78: I think it is easily possible to reality this. To simply change the direction changing changing the dimming section with the code belief should work (not tested) Pausing on upper or lower level might be done via an extra variable counter. Have fun ; increase dim level |
This comment has been minimized.
This comment has been minimized.
@Bajger-M Mix original firmware didn‘t worked. The dimmerd turned off the lights randomly...so no option to keep it. I wanted to control them via openhab so Tasmota was my choice. Working stable since more than a year. |
This comment has been minimized.
This comment has been minimized.
@sqw534 Thankyou for reply, the code and how quick this was!! |
This comment has been minimized.
This comment has been minimized.
@thxthx0 really love your script. I flashed my QS-WiFi-D01-TRIAC 150W Dimmer with Tasmota (9.2.0.7 with scripting). after adding the script I am able to toggle and change brightness using a pulse switch. But when I click the Toggle switch within the Tasmota web interface the device will crash and reboot. I get the following error in the Console: Sometimes the action fails with error: Has anyone seen this issue before? |
This comment has been minimized.
This comment has been minimized.
Hi, I have the same problem. |
This comment has been minimized.
This comment has been minimized.
Thanks for the reply! |
This comment has been minimized.
This comment has been minimized.
Hej, if 7.1.1.1 ist as well ok for you there is an stripped down one incl. scripting, mqtt, hue and timer here: Is running stable on all my devices since +1 year. Might be that it doesn't work from scratch but could be a starting point. Hope this helps. Enjoy |
This comment has been minimized.
This comment has been minimized.
Hi, Thank you so much! |
This comment has been minimized.
Thank you!