Align alexa binding to virtual switch

I was able to setup my R4 mini to learn 2 IR commands, how to power off the Aircon and how to power it on at a given setting. Now this is my configuration and it works just fine on Alexa:

Group     SalottoCondizionatore               "Condizionatore Salotto"                     (Salotto)                  ["Thermostat"]    {alexa="AirConditioner"}
Number    SalottoCondizionatoreTemperatura    "Temperatura Salotto"       <temperature>    (SalottoCondizionatore)                      {channel="broadlink:rm4-mini:e8-....:temperature", alexa="AirConditioner.CurrentTemperature"}
String    SalottoCondizionatoreComando        "Condizionatore Comando"                     (SalottoCondizionatore)                      {channel="broadlink:rm4-mini:e8-...:command", alexa="AirConditioner.PowerState" [ON="DEVICE_ON_27_COOL_AUTO",OFF="DEVICE_OFF"]}

What i’d like to add now is the ability to control this not only from alexa but from the UI as well ensuring that also Alexa has the proper state, so i’d like to turn it ON from the UI and turn it OFF from alexa for example.

I guess i should create a switch and then store state somehow? Also i am not sure how to map commands in a switch so the switch sends command to my IR command channel above.

Thanks!

To detect Alexa devices directly within openhab you need:

  • openhab skill within Alexa app
  • Amazon echo binding
  • set the bridge thing to discovery mode = Direct, over Alexa and openHAB skill

To make an openhab item visible to Alexa you need:

  • openhab skill within Alexa
  • add the Amazon metadata to your openhab item
  • search for new devices in Alexa app

Thanks Larsen, that was not my question maybe i expressed myself incorrectly, i wanted to understand how to create a virtual switch that can both be used by the UI and Alexa while sending commands to a String channel.

I managed to do this myself by doing this:

  • Created a Switch, exposed this switch to Alexa as AirConditioner.PowerState
  • Create a rule file that monitors the switch and sends the command to the channels

So aircon.items looks like this:

Group     SalottoCondizionatore               "Condizionatore Salotto"                            (Salotto)                  ["Thermostat"]    {alexa="AirConditioner"}
Number    SalottoCondizionatoreTemperatura    "Temperatura Salotto"              <temperature>    (SalottoCondizionatore)                      {channel="broadlink:rm4-mini:e8....:temperature", alexa="AirConditioner.CurrentTemperature"}
Switch    SalottoCondizionatoreSwitch         "Condizionatore Salotto Switch"    <switch>         (SalottoCondizionatore)                      {alexa="AirConditioner.PowerState"}
String    SalottoCondizionatoreComando        "Condizionatore Comando"                            (SalottoCondizionatore)                      {channel="broadlink:rm4-mini:e8-...:command"}

And rules:

rule "Maps aircon in living room to commands on IR controller"
when
    Item SalottoCondizionatoreSwitch changed
then
    if (SalottoCondizionatoreSwitch.state == ON) {
        SalottoCondizionatoreComando.sendCommand("DEVICE_ON_27_COOL_AUTO")
    } else if (SalottoCondizionatoreSwitch.state == OFF) {
        SalottoCondizionatoreComando.sendCommand("DEVICE_OFF")
    }
end

Works like a charm.
Thanks!