MagicHome with Tasmota and OpenHab2

Hi @lxfrdl,

you have to install MQTT binding to get the publish command…

So just install MQTT binding via PaperUI and configure it in service/mqtt.cfg

Andreas

Hey @imhofa,

what a fast support :).

I already installed it an configured it under services/mqtt.cfg.
I found trough research that I need

import java.awt.Color

before the rule to Support Color.
Maybe it it something similar?
Anyways thanks for your reply!

Alex

I have the following imports at the beginning of the rule file:

import org.openhab.core.library.types.HSBType
import java.awt.Color

Do you get some information in the logs about mqtt at startup?
If the binding is installed you should have the publish command…
So just restart openhab and see what the logs are saying about mqtt binding…

Andreas

edit: AND you need the MQTT Action Binding as well…

1 Like

This was the missing piece :). After I installed the Action it works like a charm.

import org.openhab.core.library.types.HSBType

resultet for me in the error Configuration model 'alex_rgb_beleuchtung.rules' is either empty or cannot be parsed correctly!

To sum up after installing MQTT Action and MQTT Binding the following rule

import java.awt.Color

rule "Set RGB value Alex RGB"
  when
    Item Alex_RgbStrip_Color changed
  then
    var HSBType hsb = Alex_RgbStrip_Color.state as HSBType
    var Color color = Color::getHSBColor(hsb.hue.floatValue / 360, hsb.saturation.floatValue / 100, hsb.brightness.floatValue / 100)
    var String rgb = String::format("%1$02x%2$02x%3$02x", color.red, color.blue, color.green)
    publish("broker", "cmnd/alexrgb1/color", rgb)
    Alex_RgbStrip_RGB.postUpdate(rgb)
  end

works perfectly.

@imhofa Thank you so much!

Sorry about the late information about MQTT Action. Most times you install a setup but can’t remember every single step…

Glad that it’s working now…

Andreas

1 Like

Thanks it works for me also. But one issue encounters. I’ve connected a WS2812 to a Wemos Mini. It’s running well, also color changing works with the rule above. But if I select a scheme (Webconsole command e.g. “scheme 8” ) Than i get the following error in openhab.log:
018-03-21 14:29:51.434 [ERROR] [.mqtt.internal.MqttMessageSubscriber] - Error processing MQTT message.
org.openhab.core.transform.TransformationException: Invalid path ‘$.Color’ in ‘{“Scheme”:2}’
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [200:org.openhab.core.compat1x:2.2.0]
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138) [231:org.openhab.binding.mqtt:1.11.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556) [239:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475) [239:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) [239:org.openhab.io.transport.mqtt:1.11.0]
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) [239:org.openhab.io.transport.mqtt:1.11.0]
at java.lang.Thread.run(Thread.java:748) [?:?]

Blockquote

I think the problem is, that the return value of the mqtt broker is different, depending on what action is started:
stat/sonoffWemosMini/RESULT {“POWER”:“ON”,“Dimmer”:100,“Color”:“00FF00”}
stat/sonoffWemosMini/RESULT {“Scheme”:2}

I think a workaround would be to grab complete Result String and split it up into separate mqtt items manually…

Anybody an idea to proceed?

The problem is that Tasmota answers with different payload within RESULT as you showed.
If you change the dimmer value then the JSON returns just the value for “Dimmer”, if you change the color the answer is just the “Color”-value.

I can live with the error messages in this case…

The only solution I see is getting a Proxy item with the JSON return and split this within a rule. With this solution it is possible to check the payload and update the corresponding item…

For me: too much work…

Andreas

Hi,

wrote a mail that “greps” out the JSON Result, so no Logging occurs any longer:

