We control our devices usually with voice commands with Alexa and Google Assistant and sometimes those voice assistants, for some reason, do not understand the item name correctly but something else.
What I did to enhance the WAF is to create “Item Aliases” with the misheard names so that, even when the voice assistants understand something different to what we say, it still works.
An example is a lamp we call “The Pandas” because it has panda bears on them. When saying “xxx, turn on the pandas” Alexa in the past sometimes understood the item name as “Pandas”, “Panda”, “Panthers”, “Candle”, “Pandals”, “Pendant”, “Benders” -> frustrating!
So I created additional items in my items file with those alternate names, made them visible to the voice assistants and created rules to trigger the main item in case such an alias item was triggered -> works perfectly.
However I was wondering if there would be a better, easier solution than this without specific rules and defining multiple items?
Here is my code example with “The Pandas” lamp:
Switch Outlet02 "The Pandas" <switch_panda> (Outlets) ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias1 "Pandas" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias2 "Panthers" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias3 "The Panda" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias4 "Candles" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias5 "Pandals" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias6 "Pendant" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
Switch Outlet02_Alias7 "Benders" ["Switchable"] { channel="mqtt:topic:MQTTBroker:Outlet02:Outlet02" }
rule "Outlet02_Alias ON"
when
Item Outlet02_Alias1 received update ON or Item Outlet02_Alias2 received update ON or Item Outlet02_Alias3 received update ON or Item Outlet02_Alias4 received update ON or Item Outlet02_Alias5 received update ON or Item Outlet02_Alias6 received update ON or Item Outlet02_Alias7 received update ON
then
logInfo( "FILE", "RULE 'Outlet02_Alias ON' START")
if(Outlet02.state != ON) {
sendCommand(Outlet02, ON)
postUpdate(Outlet02_Alias1, ON)
postUpdate(Outlet02_Alias2, ON)
postUpdate(Outlet02_Alias3, ON)
postUpdate(Outlet02_Alias4, ON)
postUpdate(Outlet02_Alias5, ON)
postUpdate(Outlet02_Alias6, ON)
postUpdate(Outlet02_Alias7, ON)
}
logInfo( "FILE", "RULE 'Outlet02_Alias ON' END")
end
rule "Outlet02_Alias OFF"
when
Item Outlet02_Alias1 received update OFF or Item Outlet02_Alias2 received update OFF or Item Outlet02_Alias3 received update OFF or Item Outlet02_Alias4 received update OFF or Item Outlet02_Alias5 received update OFF or Item Outlet02_Alias6 received update OFF or Item Outlet02_Alias7 received update OFF
then
logInfo( "FILE", "RULE 'Outlet02_Alias OFF' START")
if(Outlet02.state != OFF) {
sendCommand(Outlet02, OFF)
postUpdate(Outlet02_Alias1, OFF)
postUpdate(Outlet02_Alias2, OFF)
postUpdate(Outlet02_Alias3, OFF)
postUpdate(Outlet02_Alias4, OFF)
postUpdate(Outlet02_Alias5, OFF)
postUpdate(Outlet02_Alias6, OFF)
postUpdate(Outlet02_Alias7, OFF)
}
logInfo( "FILE", "RULE 'Outlet02_Alias OFF' END")
end