WLED/wled00/wled12_alexa.ino

53 lines
886 B
Arduino
Raw Normal View History

2017-02-21 23:59:47 +01:00
void alexaOn();
void alexaOff();
void alexaDim();
2017-02-21 23:59:47 +01:00
void alexaInit()
{
if (alexaEnabled && WiFi.status() == WL_CONNECTED)
{
upnpBroadcastResponder.beginUdpMulticast();
alexa = new Switch(alexaInvocationName, 81, alexaOn, alexaOff);
upnpBroadcastResponder.addDevice(*alexa);
}
}
void handleAlexa()
{
if (alexaEnabled && WiFi.status() == WL_CONNECTED)
{
upnpBroadcastResponder.serverLoop();
alexa->serverLoop();
}
}
void alexaOn()
{
if (alexaOnMacro == 255)
2017-02-21 23:59:47 +01:00
{
handleSet((alexaNotify)?"win&T=1&IN":"win&T=1&NN&IN");
2017-02-21 23:59:47 +01:00
} else
{
applyMacro(alexaOnMacro);
2017-02-21 23:59:47 +01:00
}
}
void alexaOff()
{
if (alexaOffMacro == 255)
2017-02-21 23:59:47 +01:00
{
handleSet((alexaNotify)?"win&T=0&IN":"win&T=0&NN&IN");
2017-02-21 23:59:47 +01:00
} else
{
applyMacro(alexaOffMacro);
2017-02-21 23:59:47 +01:00
}
}
void alexaDim(uint8_t bri)
{
String ct = (alexaNotify)?"win&IN&A=":"win&NN&IN&A=";
ct = ct + bri;
handleSet(ct);
}