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 121 forks source link

Ino code for garagedoor with gpio for relay and contact sensor #263

Closed mjtrini closed 2 years ago

mjtrini commented 2 years ago

Hello Sinric pro,

Can you provide the code to set the digital pins on the esp8266 to activate a garage door wall switch and also to read the garage open closed state?

The existing example does not show how to assign pin numbers for digital out and digital read.

Thanks, Michael.

sivar2311 commented 2 years ago

Hello @mjtrini!

The library is only for communication with the SinricPro server. For this reason, the examples are all kept relatively open and do not include specific implementations. You need to adapt the code according to the requirements of your garage door opener.

For controlling the garage door, you will need to add appropriate commands to the onDoorState callback.

You can send the current state via the sendDoorStateEvent function (see documentation).

Do you know how to control and query the current state of your garage door? Or do you already have a (non-SinricPro) sketch for controlling / retrieving your garage door? Then I would be happy to help you with the adaptation.

mjtrini commented 2 years ago

Hello @mjtrini!

The library is only for communication with the SinricPro server. For this reason, the examples are all kept relatively open and do not include specific implementations. You need to adapt the code according to the requirements of your garage door opener.

For controlling the garage door, you will need to add appropriate commands to the onDoorState callback.

You can send the current state via the sendDoorStateEvent function (see documentation).

Do you know how to control and query the current state of your garage door? Or do you already have a (non-SinricPro) sketch for controlling / retrieving your garage door? Then I would be happy to help you with the adaptation.

Hello,

Here is the sketch I'm using. It is pretty large since it include an Async webserver and telegram controls. I'm attaching it into the reply here. If there is an more appropriate means then please let me know. Much thanks! AMbp1t.zip

sivar2311 commented 2 years ago

The code is indeed a bit confusing. Unfortunately, I cannot see at first glance which functions are responsible for the garage door and which GPIO is responsible for a particular function.

Can you perhaps create a very simple example that controls the garage door (open / close) and queries the status?

I would suggest that you create a repository for this and publish your code there. This has the great advantage that we can work together on the source code.

Please also define and name the GPIOs. For example: a digtialWrite(2, HIGH) can mean anything - the meaning will not be clear to me. But if you write const int gpio_gate_open = 2; beforehand and then digitalWrite(gpio_gate_open, HIGH) later, the meaning will be obvious to me. :)

mjtrini commented 2 years ago

My apologies! Here is a much simpler version of the code with suitable comments for easier following of the sketch. The sketch controls two motors and also takes the status of the door closed position via magnetic reed switches between the gpio and 0V. I have noticed that the sinric pro code causes crashes when inserted into an Asynch webserver on the ESP8266. test.zip .

mjtrini commented 2 years ago

I just made my very first repository as you suggested. The name of it is: sinric-pro-garage-controller

sivar2311 commented 2 years ago

Cool!

I have created a new issue in your repository. Let's continue there.

mjtrini commented 1 year ago

Hi Good Morning,

Thank you for the rapid reply. How do I send you the sketch I'm using for the esp8266 that controls my garage? Basically I'm using a nodemcu board with gpio5 to activate the garage (or gate) motor controller and gpio14 to read the status of a magnetic sensor ( for garage or gate fully closed position).

Regards, Michael James.

------ Original Message ------ From: "sivar2311" @.> To: "sinricpro/esp8266-esp32-sdk" @.> Cc: "mjtrini" @.>; "Mention" @.> Sent: 28-Apr-22 8:41:33 AM Subject: Re: [sinricpro/esp8266-esp32-sdk] Ino code for garagedoor with gpio for relay and contact sensor (Issue #263)

Hello @mjtrini https://github.com/mjtrini!

The library is only for communication with the SinricPro server. For this reason, the examples are all kept relatively open and do not include specific implementations. You need to adapt the code according to the requirements of your garage door opener.

For controlling the garage door, you will need to add appropriate commands to the onDoorState callback.

You can send the current state via the sendDoorStateEvent function (see documentation https://sinricpro.github.io/esp8266-esp32-sdk/class_door_controller.html#a54e5b81baedd99d5e03383eab7da909e).

Do you know how to control and query the current state of your garage door? Or do you already have a (non-SinricPro) sketch for controlling / retrieving your garage door? Then I would be happy to help you with the adaptation.

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/263#issuecomment-1112155478, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX2DVI25LLE7E6GXTZ7D2CDVHKBP3ANCNFSM5USHTGTA. You are receiving this because you were mentioned.Message ID: @.***>

kakopappa commented 1 year ago

Hi @mjtrini

Please create a new issue https://github.com/sinricpro/esp8266-esp32-sdk/issues/new and put the code there without credentials.