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
Other
236 stars 125 forks source link

Need help with script for ESP8266 #75

Closed EkanshdeepGupta closed 4 years ago

EkanshdeepGupta commented 4 years ago

Hi, I have been looking at the code but I cannot seem to figure out how to do the simple thing that I was able to do with old Sinric easily. I just want to control lights etc by telling Google Home what to do, and then the Sinric backend should send command to my ESP8266 board to control it using a relay board.

The code at https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/examples/Switch/MultiSwitch_beginner.ino does not mention specific pins on the ESP board, so how is it supposed to control the relay? Or is it the case that I am supposed to add the relay board stuff manually in the onPowerStateX functions?

Thank you so much in advance, I really hope I am able to make this work.

Also, what is the state of Google Home integration, I don't have an Alexa. Is IFTTT still the only way?

sivar2311 commented 4 years ago

Hi!

Your post contains questions on various topics. Since I am the developer of the SDK, I will answer the SDK specific questions.

The example MultiSwitch_beginner.ino is not suitable for a light device. Here the device type SinricProLight (see the example Light.ino or Light_FastLED_WS2812.ino) would be more suitable, because much more functions than on/off are supported (dim light, adjust color etc.)

Because of the flexibility, the SinricProSDK does not contain any PIN definitions, not even the examples. For complex devices, like a TV, simple commands like digitalWrite or similar cannot be used. Here the control can be done e.g. via infrared or network commands. All this depends very much on the television set used. Therefore the control of the (hardware) devices is left to the user and must be implemented in the respective callbacks.

As you have correctly noticed, you have to implement the relay related stuff yourself. To control a relay, a simple digitalWrite in the onPowerState callback is sufficient. If you also want to dim your light, you have to implement the dimming function in the setBrightness and adjuStBrightness callbacks. The control can also be done differently here, depending on the hardware used. A simple LED can be dimmed with analogWrite, but this is not possible with a WS2812b LED. For this reason there are no PIN definitions.

kakopappa commented 4 years ago

IFTTT is already available. You can use IFTTT to control your devices via Google Home

https://help.sinric.pro/pages/ifttt.html

On Wed, 8 Jul 2020 at 8:49 PM Boris Jäger notifications@github.com wrote:

Hi!

Your post contains questions on various topics. Since I am the developer of the SDK, I will answer the SDK specific questions.

The example MultiSwitch_beginner.ino is not suitable for a light device. Here the device type SinricProLight (see the example Light.ino https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/examples/Light/Light.ino or Light_FastLED_WS2812.ino https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/examples/Light/Light_FastLED_WS2812.ino) would be more suitable, because much more functions than on/off are supported (dim light, adjust color etc.)

Because of the flexibility, the SinricProSDK does not contain any PIN definitions, not even the examples. For complex devices, like a TV, simple commands like digitalWrite or similar cannot be used. Here the control can be done e.g. via infrared or network commands. All this depends very much on the television set used. Therefore the control of the (hardware) devices is left to the user and must be implemented in the respective callbacks.

As you have correctly noticed, you have to implement the relay related stuff yourself. To control a relay, a simple digitalWrite in the onPowerState callback is sufficient. If you also want to dim your light, you have to implement the dimming function in the setBrightness and adjuStBrightness callbacks. The control can also be done differently here, depending on the hardware used. A simple LED can be dimmed with analogWrite, but this is not possible with a WS2812b LED. For this reason there are no PIN definitions.

— 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/75#issuecomment-655532469, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZQFDQCT2IMXNCZECB3R2R2PNANCNFSM4OUJSWRA .

kakopappa commented 4 years ago

GH + IFTTT

https://help.sinric.pro/pages/ifttt-googlehome.html

EkanshdeepGupta commented 4 years ago

@sivar2311 thanks a lot, your comment clears up everything. To ensure I understand it correctly, when I trigger a switch on or off, the Sinric backend will handle that request and execute the appropriate functions on my ESP8266 board, for example the onPowerState function etc right?

Thanks a lot.

@kakopappa my question was is there a direct way to link my sinric devices with Google Home (without using IFTTT)? Or is IFTTT still the only way?

sivar2311 commented 4 years ago

@EkanshdeepGupta Yes that's correct! Please check also the full user documentation for all supported device types and their callbacks.

kakopappa commented 4 years ago

@EkanshdeepGupta There's no direct way as of now. pending approval.