I would like to use a switch item to toggle an ESP8266 module to send commands via its serial port. Therefore, I flashed an ESP8266 with a little firmware that converts incoming MQTT messages to serial output.
The commands are executed on the ESP8266 just fine, when the switch is toggled via app or webinterface.
However, it is not possible to have Alexa execute the commands. When telling Alexa to turn on or off the switch, she acknoledges the command with “OK”. However, nothing happens.
I assume, it has something to do with the fact, that the switch is defined as a string. However, I don’t know how to work around this issue. Any help is highly appreciated.
EDIT: Modified the item and sitemap extracts from general to specific implementation, to match with the logs in the follow up posts.
I am using the official Alexa skill. The ESP is configured through the .items string entry as described in the original post.
The use of a string item is due to the fact, that I need to send a string via MQTT to the ESP.
This is the log, when triggered via Alexa (Mathilde = ESP, “Clean” = “OnString” compared to the general problem description in the original post. I am trying to run a Neato robot from openHAB):
13:35:09.247 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Mathilde' received command ON
13:35:09.284 [INFO ] [marthome.event.ItemStateChangedEvent] - Mathilde changed from OFF to ON
And this, when triggered via app:
13:35:49.789 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Mathilde' received command Clean
13:35:49.826 [INFO ] [marthome.event.ItemStateChangedEvent] - Mathilde changed from ON to Clean
Apparently, the mapping in the sitemap (“Clean”=ON) is only excuted when beeing called from the app (which somewhat makes sense, because the definition is in the sitemap).
So the question is, whether it is possible to do the mapping in the string item definition? Otherwise I might have to work with a rule.
my little mqtt-client-firmware implemented on a particle photon is receiving the value of the command ON/OFF (value: AN/AUS) as a byte*, so there is a little work to do to get a string.
by the way: i always used a mapping definition vice versa:
No string to byte conversion was necessary, the string is correctly interpreted in the ESP8266.
Another positive side effect: The Neato sometimes needs to receive the clean command twice (when it is in deep sleep). The double definition of the MQTT on command accounts for that.