I’m currently using call service. But would like to learn how to use mqtt directly. I do have mqtt container running and a few tasmota switch connected to mqtt. Could you share the code of the light, switch and mqtt out nodes? This way it bypass hass.
I’ll share it but it’s not likely to be very useful for you. My devices are not using Tasmota, so the function nodes are producing payloads that are compliant with my specific MQTT requirements and not Tasmota’s.
The “lights” function node contains this:
if (msg.on === true) {
msg.payload = msg.percentage.toString();
}
else {
msg.payload = "0";
}
return msg;
All it does is set msg.payload
to a value between "0"
and "100"
. The topic is the device’s brightness
value (see my previous post for a sample light topic).
The “switches” function node is even simpler and contains this:
msg.payload = ((msg.on === true) ? '1' : '0');
return msg;
It sets msg.payload
to either "1"
or "0"
(representing on
and off
). The topic is the device’s powerstate
value (see my previous post for a sample switch topic).
Thank you.
Looks like quite some setup for this. What major benefit by using smart home skill?
node-red-contrib-amazon-echo works great on my first try, however it requires port 80 for my echo dot 3. I have letsencrypt container for SSL and it uses port 80 and 443, I haven’t figure out how to let it release port 80 yet.
It’s basically nabucasa but free. So you get all the domain controls, light, switch, sensor, media player, etc where hue is just lights
Thanks. since it is using official api, it may worth time to set it up.
It is not going through node-red, I’d think that node-red-contrib-amazon-echo has advantage of the flexibility of setting up any simple/complex automation by any name you like.
Sadly, the whole thing imploded, yet again.
It had discovered the 20+ devices I created and was running fine for days. Today, I added one more device to the flow, used the web app to discover it, and it was discovered … but all of the 20+ devices it had were now flagged as ‘unknown device’. Not good.
I used the web app to “Forget” each and every one of the ‘unknown’ devices, then ran another another discovery. This time it only found 4 of them and all were flagged as ‘unknown devices’. I power-cycled the Echo Dot (because that seemed like the magic that resolved it last time), repeated the discovery process and it always discovered the same 4 ‘unknown devices’.
I’ll let it rest overnight and see if it works any better tomorrow. I may need to learn more about ‘burnt offerings’ …
UPDATE
This morning I power-cycled the Echo Dot again then used the web app to discover devices. This time it found all 20+ of them and only two were flagged ‘unknown device’. Not perfect but much better than last night; I can live with it.
NOTE
After performing this operation (forgetting all devices then re-discovering them) it caused a related set of nodes, node-red-contrib-alexa-remote2, to malfunction.
Alexa-Remote2 uses a cookie to connect to your Amazon account. I think that cookie contains information about your existing Alexa-aware devices (i.e. devices found at the time the cookie was created). So if those devices change in some way afterwards (like after being forgotten and re-discovered) that cookie’s contents become stale.
The way it malfunctions is immediately obvious: it loses the ability to control your devices. Although it still knows the devices you have, attempts to control them result in an error message containing “NO_ENDPOINT_FOUND”.
I deleted the cookie file and performed the initialization process again in order to create a new cookie. That fixed the problem; Alexa-Remote2 was able to control the devices again.
I am having a similar issue. I have been using emulated hue in HA with my esphome switches and it has been working great. Recently I added two more switches to emulated hue but these two are not discovered by alexa but all the existing switches works without any problems. I check the emulated hue endpoints (http://:80/api/pi/lights) and I could see the newly added switches there.
Then for experimenting I deleted one of the earlier switch from config and also alexa, then readded it again to config. This time the switch was also not discovered. Here again the endpoints were getting updated but alexa didnt find new devices.
Why is alexa not discovering new switches even when old switches works fine?