sinricpro / feature-requests

Feature request tracker for Sinric Pro
0 stars 0 forks source link

Alexa won't let me create a routine with my DHT11 temperature sensor #28

Closed ogabrielborges closed 1 year ago

ogabrielborges commented 1 year ago

When creating a Temperature Sensor device in SinricPro, I cannot create a routine with it in Alexa, as Alexa only allows me to "turn off and on" the sensor.

How can I resolve this?

(I'm using a NodeMCU 0.9 and a DHT11 sensor with the DHT.h library and the code for this sensor that Sinric provides)

image

About air humidity, I saw in some forums that it is not accepted by Alexa, correct me if I'm wrong.

kakopappa commented 1 year ago

Last time we checked temperature sensors are not supported try contact sensor instead

On Sun, 8 Jan 2023 at 2:00 PM Gabriel Borges @.***> wrote:

When creating a Temperature Sensor device in SinricPro, I cannot create a routine with it in Alexa, as Alexa only allows me to "turn off and on" the sensor.

How can I resolve this?

(I'm using a NodeMCU 0.9 and a DHT11 sensor with the DHT.h library and the code for this sensor that Sinric provides)

[image: image] https://user-images.githubusercontent.com/36484705/211184394-5e8bf076-1529-44cd-8267-9c82ea4cc985.png

About air humidity, I saw in some forums that it is not accepted by Alexa, correct me if I'm wrong.

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/feature-requests/issues/28, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZQJG5C3J6JUGGA6FR3WRJQZDANCNFSM6AAAAAATUNBCDA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ogabrielborges commented 1 year ago

I'll leave this problem aside for now, because I have a bigger concern:

Can I use an Arduino with an Ethernet Shield W5100 in SinricPro?

kakopappa commented 1 year ago

Officially we don’t support. However there’s a community repo here you can try.

https://github.com/khoih-prog/SinricPro_Generic

On Mon, 9 Jan 2023 at 12:02 PM Gabriel Borges @.***> wrote:

I'll leave this problem aside for now, because I have a bigger concern:

Can I use an Arduino with an Ethernet Shield W5100 in SinricPro?

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/feature-requests/issues/28#issuecomment-1375108710, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXALUW4EKXM76LXIY3WROLXPANCNFSM6AAAAAATUNBCDA . You are receiving this because you commented.Message ID: @.***>

ogabrielborges commented 1 year ago

Sorry to bother you again, but I would like to inform SinricPro that the lock was locked/unlocked when I pressed a button, how would the code look like?

sivar2311 commented 1 year ago

You can use the sendLockStateEvent function.

myDevice.sendLockStateEvent(true); // device is locked myDevice.sendLockStateEvent(false); // device is unlocked

ogabrielborges commented 1 year ago

The code does not compile, my idea is to pass an RFID card registered in my MFRC522 module, pin 2 and 1 change to low and the state of the lock changes to open, and after 3 seconds, to closed and the pins to high code.txt

sivar2311 commented 1 year ago

The code does not compile

You don't have a myLock instance in your loop() !

So you have to add SinricProLock& myLock = SinricPro[LOCK_ID]; in the loop()-function too!

ogabrielborges commented 1 year ago

Very good, thank you SO MUCH for the help, I graduate in Information Systems and I'm still in my infancy in programming but I really like arduino and I'm trying to get by!

Help me with something else: What do I need to do in the code to define the lock as unlocked in sinricpro, wait 5 seconds and it locks?

I suppose I need to tweak something around here, but you're the one who can tell me bro:

(this code is before void setup) bool onLockState(String deviceId, bool &lockState) { digitalWrite(LOCK_PIN, lockState); // apagar Serial.printf("A fechadura foi %s\r\n", lockState?"fechada":"aberta"); return true; }

sivar2311 commented 1 year ago

This is how i would do:

define a global timer variable unsigned long timer = 0;

In the onLockState callback:


  if (lockState == false) // door should unlock
  {
    timer = millis() + 5000; // start the timer;
    lockState = true; // keep the lock state on server "locked" because it relocks within 5 seconds automatically
  } 
  digitalWrite(LOCK_PIN, state);

Write a timer handler function that check if the timer has been set and handle the lock:

void handleTimer() {
  if (timer  == 0) return; // nothing to do (timer not set)

  if (millis() >= timer) {
    digitalWrite(LOCK_PIN, HIGH); // re-lock
    timer = 0; // reset timer
  }
}

It doesn't make sense to send an event to the sinric pro server, because the time of 5 seconds is too short.

Add handleTimer() function to the main loop()

Note: Code not tested

sivar2311 commented 1 year ago

The current issue no longer corresponds to the original issue.

I therefore ask you to open a new issue.

For questions about esp8266-esp32-sdk please open an issue in the esp8266-esp32-sdk repository.

Thanks for your understanding.