arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.29k stars 4.82k forks source link

Power State send twice via MQTT #3266

Closed helmar74 closed 6 years ago

helmar74 commented 6 years ago

Hi,

I'm running a Wemos Mini with a WS2812 connected. The LED Strip works fine. The MQTT Messages are send to a mosquitto broker, which is connected openhab 2.3.0. I've got the following problem: When I turn ON or OFF the LED Strip (with the command POWER ON or POWER OFF) I always get the Power status message vor MQTT twice: 19:55:03 MQT: stat/sonoffWemosMini_5/POWER = {"POWER":"OFF"} 19:55:03 MQT: stat/sonoffWemosMini_5/POWER = OFF

The Problem is that my openhab always throws an Exception becaus one of the Status is invalid. Is it possible to turn of this double MQTT Messages to get only one status: 19:55:03 MQT: stat/sonoffWemosMini_5/POWER = {"POWER":"OFF"} OR 19:55:03 MQT: stat/sonoffWemosMini_5/POWER = OFF

Thanks a lot

Make sure these boxes are checked [x] before submitting your issue - Thank you!

(Please, remember to close the issue when the problem has been addressed)

Jason2866 commented 6 years ago

It seems you have something misconfigured It should look like this 20:34:17 MQT: stat/sonoff-13D92F/RESULT = {"POWER":"ON"} 20:34:17 MQT: stat/sonoff-13D92F/POWER = ON 20:34:23 MQT: stat/sonoff-13D92F/RESULT = {"POWER":"OFF"} 20:34:23 MQT: stat/sonoff-13D92F/POWER = OFF I use OpenHab too and it works without any errors with Tasmota

helmar74 commented 6 years ago

I configured setoption4 on to get "working" results JSON queries for the connected ws2812. (MQTT Results for setting dimmer, scheme, color, speed, fade....)

Jason2866 commented 6 years ago

SetOption 4 on is the problem!! -> You have two mqqt messages with nearly the same message. Disable SetOption 4 and post your results. If it looks similar to mine, your OpenHab config is wrong. Not at TASMOTA issue. In that case close this issue You can search here https://community.openhab.org/ or ask for help (i am active there too) There are already some articles https://community.openhab.org/t/light-color-rgb-rgbw-rgbcw-to-and-from-hsb-dimmer-conversion/39132/12 Configuration of Color LED (Lamp or WS2812) isnt done out of the box!

helmar74 commented 6 years ago

Not really... If you disable setption4 you get the same "RESULT" for different actions (changing color, scheme, speed, dimmer, fade...) So you get error in openhab, because you get one JSON Result with different content... That couldn't be parsed correctly. I used setoption4 on and as a workaround only the "POWER" Mqtt Message raised an failure, because it was send twice. As a workaround I used the POWER MQTT Message as a String Item in Openhab. Within a rule I parse the Message, and now i got the correct status (ON, OFF, BLINK) without an error...

Jason2866 commented 6 years ago

Yes, but my answer is correct, not an error in TASMOTA. It is a feature! You dont have to SetOption 4 to get it correctly working. I know OpenHab a little ;-) You can do nearly everything. It is just the way how. I did only say your configuration in OpenHab isnt correct ;-)

Please close this issue.

helmar74 commented 6 years ago

Thanks a lot

Jason2866 commented 6 years ago

Here is my way how is solved that (RegEx to filter unwanted -> causes errors) Switch AiLight "AiLight" <light> (gLight) { mqtt=">[broker:cmnd/sonoff-0CB8DA/power:command:*:default], <[broker:stat/sonoff-0CB8DA/RESULT:state:JSONPATH($.POWER):.*POWER.*]"} Number AiLight_Dimmer "AiLight Dimmer" (gLight) {mqtt=">[broker:cmnd/sonoff-0CB8DA/DIMMER:command:*:default],<[broker:stat/sonoff-0CB8DA/RESULT:state:JSONPATH($.Dimmer):.*Dimmer.*]"} Color AiLight_HSB "AiLight HSBColor" <colorwheel> (gLight) {mqtt=">[broker:cmnd/sonoff-0CB8DA/HSBCOLOR:command:*:default],<[broker:stat/sonoff-0CB8DA/RESULT:state:JSONPATH($.HSBColor):.*HSBColor.*]"}

helmar74 commented 6 years ago

Thanks for your help! For me it's now also working with setoption4 off and the following Openhab Items:

String i_mqtt_sonoffWemosMini_5_Power "Sonoff Wemos Mini 5 LED: [%s]" { mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/POWER:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.POWER):.*POWER.*]"} Dimmer i_mqtt_sonoffWemosMini_5_Dimmer "Sonoff Wemos Mini 5 Dimmer [%.0f %%]" {mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/DIMMER:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/DIMMER:state:JSONPATH($.Dimmer):.*Dimmer.*]"} Color i_mqtt_sonoffWemosMini_5_Color "Sonoff B1 1 Color" {mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/HSBCOLOR:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.HSBColor):.*HSBColor.*]"} Number i_mqtt_sonoffWemosMini_5_Speed "Sonoff Wemos Mini 5 LED Speed: [%d]" {mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/SPEED:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.Speed):.*Speed.*]"} Number i_mqtt_sonoffWemosMini_5_Pixels "Sonoff Wemos Mini 5 Pixels [%d]" { mqtt="<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.Pixels):.*Pixels.*]"} Switch i_mqtt_sonoffWemosMini_5_Fade "Sonoff Wemos Mini 5 Fade: [%s]" { mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/FADE:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.Fade):.*Fade.*]"} Number i_mqtt_sonoffWemosMini_5_Schema "Sonoff Wemos Mini 5 Schema: [%d]" {mqtt=">[mosquitto:cmnd/sonoffWemosMini_5/SCHEME:command:*:default],<[mosquitto:stat/sonoffWemosMini_5/RESULT:state:JSONPATH($.Scheme):.*Scheme.*]"} Number i_mqtt_sonoffWemosMini_5_Programm "Programm [MAP(ws2812programme.map):%s]"