Openhab & Alexa & Sonoff(Tasmota or ESPUrna), where are my things

Hi OpenHabbers,

a little background on my system - I use OpenHabian on a raspi3, plus a bunch of Smart Home Hardware.
Control should be possible with a little Android tablet (FireTab) using a nice Openhab GUI and Alexa.

I started with OpenHab and added all my Sonoffs (flashed with tasmota firmware), Openhab was able to control them all
but Alexa only works on the single channel switches. As I have mostly Sonoff 4Ch and 4ch Pro devices this was bad.
If I say"work", I mean that I can use the devices not only for direct voice commands but also inside Alexa Routines.
It seems that the tasmota Hue emulation is not “compatible” enough, but Wemo emu works.

So I am now testing ESPurna. It is also available for almost all ESP based Hardware (just like the tasmota), but it uses the Wemo emulation - also for the multi-channel parts (it just starts a webserver for each relais - nice trick)

My problem now is - how do I add the Wemo devices to OpenHab? The auto-magick detection does not seem to work :frowning:.

Is my approach the best one, under my special circumstances (e.g. using Alexa Routines)?

If I won’t hear any new tip (or trick) I might use the http API as last resort?

TiA
Marc

Hello Marc,

Openhab was able to control them all but Alexa only works on the single channel switches. As I have mostly Sonoff 4Ch and 4ch Pro devices this was bad.

I believe this is the real problem you are facing. The one does not rule out the other.
I have a good idea what you are doing “wrong”. Please post your item definitions for the four channels.

Hi Thomas,

in my tasmota-setup I used this config (in items/sonoff.items)

Switch SofaGruen "Sofa gruen" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/pow1/POWER:command:*:default],
            <[mqtt:stat/pow1/POWER:state:default]" }

Switch Gartenfenster "Gartenfenster" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/pow2/POWER:command:*:default],
            <[mqtt:stat/pow2/POWER:state:default]" }

Switch TV_Licht "TV Licht" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-1/POWER1:command:*:default],
            <[mqtt:stat/ch4-1/POWER1:state:default]" }

Switch SofaSchwarz "Sofa schwarz" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-1/POWER2:command:*:default],
            <[mqtt:stat/ch4-1/POWER2:state:default]" }

Switch KlavierLicht "Klavier Licht" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-1/POWER3:command:*:default],
            <[mqtt:stat/ch4-1/POWER3:state:default]" }

Switch BuegelLicht "Buegel Licht" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-1/POWER4:command:*:default],
            <[mqtt:stat/ch4-1/POWER4:state:default]" }

Switch A1 "A1" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-2/POWER1:command:*:default],
            <[mqtt:stat/ch4-2/POWER1:state:default]" }

Switch A2 "A2" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-2/POWER2:command:*:default],
            <[mqtt:stat/ch4-2/POWER2:state:default]" }

Switch A3 "A3" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-2/POWER3:command:*:default],
            <[mqtt:stat/ch4-2/POWER3:state:default]" }

