sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
228 stars 122 forks source link

SmartThings and Google Home integration not working #213

Closed sensboston closed 2 years ago

sensboston commented 2 years ago

I'm trying to replace MQTT IFTTT service for my ESP32 smart devices (because IFTTT recently stopped working for me without any reason, and their support is very slow and aren't helpful at all), but also have troubles with Sinric Pro. I followed examples you provided, and did exactly as you said but results are completely differ from manual. I do have two devices: IR transmitter connected to AC window unit, and motorized roller blind (both ESP32 based). So, I created two devices on Sinric Pro website but implemented test code just for my "smart remote" (based on "Window AC unit" template)

Unfortunately, Samsung "SmartThings" app can't see that unit (only non-implemented "Smart blind" is visible)

"Google Home" app is also can't find any Sinric Pro device:

So, what I'm doing wrong, and how to fix issue? I really wanna get rid from IFTTT - I signed up for "Pro" plan but their support aren't "pro" at all :( However, before shit happened, everything on IFTTT worked as described.

sensboston commented 2 years ago

UPDATE: after adding another device (I've used "switch" template, all devices started appearing magically in "Google Home"! And (at least, AC unit) is working pretty well and fast.

P.S. As far as I understand, all these events:

    myAcUnit.onPowerState(onPowerState);
    myAcUnit.onTargetTemperature(onTargetTemperature);
    myAcUnit.onAdjustTargetTemperature(onAdjustTargetTemperature);
    myAcUnit.onThermostatMode(onThermostatMode);

are predefined by Google, right? My AC is pretty standard AC with IR remote (I've substituted by ESP32 with RF transmitter), the remote don't have an option to set temperature or get some feedback from AC unit, it simple commands: temp lower/higher, fan speed lower/higher, mode cold/eco/fan. But looks like AC_UNIT type is assuming more "intellectual" AC? Is there a way to implement standard AC IR remote with Google Home, what you can suggest?

Thank you!

kakopappa commented 2 years ago

We have been approved to use following device types with Google Home;

switch, blind, thermostat, fan, AC_unit and light, garage door, lock

Others are not supported and won’t appear in the Google Home app.

Callback are standard, and they are defined by us. We try to it consistent between Alexa, Google Home and SmartThings

For IR control, we have more intelligent device coming up (irdevkit.com) which can record IR and resend them back. Sinric Pro integration is coming soon.

You need to send the correct IR code in the callback to support any Air Conditioner

On Sat, 18 Sep 2021 at 4:51 AM SeNS @.***> wrote:

UPDATE: after adding another device (I've used "switch" template, all devices started appearing magically in "Google Home"! And (at least, AC unit) is working pretty well and fast.

P.S. As far as I understand, all these events:

myAcUnit.onPowerState(onPowerState);
myAcUnit.onTargetTemperature(onTargetTemperature);
myAcUnit.onAdjustTargetTemperature(onAdjustTargetTemperature);
myAcUnit.onThermostatMode(onThermostatMode);

are predefined by Google, right? My AC is pretty standard AC with IR remote (I've substituted by ESP32 with RF transmitter), the remote don't have an option to set temperature or get some feedback from AC unit, it simple commands: temp lower/higher, fan speed lower/higher, mode cold/eco/fan. But looks like AC_UNIT type is assuming more "intellectual" AC? Is there a way to implement standard AC IR remote with Google Home, what you can suggest?

Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/213#issuecomment-922100931, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZW6TBO6BUMCMPBIM7DUCOZ53ANCNFSM5EIG6PPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

sensboston commented 2 years ago

Callback are standard, and they are defined by us.

Could you please add callback for controlling fan speed on AC_unit? You haven't published source code so I can't change by myself.

For IR control, we have more intelligent device coming up

I already have more intelligent device, but thanks for offering.

kakopappa commented 2 years ago

Will take a look at adding this in the future

On Sat, 18 Sep 2021 at 9:42 PM SeNS @.***> wrote:

Callback are standard, and they are defined by us.

Could you please add callback for controlling fan speed on AC_unit? You haven't published source code so I can't change by myself.

For IR control, we have more intelligent device coming up

I already have more intelligent device https://github.com/sensboston/SmartRemote, but thanks for offering.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/213#issuecomment-922311557, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZWCYM3BKYJFIBRSK43UCSQOXANCNFSM5EIG6PPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

sivar2311 commented 2 years ago

The window air conditioner already has a fan speed control (speed 1 to 3):

bool onRangeValue(const String& deviceId, int& speed) {
    Serial.printf("Speed is set to %d\r\n", speed); // print speed
    return true;
}

...
  myAcUnit.onRangeValue(onRangeValue);
...
sensboston commented 2 years ago

Thanks! That event is missing in AC unit example; looks like it's exactly what I need. Do you remember Google Assistant voice command for controlling window AC fan speed? Could you please remind me?

sensboston commented 2 years ago

By the way, guys, today Android app shows me an error type _Double is not a subtype of type 'int' . Samsung's "SmartThings" also show device status offline (but it's not). On portal everything is OK.

kakopappa commented 2 years ago

Are you using the latest version of the app?

On Mon, Sep 20, 2021 at 10:37 PM SeNS @.***> wrote:

By the way, guys, today Android app shows me an error type _Double is not a subtype of type 'int' . Samsung's "SmartThings" also show device status offline (but it's not). On portal https://portal.sinric.pro/dashboard everything is OK.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/213#issuecomment-923042227, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXKSACZ3UXEFMO4VUDUC5IMPANCNFSM5EIG6PPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

sensboston commented 2 years ago

Yes, of course. I'm also tried to clear cache & data - no changes. On Saturday everything worked fine; I also tried to reflash updated FW (with added onRangeValue - see above), no changes (btw, I'm still have no idea how to change AC unit fan speed by Assistant voice command)

By the way, device & internet is up and running, Google Assitant commands are also working fine.

kakopappa commented 2 years ago

Seems your device's target temperature has gone to -17.22222 so I have reset it back to 0.

  1. App seems to have an issue dealing with decimals. I will fix it in the next release.

  2. Google Home's AC_UNIT needs to be updated to support FAN speed. Might have to submit again for approval for this. Will let you know when ready

On Mon, Sep 20, 2021 at 11:24 PM SeNS @.***> wrote:

Yes, of course. I'm also tried to clear cache & data - no changes. On Saturday everything worked fine; I also tried to reflash updated FW (with added onRangeValue - see above), no changes (btw, I'm still have no idea how to change AC unit fan speed by Assistant voice command)

https://user-images.githubusercontent.com/1036158/134037348-89e367ef-3f9b-4ad8-a771-28c23d6c9a62.jpg https://user-images.githubusercontent.com/1036158/134037367-4a308af0-12f0-4068-a9d2-36e2eeee9f5c.jpg

By the way, device & internet is up and running, Google Assitant commands are also working fine. My public IP is 108.20.145.207, login email is: @. @.>*

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/213#issuecomment-923081211, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXHKOHS33SBJ77ESOLUC5N43ANCNFSM5EIG6PPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

sensboston commented 2 years ago

Thanks a lot!

P.S. Your project and support are really helpful, I just bought a paid subscription for 3 devices (don't actually need it but wanna support you guys)!

kakopappa commented 2 years ago

I have updated the Google Home configuration to support Fan in AC Unit now.

When you say "Set the AC unit fan speed to 10"

Google sends this command, "command":"action.devices.commands.SetFanSpeed","commandParams":{"fanSpeedPercent":10},

This command translates to setRangeValue Sinric command, so you need to have this callback.

When you say, set the "Set the AC unit mode to fan only" This command translates to setThermostatMode mode with {"thermostatMode":"fan-only"} , so you need to add the callback for this.

you can also say "Set the AC unit fan speed to low" "Set the AC unit fan speed to high"

sensboston commented 2 years ago

I just tried but onRangeValue never called and Google Assistant can't recognize the sentence (I tried a lot of variants). Also, Android app restored to work yesterday but now has the same error I've mentioned above.

kakopappa commented 2 years ago

When I say: Set the "AC Unit" fan speed to 1, I can see the command in Arduino Serial Monitor.

DEMO:

ac-unit

Maybe you need to do a rediscovery for GH devices.

Here's the sketch I used:

/*
 * Example for how to use the AC Unit
 * 
 * If you encounter any issues:
 * - check the readme.md at https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md
 * - ensure all dependent libraries are installed
 *   - see https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#arduinoide
 *   - see https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#dependencies
 * - open serial monitor and check whats happening
 * - check full user documentation at https://sinricpro.github.io/esp8266-esp32-sdk
 * - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
 */

// Uncomment the following line to enable serial debug output
#define ENABLE_DEBUG

#ifdef ENABLE_DEBUG
       #define DEBUG_ESP_PORT Serial
       #define NODEBUG_WEBSOCKETS
       #define NDEBUG
#endif 

#include <Arduino.h>
#ifdef ESP8266 
       #include <ESP8266WiFi.h>
#endif 
#ifdef ESP32   
       #include <WiFi.h>
#endif

#include "SinricPro.h"
#include "SinricProWindowAC.h"

#define WIFI_SSID         ""    
#define WIFI_PASS         ""
#define APP_KEY           ""      // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET     ""   // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define ACUNIT_ID       ""    // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE         9600                     // Change baudrate to your need

float globalTemperature;
bool globalPowerState;

bool onPowerState(const String &deviceId, bool &state) {
  Serial.printf("Thermostat %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
  globalPowerState = state; 
  return true; // request handled properly
}

bool onTargetTemperature(const String &deviceId, float &temperature) {
  Serial.printf("Thermostat %s set temperature to %f\r\n", deviceId.c_str(), temperature);
  globalTemperature = temperature;
  return true;
}

bool onAdjustTargetTemperature(const String & deviceId, float &temperatureDelta) {
  globalTemperature += temperatureDelta;  // calculate absolut temperature
  Serial.printf("Thermostat %s changed temperature about %f to %f", deviceId.c_str(), temperatureDelta, globalTemperature);
  temperatureDelta = globalTemperature; // return absolut temperature
  return true;
}

bool onThermostatMode(const String &deviceId, String &mode) {
  Serial.printf("Thermostat %s set to mode %s\r\n", deviceId.c_str(), mode.c_str());
  return true;
}

bool onRangeValue(const String &deviceId, int &rangeValue) {
  Serial.printf("Fan speed changed to %d\r\n", rangeValue);
  return true;
}

bool onAdjustRangeValue(const String &deviceId, int &rangeValueDelta) {
  Serial.printf("Fan speed adjusted to to %d\r\n", rangeValueDelta);
  return true;
}

void setupWiFi() {
  Serial.printf("\r\n[Wifi]: Connecting");
  WiFi.begin(WIFI_SSID, WIFI_PASS);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.printf(".");
    delay(250);
  }
  IPAddress localIP = WiFi.localIP();
  Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
}

void setupSinricPro() {
  SinricProWindowAC &myAcUnit = SinricPro[ACUNIT_ID];
  myAcUnit.onPowerState(onPowerState);
  myAcUnit.onTargetTemperature(onTargetTemperature);
  myAcUnit.onAdjustTargetTemperature(onAdjustTargetTemperature);
  myAcUnit.onThermostatMode(onThermostatMode);
  myAcUnit.onThermostatMode(onThermostatMode);
  myAcUnit.onRangeValue(onRangeValue);
  myAcUnit.onAdjustRangeValue(onAdjustRangeValue);

  // setup SinricPro
  SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); 
  SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
  SinricPro.begin(APP_KEY, APP_SECRET);
}

void setup() {
  Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
  setupWiFi();
  setupSinricPro();
}

void loop() {
  SinricPro.handle();
}
kakopappa commented 2 years ago

I have fixed the issue related to -17.22222. The issue was not sending the correct thermostatTemperatureUnit to Google Home during the discovery process. Please relink the GH action.

I still need to fix the app to handle the conversation error. however, this may take time. I am in the middle of upgrading the app to the latest version of Flutter.

sensboston commented 2 years ago

OK, thanks, I confirm: after reconnecting SinricPro to Google Home, AC fan speed commands become recognizable. Now I can set fan speed by saying: "Hey Google, set bedroom fan speed to high/low/medium" (or percentage but it's not supported by AC of course). Thanks a lot!

sensboston commented 2 years ago

Hey, Aruna, could you please tell me: do I still need a Samsung "SmartThings" app installed, or you're working with Google Home directly? If not, might be a good idea to update your manuals? BTW, this one returning 404.

kakopappa commented 2 years ago

You don't need ST if GH works for you.

image

looks like the link marked in red is broken. thanks

sensboston commented 2 years ago

Thanks!

stale[bot] commented 2 years ago

This issue has gone quiet. Spooky quiet. We currently close issues after 14 days of inactivity. It’s been at least 7 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks for being a part of the SinricPro community!

stale[bot] commented 2 years ago

Hey again! It’s been 14 days since anything happened on this issue, so our friendly robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks again for being a part of the SinricPro community!