rule “Wemos Mini 1 LED Result Topic”
when
Item i_mqtt_sonoffWemosMini_1_Result changed
then

        if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("Speed") ) {
            val speed = transform("JSONPATH", "$.Speed", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Speed.postUpdate(speed)
        }

        if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("POWER") ) {
            val power = transform("JSONPATH", "$.POWER", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Power.postUpdate(power)
        }
        
        if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("Color") ) {
            val color = transform("JSONPATH", "$.Color", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_RGB.postUpdate(color)

            val power = transform("JSONPATH", "$.POWER", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Power.postUpdate(power)

            val dimmer = transform("JSONPATH", "$.Dimmer", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Dimmer.postUpdate(dimmer)
        }

        if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("Fade") ) {
            val fade = transform("JSONPATH", "$.Fade", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Fade.postUpdate(fade)
        }

        if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("Pixels") ) {
            val pixels = transform("JSONPATH", "$.Pixels", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Pixels.postUpdate(pixels)
        }    

         if (i_mqtt_sonoffWemosMini_1_Result.state.toString.contains("Scheme") ) {
            val scheme = transform("JSONPATH", "$.Scheme", i_mqtt_sonoffWemosMini_1_Result.state.toString)
            i_mqtt_sonoffWemosMini_1_Schema.postUpdate(scheme)
        }         

end

Here are the items:
Switch i_mqtt_sonoffWemosMini_1_Power “Sonoff Wemos Mini 1 LED: [%s]” { mqtt=">[mosquitto:cmnd/sonoffWemosMini_1/POWER:command::default]"}
Color i_mqtt_sonoffWemosMini_1_Color “Sonoff Wemos Mini 1 Color”
String i_mqtt_sonoffWemosMini_1_RGB
String i_mqtt_sonoffWemosMini_1_Result {mqtt="<[mosquitto:stat/sonoffWemosMini_1/RESULT:state:default]"}
Dimmer i_mqtt_sonoffWemosMini_1_Dimmer “Sonoff Wemos Mini 1 Dimmer [%.0f %%]” {mqtt=">[mosquitto:cmnd/sonoffWemosMini_1/DIMMER:command:
:default]"}
Number i_mqtt_sonoffWemosMini_1_Speed “Sonoff Wemos Mini 1 LED Speed: [%d]” {mqtt=">[mosquitto:cmnd/sonoffWemosMini_1/SPEED:command::default]"}
Number i_mqtt_sonoffWemosMini_1_Schema “Sonoff Wemos Mini 1 Schema: [%d]” {mqtt=">[mosquitto:cmnd/sonoffWemosMini_1/SCHEME:command:
:default]"}
Number i_mqtt_sonoffWemosMini_1_Programm “Programm [MAP(ws2812programme.map):%s]”
Number i_mqtt_sonoffWemosMini_1_Pixels “Sonoff Wemos Mini 1 Pixels [%d]”
Switch i_mqtt_sonoffWemosMini_1_Fade “Sonoff Wemos Mini 1 Fade: [%s]” { mqtt=">[mosquitto:cmnd/sonoffWemosMini_1/FADE:command:*:default]" }

Of course MQTT Topics must fit for you environment…

1 Like

Are there anyone here who use this kind of MagicHome (copy maybe?) with Tasmota and OpenHab:
link

If yes, does it requires flashing Tasmota? Or it can be used without modifying the firmware? Is this thing reliable?

Thanks

I just started using this controller with OpenHAB this week. You can use the wifi LED binding, is working fijne.
https://docs.openhab.org/addons/bindings/wifiled/readme.html

Thanks!
Yeah I saw this binding before, but I was not sure that Tasmota is needed for this or not.
Do you use some modified firmware or you use the original firmware on this controller?

Nope, no other firmware. So it’s realy simple. Discovery is also working if needed.

Thanks for your help!

Is there another way to send HSB Values to the Arilux (AL-C01) Controller without reflashing them?

Hello Nico111,
I guess that you are talking about AL-SL 01. If so, I’m using it with WIFI Led bind and original firmware and works perfectly. As I know, you can send HSB values. I have configured " LD382A" as protocol.

Nope I’m talking about this one.
https://www.amazon.de/Pegasus-ARILUX®-AL-LC01-RGB-Controller-Streifenlicht/dp/B074DGF8J9

Seams to be the same that I’m using. I have found several model name for the same device.
https://www.banggood.com/ARILUX-AL-LC01-Super-Mini-LED-WIFI-Smart-RGB-Controller-For-RGB-LED-Strip-Light-DC-9-12V-p-1058603.html?rmmds=search&cur_warehouse=CN

Yeah it’s the same, They produce them and label different names on it.
Basically just a ESP8266

Follows this you can do it with magichome without Tasmota.

Hi Andreas,

thanks for sharing. Could you also add your sitemap configuration so I can get it to work?