Open gustavolyra opened 6 years ago
Sinric sends success back to Alexa and forward the command to esp. normally you don’t have to do anything
On Wed, 12 Sep 2018 at 7:46 PM Gustavo Lyra notifications@github.com wrote:
When i ask alexa to change channel, ESP receive the command but alexa say "Sorry, TV isn't responding". This only happens when i ask to change channel, change volume works fine.
Do ESP need to send something to alexa after receive the command to change channel?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kakopappa/sinric/issues/115, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIM5s1QayMfaZPGgrAaZu2jgyTJ1XYYks5uaQIvgaJpZM4WlTti .
Do you see anything in the serial monitor even if it says not responding?
On Wed, Sep 12, 2018 at 8:17 PM Aruna Tennakoon aruna.tennakoon@gmail.com wrote:
Sinric sends success back to Alexa and forward the command to esp. normally you don’t have to do anything
On Wed, 12 Sep 2018 at 7:46 PM Gustavo Lyra notifications@github.com wrote:
When i ask alexa to change channel, ESP receive the command but alexa say "Sorry, TV isn't responding". This only happens when i ask to change channel, change volume works fine.
Do ESP need to send something to alexa after receive the command to change channel?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kakopappa/sinric/issues/115, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIM5s1QayMfaZPGgrAaZu2jgyTJ1XYYks5uaQIvgaJpZM4WlTti .
yes, i see the command WiFi connected. IP address: 192.168.100.22 [WSc] Service connected to sinric.com at url: / Waiting for commands from sinric.com ... [WSc] get text: {"deviceId":"TV","action":"AdjustVolume","value":{"volume":10,"volumeDefault":true}} [WSc] get text: {"deviceId":"TV","action":"AdjustVolume","value":{"volume":-10,"volumeDefault":true}} [WSc] get text: {"deviceId":"TV","action":"setPowerState","value":"ON"} [WSc] get text: {"deviceId":"TV","action":"ChangeChannel","value":{"channel":{},"channelMetadata":{"name":"tnt"}}}
ESP receive all commands, only the ChangeChannel alexa say: "Sorry, TV isn't responding"
My code:
`#include
ESP8266WiFiMulti WiFiMulti; WebSocketsClient webSocket; WiFiClient client;
const int relayPin = D1;
uint64_t heartbeatTimestamp = 0; bool isConnected = false;
void setPowerStateOnServer(String deviceId, String value); void setTargetTemperatureOnServer(String deviceId, String value, String scale);
// deviceId is the ID assgined to your smart-home-device in sinric.com dashboard. Copy it from dashboard and paste it here
void turnOn(String deviceId) {
if (deviceId == "YYYYYYYYYYYYYY") // Device ID of first device
{
Serial.print("Turn on device id: ");
Serial.println(deviceId);
digitalWrite(relayPin, HIGH); // turn on relay with voltage HIGH
}
else {
Serial.print("Turn on for unknown device id: ");
Serial.println(deviceId);
}
}
void turnOff(String deviceId) {
if (deviceId == "YYYYYYYYYYYYYYY") // Device ID of first device
{
Serial.print("Turn off Device ID: ");
Serial.println(deviceId);
digitalWrite(relayPin, LOW); // turn off relay with voltage LOW
}
else {
Serial.print("Turn off for unknown device id: ");
Serial.println(deviceId);
}
}
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
switch(type) {
case WStype_DISCONNECTED:
isConnected = false;
Serial.printf("[WSc] Webservice disconnected from sinric.com!\n");
break;
case WStype_CONNECTED: {
isConnected = true;
Serial.printf("[WSc] Service connected to sinric.com at url: %s\n", payload);
Serial.printf("Waiting for commands from sinric.com ...\n");
}
break;
case WStype_TEXT: {
Serial.printf("[WSc] get text: %s\n", payload);
// Example payloads
// For Switch or Light device types
// {"deviceId": xxxx, "action": "setPowerState", value: "ON"} // https://developer.amazon.com/docs/device-apis/alexa-powercontroller.html
// For Light device type
// Look at the light example in github
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject((char*)payload);
String deviceId = json ["deviceId"];
String action = json ["action"];
if(action == "setPowerState") { // Switch or Light
String value = json ["value"];
if(value == "ON") {
turnOn(deviceId);
} else {
turnOff(deviceId);
}
}
else if (action == "SetTargetTemperature") {
String deviceId = json ["deviceId"];
String action = json ["action"];
String value = json ["value"];
}
else if (action == "test") {
Serial.println("[WSc] received test command from sinric.com");
}
}
break;
case WStype_BIN:
Serial.printf("[WSc] get binary length: %u\n", length);
break;
} }
void setup() { Serial.begin(115200);
// Relay PIN eg: https://github.com/wemos/D1_mini_Examples/blob/master/examples/04.Shields/Relay_Shield/Blink/Blink.ino pinMode(relayPin, OUTPUT);
WiFiMulti.addAP(MySSID, MyWifiPassword); Serial.println(); Serial.print("Connecting to Wifi: "); Serial.println(MySSID);
// Waiting for Wifi connect while(WiFiMulti.run() != WL_CONNECTED) { delay(500); Serial.print("."); } if(WiFiMulti.run() == WL_CONNECTED) { Serial.println(""); Serial.print("WiFi connected. "); Serial.print("IP address: "); Serial.println(WiFi.localIP()); }
// server address, port and URL webSocket.begin("iot.sinric.com", 80, "/");
// event handler webSocket.onEvent(webSocketEvent); webSocket.setAuthorization("apikey", MyApiKey);
// try again every 5000ms if connection has failed webSocket.setReconnectInterval(5000); // If you see 'class WebSocketsClient' has no member named 'setReconnectInterval' error update arduinoWebSockets }
void loop() { webSocket.loop();
if(isConnected) { uint64_t now = millis();
// Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass
if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) {
heartbeatTimestamp = now;
webSocket.sendTXT("H");
}
}
}
// If you are going to use a push button to on/off the switch manually, use this function to update the status on the server // so it will reflect on Alexa app. // eg: setPowerStateOnServer("deviceid", "ON") void setPowerStateOnServer(String deviceId, String value) { DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.createObject(); root["deviceId"] = deviceId; root["action"] = "setPowerState"; root["value"] = value; StreamString databuf; root.printTo(databuf);
webSocket.sendTXT(databuf); }
//eg: setPowerStateOnServer("deviceid", "CELSIUS", "25.0") void setTargetTemperatureOnServer(String deviceId, String value, String scale) { DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.createObject(); root["action"] = "SetTargetTemperature"; root["deviceId"] = deviceId;
JsonObject& valueObj = root.createNestedObject("value"); JsonObject& targetSetpoint = valueObj.createNestedObject("targetSetpoint"); targetSetpoint["value"] = value; targetSetpoint["scale"] = scale;
StreamString databuf; root.printTo(databuf);
webSocket.sendTXT(databuf); }`
I checked the code for ChangeChannel . Sinric does send the correct response back to Amazon. Issue is likely from Amazon side
On Mon, 17 Sep 2018 at 8:23 AM Gustavo Lyra notifications@github.com wrote:
yes, i see the command WiFi connected. IP address: 192.168.100.22 [WSc] Service connected to sinric.com at url: / Waiting for commands from sinric.com ... [WSc] get text: {"deviceId":"5b8df18bf332cf2dc424f99f","action":"AdjustVolume","value":{"volume":10,"volumeDefault":true}} [WSc] get text: {"deviceId":"5b8df18bf332cf2dc424f99f","action":"AdjustVolume","value":{"volume":-10,"volumeDefault":true}} [WSc] get text: {"deviceId":"5b8df18bf332cf2dc424f99f","action":"setPowerState","value":"ON"} [WSc] get text: {"deviceId":"5b8df18bf332cf2dc424f99f","action":"ChangeChannel","value":{"channel":{},"channelMetadata":{"name":"tnt"}}}
ESP receive all commands, only the ChangeChannel alexa say: "Sorry, TV isn't responding"
My code: `#include
include
include
include
// https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
include
// https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
include
ESP8266WiFiMulti WiFiMulti; WebSocketsClient webSocket; WiFiClient client;
define MyApiKey XXXXXXXXXXXXXXXXXXXXX" // TODO: Change to your sinric API
Key. Your API Key is displayed on sinric.com dashboard
define MySSID "XXXXXX"
define MyWifiPassword "XXXXX"
define HEARTBEAT_INTERVAL 300000 // 5 Minutes
const int relayPin = D1;
uint64_t heartbeatTimestamp = 0; bool isConnected = false;
void setPowerStateOnServer(String deviceId, String value); void setTargetTemperatureOnServer(String deviceId, String value, String scale);
// deviceId is the ID assgined to your smart-home-device in sinric.com dashboard. Copy it from dashboard and paste it here
void turnOn(String deviceId) { if (deviceId == "YYYYYYYYYYYYYY") // Device ID of first device { Serial.print("Turn on device id: "); Serial.println(deviceId);
digitalWrite(relayPin, HIGH); // turn on relay with voltage HIGH
} else { Serial.print("Turn on for unknown device id: "); Serial.println(deviceId); } }
void turnOff(String deviceId) { if (deviceId == "YYYYYYYYYYYYYYY") // Device ID of first device { Serial.print("Turn off Device ID: "); Serial.println(deviceId);
digitalWrite(relayPin, LOW); // turn off relay with voltage LOW
} else { Serial.print("Turn off for unknown device id: "); Serial.println(deviceId); } }
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) { switch(type) { case WStype_DISCONNECTED: isConnected = false; Serial.printf("[WSc] Webservice disconnected from sinric.com!\n"); break; case WStype_CONNECTED: { isConnected = true; Serial.printf("[WSc] Service connected to sinric.com at url: %s\n", payload); Serial.printf("Waiting for commands from sinric.com ...\n"); } break; case WStype_TEXT: { Serial.printf("[WSc] get text: %s\n", payload); // Example payloads
// For Switch or Light device types // {"deviceId": xxxx, "action": "setPowerState", value: "ON"} // https://developer.amazon.com/docs/device-apis/alexa-powercontroller.html // For Light device type // Look at the light example in github DynamicJsonBuffer jsonBuffer; JsonObject& json = jsonBuffer.parseObject((char*)payload); String deviceId = json ["deviceId"]; String action = json ["action"]; if(action == "setPowerState") { // Switch or Light String value = json ["value"]; if(value == "ON") { turnOn(deviceId); } else { turnOff(deviceId); } } else if (action == "SetTargetTemperature") { String deviceId = json ["deviceId"]; String action = json ["action"]; String value = json ["value"]; } else if (action == "test") { Serial.println("[WSc] received test command from sinric.com"); }
} break; case WStype_BIN: Serial.printf("[WSc] get binary length: %u\n", length); break;
} }
void setup() { Serial.begin(115200);
// Relay PIN eg: https://github.com/wemos/D1_mini_Examples/blob/master/examples/04.Shields/Relay_Shield/Blink/Blink.ino pinMode(relayPin, OUTPUT);
WiFiMulti.addAP(MySSID, MyWifiPassword); Serial.println(); Serial.print("Connecting to Wifi: "); Serial.println(MySSID);
// Waiting for Wifi connect while(WiFiMulti.run() != WL_CONNECTED) { delay(500); Serial.print("."); } if(WiFiMulti.run() == WL_CONNECTED) { Serial.println(""); Serial.print("WiFi connected. "); Serial.print("IP address: "); Serial.println(WiFi.localIP()); }
// server address, port and URL webSocket.begin("iot.sinric.com", 80, "/");
// event handler webSocket.onEvent(webSocketEvent); webSocket.setAuthorization("apikey", MyApiKey);
// try again every 5000ms if connection has failed webSocket.setReconnectInterval(5000); // If you see 'class WebSocketsClient' has no member named 'setReconnectInterval' error update arduinoWebSockets }
void loop() { webSocket.loop();
if(isConnected) { uint64_t now = millis();
// Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) { heartbeatTimestamp = now; webSocket.sendTXT("H"); }
} }
// If you are going to use a push button to on/off the switch manually, use this function to update the status on the server // so it will reflect on Alexa app. // eg: setPowerStateOnServer("deviceid", "ON") void setPowerStateOnServer(String deviceId, String value) { DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.createObject(); root["deviceId"] = deviceId; root["action"] = "setPowerState"; root["value"] = value; StreamString databuf; root.printTo(databuf);
webSocket.sendTXT(databuf); }
//eg: setPowerStateOnServer("deviceid", "CELSIUS", "25.0") void setTargetTemperatureOnServer(String deviceId, String value, String scale) { DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.createObject(); root["action"] = "SetTargetTemperature"; root["deviceId"] = deviceId;
JsonObject& valueObj = root.createNestedObject("value"); JsonObject& targetSetpoint = valueObj.createNestedObject("targetSetpoint"); targetSetpoint["value"] = value; targetSetpoint["scale"] = scale;
StreamString databuf; root.printTo(databuf);
webSocket.sendTXT(databuf); }`
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/kakopappa/sinric/issues/115#issuecomment-421867326, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIM5un77DUL55eZPfCGMRTnxL30ZKjSks5ubvmvgaJpZM4WlTti .
is there anything else i could do, or just wait until amazon solve the problem ?
is there anything else i could do, or just wait until amazon solve the problem ?
I believe you need to report the issue back to amazon so they can try to solve it, on your alexa app go to feedback option
Hello, I have same problem. Was someone able to fix it?
Hello, I have the same problem. How and what should we tell Amazon to fix it?
Thank you,
regards
Same issue here. Still not working
Great work @kakopappa. The Code is working fine as far as Volume, Mute, Unmute, On/Off are concerned with proper reply from Alexa. However, any attempt to change channel gives a response "Sorry, Tata Sky/TV is not responding". While, the channels are changing as desired. It is very disappointing. I think @kakopappa sir, you need to re-look at the issue and resolve the reported bug.
The response on serial port is as follows:
[WSc] get text: {"deviceId":"5bddf1832d8b221d153d7d57","action":"setPowerState","value":"OFF"} [WSc] get text: {"deviceId":"5bf83accded8b075eb77ef7f","action":"SetMute","value":{"mute":false}} [WSc] get text: {"deviceId":"5bf83accded8b075eb77ef7f","action":"SetMute","value":{"mute":true}} [WSc] get text: {"deviceId":"5bf83accded8b075eb77ef7f","action":"SkipChannels","value":{"channelCount":1}} [WSc] get text: {"deviceId":"5bf83accded8b075eb77ef7f","action":"ChangeChannel","value":{"channel":{"number":"147"},"channelMetadata":{}}} [WSc] channel Number: 147
here is the problem about "ChangeChannel". Amazon docs does not say anything appropriate response format for changechannel .
https://developer.amazon.com/docs/device-apis/alexa-channelcontroller.html#changechannel
so I send the same response for "SkipChannels" call. May be it does not match with what Alexa expect it to be. Need to resolve this with Amazon Alexa. Raising an issue
By the way, did you check the following, mentioned on Alexa docs.
Response You must send an Response event if a request to change or skip channels was successful. The response should include a context object that reports the channel after the request completes.
Response Example
{ "context": { "properties": [ { "namespace": "Alexa.ChannelController", "name": "channel", "value": { "number": "1234", "callSign": "callsign1", "affiliateCallSign": "callsign2" }, "timeOfSample": "2017-02-03T16:20:50.52Z", "uncertaintyInMilliseconds": 0 } ] }, "event": { "header": { "messageId": "abc-123-def-456", "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", "namespace": "Alexa", "name": "Response", "payloadVersion": "3" }, "endpoint":{ "endpointId":"appliance-001" }, "payload":{ } } } ErrorResponse You should reply with an error if you cannot complete the customer request for some reason. See Alexa.ErrorResponse for more details.
Additional Sample Code See the sample request and response messages in the Alexa smart home GitHub repo:
ChannelController
Thanks. Last time I check this is the response for the command I send back. I will check again on this weekend
On Wed, 28 Nov 2018 at 9:35 PM amitabh-srivastav notifications@github.com wrote:
By the way, did you check the following, mentioned on Alexa docs.
Response You must send an Response event if a request to change or skip channels was successful. The response should include a context object that reports the channel after the request completes.
Response Example
{ "context": { "properties": [ { "namespace": "Alexa.ChannelController", "name": "channel", "value": { "number": "1234", "callSign": "callsign1", "affiliateCallSign": "callsign2" }, "timeOfSample": "2017-02-03T16:20:50.52Z", "uncertaintyInMilliseconds": 0 } ] }, "event": { "header": { "messageId": "abc-123-def-456", "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", "namespace": "Alexa", "name": "Response", "payloadVersion": "3" }, "endpoint":{ "endpointId":"appliance-001" }, "payload":{ } } } ErrorResponse You should reply with an error if you cannot complete the customer request for some reason. See Alexa.ErrorResponse for more details.
Additional Sample Code See the sample request and response messages in the Alexa smart home GitHub repo:
ChannelController
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/kakopappa/sinric/issues/115#issuecomment-442467866, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIM5usm6N-0vEH-cZlNLvEJ7Qdz0Gwiks5uzp8hgaJpZM4WlTti .
Thanks, you may have a look at this one for Response : https://github.com/alexa/alexa-smarthome/tree/master/sample_messages/ChannelController
Dear @kakopappa sir, any update on the issue?
Dear @kakopappa, could you investigate this issue again, please?
@Comotio82 @amitabh-srivastav sorry guys. i will check it on this weekend again
hi, even I myself problem with Italian language, however, compliments for the work done
@kakopappa Any update on the issue as promised.
Hi @kakopappa, I will spend you some beer if you are able to fix this issue. Kind regards
found the issue and fixed it. enjoy!
I can confirm it works well now. Thank you! Enjoy your beer.
thanks. sorry about the delay. I was sick like 2 weeks.
Thanks a lot dear @kakopappa !
Today I have the same issue. https://github.com/kakopappa/sinric/issues/105#issuecomment-450570380
The message is received but Alexa says: "Sorry the device is not responding"
[WSc] get text: {"deviceId":"xxxxx","action":"AdjustPercentage","value":{"percentageDelta":25}} AdjustPercentage [WSc] get text: {"deviceId":"xxxxx","action":"AdjustPercentage","value":{"percentageDelta":-25}} AdjustPercentage
Note: my Alexa reply in Italian, I don'know if there is a problem with my language.
Thank's @kakopappa
@clabnet server will send OK back to Alexa once it forwards the command to your ESP module, You do not have to do anything for this.
can you check again, please ? I can turn on/off fine.
Yes the Ccmmand IS ok but Alexa reply 'sorry...' It IS not good as vocal feedback. Il 31 dic 2018 12:47 PM, Aruna Tennakoon notifications@github.com ha scritto:@clabnet server will send OK back to Alexa once it forwards the command to your ESP module, You do not have to do anything for this. can you check again, please ? I can turn on/off fine.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
I'm still getting "Sorry the device is not responding" when setting inputs / changing channels on a TV device? I have disabled and re-enabled the Alexa skill but still alexa says not responding even though the ESP8266 recieves the command.
I'm still getting "Sorry the device is not responding" when setting inputs / changing channels on a TV device? I have disabled and re-enabled the Alexa skill but still alexa says not responding even though the ESP8266 recieves the command.
Hi @kakopappa, I can confirm that for TV the input controller - although it is working ok - gets an Alexa response of "Sorry the device is not responding".
In my skill I do receive a good request from my point of view: [WSc] get text: {"deviceId":"xyz","action":"SelectInput","value":{"input":"HDMI 1"}}
So I think something with the response you are sending back to Amazon must be wrong, so Alexa thinks it was not working ...
In June 2018 you mentioned you had checked your response and it looked ok https://github.com/kakopappa/sinric/issues/76#issuecomment-399661519 ... but I doubt that Amazon has this bug for so long, as many people would be using input controller by now.
Would you be able to double check your response again?
If I find the time to convert my .ino to sinric.pro, I will do so in order to see if this is the same on sinric.pro, but right now I do not have enough skill to change all to sinric.pro asap ...
Thanks for your help - MacSass
When i ask alexa to change channel, ESP receive the command but alexa say "Sorry, TV isn't responding". This only happens when i ask to change channel, change volume works fine.
Do ESP need to send something to alexa after receive the command to change channel?