Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartThings and Google Home integration not working #213

Closed
sensboston opened this issue Sep 17, 2021 · 21 comments
Closed

SmartThings and Google Home integration not working #213

sensboston opened this issue Sep 17, 2021 · 21 comments
Labels
stale Issue that may be closed soon due to the original author not responding any more.

Comments

@sensboston
Copy link

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
Copy link
Author

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
Copy link
Contributor

kakopappa commented Sep 18, 2021 via email

@sensboston
Copy link
Author

sensboston commented Sep 18, 2021

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
Copy link
Contributor

kakopappa commented Sep 18, 2021 via email

@sivar2311
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

kakopappa commented Sep 20, 2021 via email

@sensboston
Copy link
Author

sensboston commented Sep 20, 2021

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
Copy link
Contributor

kakopappa commented Sep 20, 2021 via email

@sensboston
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

kakopappa commented Sep 22, 2021

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
Copy link
Contributor

kakopappa commented Sep 22, 2021

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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

image

looks like the link marked in red is broken. thanks

@sensboston
Copy link
Author

Thanks!

@stale
Copy link

stale bot commented Oct 1, 2021

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 stale bot added the stale Issue that may be closed soon due to the original author not responding any more. label Oct 1, 2021
@stale
Copy link

stale bot commented Oct 8, 2021

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!

@stale stale bot closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

3 participants