Using Alexa Voice Commands to Trigger OpenHAB

I currently use Alexa voice commands to trigger OpenHAB rules via IFTTT integration. For example, “Alexa, trigger security pause” causes Alexa to send OpenHAB a command to update NUMBER item Master_Control to the value of 3. The NUMBER item Master_Control is declared to be exposed in the openhabcloud.cfg configuration file.

I am running OpenHAB 3.0.2 and use configuration files.

IFTTT is now putting restrictions on its free usage so I am migrating away from it.

I have spent the afternoon researching the solution and found hints in:

Amazon Alexa Smart Home Skill at openHAB Skill For Amazon Alexa | openHAB
and
Amazon Alexa Smart Home Skill: How to tag items for Alexa?
and
Amazon Echo Control Binding: Amazon Echo Control - Bindings | openHAB

but have not found a clear way to set a NUMBER item.

The utterances I would like to use are:
“Alexa, Security ON”
“Alexa, Security OFF”
“Alexa, Security PAUSE”
“Alexa, Security RESTART”
“Alexa, Security SHUTDOWN”

“Alexa, Network RESTART”
etc.
etc.

or “Alexa, trigger Security …”

I think I need the .items file to something like as follows that maps the control setting to a number?

Number Master_Control “Master Control [%d]” (gControl) {alexa=“Security ON”=1,“Security OFF”=2,“Security PAUSE”=3,“Security RESTART”=4,“Security SHUTDOWN”=5}
{channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

Any help will be appreciated.

Using the Alexa skill, you can model your item as a generic mode capability.

item

Number Master_Control "Master Control [%d]" (gControl) {alexa="Mode" [capabilityNames="Security", supportedModes="1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN"], channel="mqtt:topic:hsbroker:WatchManThing:WMC39"}

utterances
Alexa, set master control security to OFF
Alexa, set master control security to ON
Alexa, what’s the master control security set to?

Thank you! I’ll give it a try in the morning.

Jeremy,

Is it legal or illegal to assign the capabilityNames="Security", to multiple Number ITEMS such as:

Number Master_Control “Master Control [%d]” (gControl) {alexa=“Mode” [capabilityNames=“Security”, supportedModes=“1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

and

Number System_Health “System Health [%d]” (gControl) {alexa=“Mode” [capabilityNames=“Security”, supportedModes=“1=LOCK,2=UNLOCK”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC40”}

…bob

It’s fine since each item will be named based on its label.

Alexa, set master control security to OFF
Alexa, set system health security to UNLOCK

Can I stretch this further - What if the ITEM NAME LABELS are the same such as:

Number Master_Control “Master Control [%d]” (gControl) {alexa=“Mode” [capabilityNames=“Security”, supportedModes=“1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

and

Number System_Health “Master Control [%d]” (gControl) {alexa=“Mode” [capabilityNames=“Security”, supportedModes=“1=LOCK,2=UNLOCK”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC40”}

I have made progress but my system is not 100% operational. Current status is operational; commands are not :frowning:

I have the 2 ITEMS configured but they are not 100% operational. When I view them in the Alexa App I see 2 devices: “Equipment” and “Security”. When I tap “Equipment” the app pages down and displays “Restart” with status = “UNLOCK”; and when I tap “Security” the app pages down and displays “System” with status = “OFF”. Both devices properly display the current status, and both devices properly display the current status when it is changed. HOWEVER, NEITHER DEVICE ALLOWS ME TO control it no matter where I tap on the screen. I would expect tapping on the status should reveal the other choices?

My wake word for the Echo Dot is “Echo”. When I utter “Echo what’s the Equipment Restart set to?” or “Echo what’s the Security System set to?” I again get the proper response. HOWEVER, I CAN NOT CONTROL either device. When I utter “Echo set Security System to OFF” Echo replies “I don’t know how to set security to that setting”. This response is consistent for all utterances.

Bottom Line: The devices are not commandable/controllable, but why?
Perhaps “supportedModes” is not the correct choice?
Perhaps there is a semantic problem with the mode names?

The 2 devices are configured as follows:

Number OHC_System_Health “Equipment [%d]” (gControl){alexa=“Mode” [capabilityNames=“Restart”, supportedModes=“1=UNLOCK,2=UNUSED,3=LOCK,4=NETWORK,5=WATCHMAN,6=OPENHAB,7=SHUTDOWN”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC35”}

and

Number OHC_Master_Control “Security [%d]” (gControl) {alexa=“Mode” [capabilityNames=“System”, supportedModes=“1=OFF,2=PAUSE,3=ON,6=LIGHTS”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

BTW - As a side note for others implementing the Amazon Alexa Smart Home Skill for the first time, there are no bindings required.

Again, any help will be appreciated.

No you can’t. Device names on the Alexa side should be unique otherwise you will get duplicate device errors.

Have you tried the item definition and utterances I provided? Also, please include the utterances you are requesting.

Jeremy,

Thanks so much for responding. As I research this issue I see your name on many threads.

I’ve tested the following utterances:

“Echo set Security System to Off” Echo replies “I don’t know how to set security to that setting”
“Echo set Security System to Pause” Echo replies “I don’t know how to set security to that setting”
“Echo set Security System to On” Echo replies “I don’t know how to set security to that setting”
“Echo set Security System to Lights” Echo replies “I don’t know how to set security to that setting”

I’m willing to bet either the words “Security” or “System” are unacceptable to Alexa’s vocabulary.

“Echo set Equipment Restart to Lock” Echo replies “I don’t know how to set security to that setting”
“Echo set Equipment Restart to Unlock” Echo sometimes replies “I don’t know how to set security to that setting”
BUT
usually responds to with the acknowledgement tone BUT does not change the the value of Number Item OHC_Master_Control.

I’m thinking the word “Lock” might also be a vocabulary problem?

Looking at the online Generic Attributes / Modes documentation, is it possible that I need to include

  • nonControllable=<boolean>
    • set to true for state reporting support only
    • defaults to item state description read only property if defined, otherwise false

Should I be able to control these 2 devices via the Amazon Alexa App like non-OpenHAB devices?

Have you triggered a discovery after making your item definition changes?

Yes as long they are properly configured.

  1. I successfully delete the devices from Alexa every time I restart OpenHAB.

  2. I successfully discover the 2 new OpenHAB devices after OpenHAB is fully up and running.

  3. I have changed device names to eliminate the possibility of reserved words.

  4. Alexa CORRECTLY replies to:
    “Echo, what is House Dog Now set to?”
    and
    “Echo, what is Equipment Restart Now set to?”

  5. Alexa consistently replies:
    “I don’t know how to set House Dog Now to that setting” when uttered “Echo, set Douse Dog Now to …” for all supportedModes
    and
    “I don’t know how to set Equipment Restart Now to that setting” when uttered “Echo, set Equipment Restart Now to …” for all supportedModes

  6. My iPhone Amazon Alexa App properly displays the current status

  7. It appears to me that the ITEMS are defaulting to read-only?

  8. Out of desperation I have also tried eliminating capabilityNames="Now" from the ITEMS configuration and I get similar results.

I’m at a loss as to what to try next. Is there any chance I need to include:
nonControllable=`

  • set to true for state reporting support only
  • defaults to item state description read only property if defined, otherwise false

Here are the 2 ITEM configurations:

Number OHC_Master_Control “House Dog [%d]” (gControl) {alexa=“Mode” [capabilityNames=“Now”, supportedModes=“1=Off,2=Pause,3=On,6=Lights”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

and

Number OHC_System_Health “Equipment Restart [%d]” (gControl){alexa=“Mode” [capabilityNames=“Now”, supportedModes=“1=Unlock,2=Unused,3=Lock,4=Network,5=Watchman,6=OpenhabB,7=Shutdown”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC35”}

Can you start with the example I provided? Also, make sure that the state description of your item isn’t set to read-only. The nonControllable metadata parameter defaults to that setting if defined.

Also, if you don’t want to name your capability on a single endpoint. You can omit the capabilityNames metadata parameters and it will default to “Mode” (e.g. Alexa, set the <device name> mode to <mode name>)

Thank you for your continued help.

OK. Per your 1st reply, I copied and pasted here and into .Items file:

Number Master_Control "Master Control [%d]" (gControl) {alexa="Mode" [capabilityNames="Security", supportedModes="1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN"], channel="mqtt:topic:hsbroker:WatchManThing:WMC39"}

utterances and responses:
Alexa, what’s the master control security set to? → master control security is pause
Alexa, set master control security to ON → I don’t know how set master control to that setting
Alexa, set master control security to OFF → I don’t know how set master control to that setting
Alexa, set master control security to PAUSE → I don’t know how set master control to that setting
Alexa, set master control security to RESTART → I don’t know how set master control to that setting
Alexa, set master control security to SHUTDOWN → I don’t know how set master control to that setting
Alexa, set master control security to SHUTDOWN → master control doesn’t support that
Alexa, set master control security to SHUTDOWN → Alexa responded with a tone
Alexa, what’s the master control security set to? → master control security is pause
Alexa, set master control security to SHUTDOWN → Alexa responded with a tone
Alexa, what’s the master control security set to? → master control security is pause

Item Master_Control is controllable thru IFTTT so I know it is not Read-Only from OpenHAB cloud’s perspective.

Please note that the Item Name has an underscore in it. Can that be causing an Alexa problem?

Jeremy,

I have good news and bad news.

The good news is I ran a test whereby I eliminated the mqtt channel binding and now the device works perfectly! Echo Dot utterances work and my iPhone Alexa App displays a touch sensitive button with responds as expected. Here’s the working ITEM configuration:

Number Master_Control "Master Control [%d]" (gControl) {alexa="Mode" [capabilityNames="Security", supportedModes="1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN"]}

The bad news is I have a new problem to resolve. Somehow the mqqt binding is effecting the smart skill:
channel="mqtt:topic:hsbroker:WatchManThing:WMC39"

Here’s the THING configuration:

	Bridge mqtt:broker:hsbroker "hsbroker" [ host="10.0.0.9", secure=false ] {
		Thing topic WatchManThing "From WatchMan" 
		{
			Channels:Type string: WMC39				"OHC_Master_Control"        [stateTopic="/OHIB/OHC/39"]```


Any ideas?

Shouldn’t your MQTT channel have a defined commandTopic in order to pass on received commands?

According to the MQTT binding documentation, if it is not configured or left empty, the thing channel will be read-only which explains why the skill is defaulting that device as non-controllable based on what I explained previously.

If you want to override this logic at the skill level, you can set metadata parameter nonControllable to false.

I’ve been running MQTT for many months without issues. I’ll review your recommendation regarding commandTopic.

While I was waiting your reply I installed and tested "nonControllable="False" and was successful!

Thanks so much for your help.

For the benefit of others researching this topic here is the solution:

Number Master_Control “Master Control [%d]” (gControl)
{alexa=“Mode” [
nonControllable=“False”,
capabilityNames=“Security”, supportedModes=“1=ON,2=OFF,3=PAUSE,4=RESTART,5=SHUTDOWN”], channel=“mqtt:topic:hsbroker:WatchManThing:WMC39”}

Note:
capabilityNames="Security", is not required.
No bindings are required

Jeremy

You identified the underlying problem I had:
MQTT REFERANCE: MQTT Things and Channels - Bindings | openHAB
commandTopic: The MQTT topic that commands are send to. This can be empty, the thing channel will be read-only then. Transformations are not applied for sending data.