Switch A4 "A4" <light> (BA) [ "Lighting" ]
    { mqtt=">[mqtt:cmnd/ch4-2/POWER4:command:*:default],
            <[mqtt:stat/ch4-2/POWER4:state:default]" }


Number WEMO1_Power "Licht Sofa Gruen: Verbrauch [%.1f W]" (BA,gPower)
    { mqtt="<[mqtt:tele/pow1/ENERGY:state:JSONPATH($.Power)]" }

Number WEMO1_RSSI "Licht Gartenfenster: RSSI [%d %%]" (gRSSI)
    { mqtt="<[mqtt:tele/pow1/STATE:state:JSONPATH($.Wifi.RSSI)]" }

Switch WEMO1_Reachable "Licht1: reachable" (gReachable)
    { mqtt="<[mqtt:tele/pow1/LWT:state:MAP(reachable.map)]" }

String WEMO1_Verbose "Licht1: MQTT return message [%s]"
{ 
    mqtt="<[mqtt:tele/pow1/INFO1:state:default],
            <[mqtt:stat/pow1/STATUS2:state:default],
            <[mqtt:stat/pow1/RESULT:state:default]"  
}
 


Number WEMO2_Power "Licht2: Verbrauch [%.1f W]" (BA,gPower)
    { mqtt="<[mqtt:tele/pow2/ENERGY:state:JSONPATH($.Power)]" }

Number WEMO2_RSSI "Licht2: RSSI [%d %%]" (gRSSI)
    { mqtt="<[mqtt:tele/pow2/STATE:state:JSONPATH($.Wifi.RSSI)]" }

Switch WEMO2_Reachable "Licht2: reachable" (gReachable) 
    { mqtt="<[mqtt:tele/pow2/LWT:state:MAP(reachable.map)]" }

String WEMO2_Verbose "Licht2: MQTT return message [%s]"
    { mqtt="<[mqtt:tele/pow2/INFO1:state:default],
            <[mqtt:stat/pow2/STATUS2:state:default],
            <[mqtt:stat/pow2/RESULT:state:default]" 
}



Number CH4_1_RSSI "CH4_1: RSSI [%d %%]" (gRSSI)
    { mqtt="<[mqtt:tele/ch4-1/STATE:state:JSONPATH($.Wifi.RSSI)]" }

Switch CH4_1_Reachable "CH4_1: reachable" (gReachable)
    { mqtt="<[mqtt:tele/ch4-1/LWT:state:MAP(reachable.map)]" }

String CH4_1_Verbose "CH4_1: MQTT return message [%s]"
    { mqtt="<[mqtt:tele/ch4-1/INFO1:state:default],
            <[mqtt:stat/ch4-1/STATUS2:state:default],
            <[mqtt:stat/ch4-1/RESULT:state:default]" 
}

String	Sonoff_Action "Sonoff Action" <sonoff_basic>

BR
Marc

I’m confused. Everything should work fine. “Alexa, schalte das Klavier Licht an” should do the job. What do you mean by Alexa routines?

Alexa supports so called “Routines”.
Thats (by now) a very simple IFTT implementation. So - you can configure a spoken sentence, e.g. “Starte meinen Tag”, and the configured routine will execute a simple task list (without any if’s, just one after another).

The OpenHab items, or the Hue emulated items do not work with routines. But Wemo emulated devices work.

Thank you for your effort so far - maybe you can help me with changing my config to the “ESPurna” Wemo config. It allows several command entries, one is MQTT, but Openhab does not detect these devices automagically. The next is the http API, it seems this might be my solution by now, as it allows me to configure http requests with IP’s and the http api key.

What do you think?

BR
Marc

Ah,
no to my knowledge this is not supported. What you can do, and that is how I’d do something like this, is to define a rule to e.g. turn on a bunch of your lamps. Then you can link this rule to a switch and use it via Alexa with “Alexa, schalte die Indirekte Beleuchtung an.” If you think about it, this should work for most use cases. If prefer this solution because this way all logic stay within openHAB. I don’t know about you but one of the strong arguments of openHAB for me is, that I can do almost everything in openHAB and don’t have to implement logic in multiple UIs/applications/devices.

I’d not go away from Sonoff-Tasmota but if you want to, I can’t help with that, sorry.

Hi,

the problem is not within Openhab, it is within tasmota - I suppose, as with the Hue emulation and Alexa only parts of the hue protocol are supported.

But I see your point. Can you point me to a nice example where I can see a “openhab routine”, compatible to Alexa, with a name I like?

BR
Marc

It’s as easy as one could imagine. Just define an item and link a rule to it :wink:

Switch WZ_Indirekt "Indirekte Beleuchtung" (WZ) ["Lighting"]
rule "Indirekte Wohnzimmer Beleuchtung schalten"
when
    Item WZ_Indirekt changed to ON
then
    WZ_Ecklampe.sendCommand(ON)
    WZ_Regal_LEDs.sendCommand(ON)
    WZ_Glastisch.sendCommand(ON)
end

Thanks, that looks promising. I will checkout some rules (I suppose you can create them also time-related?) next weekend

BR
Marc

Sure. Here’s my christmas tree lighting:

val String filename = "weihnachtsbaum.rules"

rule "Weihnachtsbaum an"
when
  Time cron "0 0 18 * * ?"
then
  sendCommand(FK_Weihnachtsbaum, ON)
end

rule "Weihnachtsbaum aus"
when
  Time cron "0 30 0 * * ?"
then
  sendCommand(FK_Weihnachtsbaum, OFF)
end