sinricpro / feature-requests

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

Alexa read back other Air Quality, C02, N02, CH20, #16

Open TPCQitek opened 1 year ago

TPCQitek commented 1 year ago

Originally posted by @TPCQitek in https://github.com/sinricpro/feature-requests/issues/14#issuecomment-1319479300


revised question, so much like the read back PM2.5 (as inAirQualitySensor.h) this allow me to add my Sensor reading values, I would like to have at minimum additionally (C02, N02, CH20,) as a read back.

thanks.

kakopappa commented 1 year ago

As you know there’s no built-in device type for C02/N02/CH20 so you must create a custom device type for this.

Take a look at the documentation https://help.sinric.pro/pages/custom-templates

  1. First create a device template and add multiple Range Capabilities for c02/n02/ch20. Range capability has the ability to show a number and you can inquire then in Alexa as well.

  2. Save the template

  3. Go and create a new device and use the new template name you created earlier as the device type.

  4. Save the device

  5. Once you save the device you can generate the code for the custom device in devices tab in portal

  6. Download the code . Call the update function with the values to update the server with c02/n02/ch20

On Mon, 21 Nov 2022 at 12:56 PM TERENCE P CURTIS @.***> wrote:

Originally posted by @TPCQitek https://github.com/TPCQitek in #14 (comment) https://github.com/sinricpro/feature-requests/issues/14#issuecomment-1319479300

revised question, so much like the read back PM2.5 (as inAirQualitySensor.h) this allow me to add my Sensor reading values, I would like to have at minimum additionally (C02, N02, CH20,) as a read back.

thanks.

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

TPCQitek commented 1 year ago

hello, ok thanks, how to set the "Unit of Measure" ? as I need things like PPM ug/m3 etc..

thanks

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Mon, 21 Nov 2022 at 18:00, Aruna Tennakoon @.***> wrote:

As you know there’s no built-in device type for C02/N02/CH20 so you must create a custom device type for this.

Take a look at the documentation https://help.sinric.pro/pages/custom-templates

  1. First create a device template and add multiple Range Capabilities for c02/n02/ch20. Range capability has the ability to show a number and you can inquire then in Alexa as well.

  2. Save the template

  3. Go and create a new device and use the new template name you created earlier as the device type.

  4. Save the device

  5. Once you save the device you can generate the code for the custom device in devices tab in portal

  6. Download the code . Call the update function with the values to update the server with c02/n02/ch20

On Mon, 21 Nov 2022 at 12:56 PM TERENCE P CURTIS @.***> wrote:

Originally posted by @TPCQitek https://github.com/TPCQitek in #14 (comment) < https://github.com/sinricpro/feature-requests/issues/14#issuecomment-1319479300

revised question, so much like the read back PM2.5 (as inAirQualitySensor.h) this allow me to add my Sensor reading values, I would like to have at minimum additionally (C02, N02, CH20,) as a read back.

thanks.

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/feature-requests/issues/16, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABZAZZS4QMVASCOLAFUIZCLWJMFKFANCNFSM6AAAAAASGIS5EU

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

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

kakopappa commented 1 year ago

AFAIK PM2. 5 is measured in micrograms per cubic meter of air, so you should select CubicMeters

TPCQitek commented 1 year ago

Hello, ok I have done that and set up, the code runs ok , see below, main.ino

what I am looking to do here is READ BACK the Sensor value, i don't need to set it in these event, only read the current Sensor value, which I give from the C02 Sensor etc , in other version I can use the switch to turn ON / OFF things, etc

in the PM2.5 version there is a value I set with the read sensor thats fine,

I have this . What is the "utterance" to use with Alexa?

thanks in advance..

[image: image.png]

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Mon, 21 Nov 2022 at 18:00, Aruna Tennakoon @.***> wrote:

As you know there’s no built-in device type for C02/N02/CH20 so you must create a custom device type for this.

Take a look at the documentation https://help.sinric.pro/pages/custom-templates

  1. First create a device template and add multiple Range Capabilities for c02/n02/ch20. Range capability has the ability to show a number and you can inquire then in Alexa as well.

  2. Save the template

  3. Go and create a new device and use the new template name you created earlier as the device type.

  4. Save the device

  5. Once you save the device you can generate the code for the custom device in devices tab in portal

  6. Download the code . Call the update function with the values to update the server with c02/n02/ch20

On Mon, 21 Nov 2022 at 12:56 PM TERENCE P CURTIS @.***> wrote:

Originally posted by @TPCQitek https://github.com/TPCQitek in #14 (comment) < https://github.com/sinricpro/feature-requests/issues/14#issuecomment-1319479300

revised question, so much like the read back PM2.5 (as inAirQualitySensor.h) this allow me to add my Sensor reading values, I would like to have at minimum additionally (C02, N02, CH20,) as a read back.

thanks.

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/feature-requests/issues/16, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABZAZZS4QMVASCOLAFUIZCLWJMFKFANCNFSM6AAAAAASGIS5EU

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

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

kakopappa commented 1 year ago

Hi @TPCQitek

Can't see the code for main.ino or the images embedded. can you update the issue again? Replaying the email with images won't work.

kakopappa commented 1 year ago

utterance would be

Alexa, what is the [range controller name] of [device name]

Example: I have added a range controller with the name: level and a device with the name: C02 Sensor.

You can ask Alexa

Alexa, what is the level of C02 Sensor

image image

kakopappa commented 1 year ago

in the example code, you have attached I did not see you are updating the server with C02 values.

here's my example code. It will update the range value every 1 min. You can see it in Alexa and inquire about it.

I have deleted your comment because it contains secret keys.

/*
 * Example
 *
 * 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
 */

 // Custom devices requires SinricPro ESP8266/ESP32 SDK 2.9.6 or later

// 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 "CSensor.h"

#define APP_KEY    ""
#define APP_SECRET ""
#define DEVICE_ID  ""

#define SSID       ""
#define PASS       ""

#define BAUD_RATE  9600

CSensor &cSensor = SinricPro[DEVICE_ID];

/*************
 * Variables *
 ***********************************************
 * Global variables to store the device states *
 ***********************************************/

// RangeController
std::map<String, int> globalRangeValues;

/*************
 * Callbacks *
 *************/

// RangeController
bool onRangeValue(const String &deviceId, const String& instance, int &rangeValue) {
  Serial.printf("[Device: %s]: Value for \"%s\" changed to %d\r\n", deviceId.c_str(), instance.c_str(), rangeValue);
  globalRangeValues[instance] = rangeValue;
  return true;
}

bool onAdjustRangeValue(const String &deviceId, const String& instance, int &valueDelta) {
  globalRangeValues[instance] += valueDelta;
  Serial.printf("[Device: %s]: Value for \"%s\" changed about %d to %d\r\n", deviceId.c_str(), instance.c_str(), valueDelta, globalRangeValues[instance]);
  globalRangeValues[instance] = valueDelta;
  return true;
}

/**********
 * Events *
 *************************************************
 * Examples how to update the server status when *
 * you physically interact with your device or a *
 * sensor reading changes.                       *
 *************************************************/

// RangeController
void updateRangeValue(String instance, int value) {
  cSensor.sendRangeValueEvent(instance, value);
}

/********* 
 * Setup *
 *********/

void setupSinricPro() {

  // RangeController
  cSensor.onRangeValue("rangeInstance1", onRangeValue);
  cSensor.onAdjustRangeValue("rangeInstance1", onAdjustRangeValue);

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

void setupWiFi() {
  WiFi.begin(SSID, PASS);
  Serial.printf("[WiFi]: Connecting to %s", SSID);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.printf(".");
    delay(250);
  }
  Serial.printf("connected\r\n");
}

void setup() {
  Serial.begin(BAUD_RATE);
  setupWiFi();
  setupSinricPro();
}

/********
 * Loop *
 ********/

unsigned long lastMillis = 0;

void loop() {
  SinricPro.handle();

  if (millis() - lastMillis > 60000) {
    lastMillis = millis();
    Serial.printf("updateRangeValue ..\r\n");
    updateRangeValue("rangeInstance1", random(1,2000));
  }
}

image

kakopappa commented 1 year ago

@sivar2311 has created a much-simplified version of my code.

https://gist.github.com/sivar2311/84d2ee09b6e18d16f2670492dca7f3bc

#include <Arduino.h>
#include <SinricPro.h>

#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif

#include "CSensor.h"

#define APP_KEY    ""
#define APP_SECRET ""
#define DEVICE_ID  ""

#define SSID ""
#define PASS ""

#define BAUD_RATE 115200

CSensor &cSensor = SinricPro[DEVICE_ID];

int getCO2_level() {
    // Implement your CO2 Sensor reading here and return the co2 value
    // For now this function only return a dummy value between 1 and 20000
    return random(1, 2000);
}

void updateCO2Level() {
    if (SinricPro.isConnected() == false) return;

    static unsigned long last_millis;
    unsigned long        current_millis = millis();
    if (last_millis && current_millis - last_millis < 60000) return;
    last_millis = current_millis;

    int CO2_level = getCO2_level();
    cSensor.sendRangeValueEvent("level", CO2_level);
}

void setup() {
    WiFi.begin(SSID, PASS);
    Serial.begin(BAUD_RATE);
    SinricPro.begin(APP_KEY, APP_SECRET);
}

void loop() {
    SinricPro.handle();
    updateCO2Level();
}
TPCQitek commented 1 year ago

Hello ok thanks for that, test was ok (sort of) although Alexa is a bit unclear about the question or the accent to understand. or goes "hmmm I don't know that one ??" but the debug json shows a new send and the APP shows the most recent value ok.. its the same on the Keyboard question..

I have a further question to include. (promise not lots more) :)

My Hardware Device design (on ESP32) can include for example a multi purpose, so the same hardware device can be set up to be a Device controller, IE FAN speed power on off etc, and also be a Sensor device. And report another Sensor, PM2.5 C02.. etc.

so am I able to configure the multi function hardware to use the same APP_KEY and APP Secret, and change the DEVICE_ID for the separate function, like DEVICE_FAN; DEVICE_AIQ: using that ID DEVICE_C02:

so I only need to change the declaration I assume for each Device deployed?

Is that logically correct?

so these become new devices in the Server, although in my case that's actually the same hardware..

thanks in advance..

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Wed, 23 Nov 2022 at 18:42, Aruna Tennakoon @.***> wrote:

in the example code, you have attached I did not see you are updating the server with C02 values.

here's my example code. It will update the range value every 1 min. You can see it in Alexa and inquire about it.

/*

// 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

ifdef ESP8266

include

endif

ifdef ESP32

include

endif

include

include "CSensor.h"

define APP_KEY ""

define APP_SECRET ""

define DEVICE_ID ""

define SSID ""

define PASS ""

define BAUD_RATE 9600

CSensor &cSensor = SinricPro[DEVICE_ID];

/*****

  • Variables *
  • Global variables to store the device states * ***/

// RangeController std::map<String, int> globalRangeValues;

/*****

  • Callbacks * *****/

// RangeController bool onRangeValue(const String &deviceId, const String& instance, int &rangeValue) { Serial.printf("[Device: %s]: Value for \"%s\" changed to %d\r\n", deviceId.c_str(), instance.c_str(), rangeValue); globalRangeValues[instance] = rangeValue; return true; }

bool onAdjustRangeValue(const String &deviceId, const String& instance, int &valueDelta) { globalRangeValues[instance] += valueDelta; Serial.printf("[Device: %s]: Value for \"%s\" changed about %d to %d\r\n", deviceId.c_str(), instance.c_str(), valueDelta, globalRangeValues[instance]); globalRangeValues[instance] = valueDelta; return true; }

/**

  • Events *
  • Examples how to update the server status when *
  • you physically interact with your device or a *
  • sensor reading changes. * *****/

// RangeController void updateRangeValue(String instance, int value) { cSensor.sendRangeValueEvent(instance, value); }

/*****

  • Setup * *****/

void setupSinricPro() {

// RangeController cSensor.onRangeValue("rangeInstance1", onRangeValue); cSensor.onAdjustRangeValue("rangeInstance1", onAdjustRangeValue);

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

void setupWiFi() { WiFi.begin(SSID, PASS); Serial.printf("[WiFi]: Connecting to %s", SSID); while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } Serial.printf("connected\r\n"); }

void setup() { Serial.begin(BAUD_RATE); setupWiFi(); setupSinricPro(); }

/****

  • Loop * ****/

unsigned long lastMillis = 0;

void loop() { SinricPro.handle();

if (millis() - lastMillis > 60000) { lastMillis = millis(); Serial.printf("updateRangeValue ..\r\n"); updateRangeValue("rangeInstance1", random(1,2000)); } }

[image: image] https://user-images.githubusercontent.com/7474406/203493952-9f67e5c2-d4fe-4295-92ff-87a0e7e04948.png

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

TPCQitek commented 1 year ago

ok thanks I see that,.. i will test more this afternoon, thanks,

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Thu, 24 Nov 2022 at 13:38, Aruna Tennakoon @.***> wrote:

@sivar2311 https://github.com/sivar2311 has created a much-simplified version of my code.

include

include

if defined(ESP32)

include

elif defined(ESP8266)

include

endif

include "CSensor.h"

define APP_KEY ""

define APP_SECRET ""

define DEVICE_ID ""

define SSID ""

define PASS ""

define BAUD_RATE 115200

CSensor &cSensor = SinricPro[DEVICE_ID];

int getCO2_level() { // Implement your CO2 Sensor reading here and return the co2 value // For now this function only return a dummy value between 1 and 20000 return random(1, 2000); }

void updateCO2Level() { if (SinricPro.isConnected() == false) return;

static unsigned long last_millis;
unsigned long        current_millis = millis();
if (last_millis && current_millis - last_millis < 60000) return;
last_millis = current_millis;

int CO2_level = getCO2_level();
cSensor.sendRangeValueEvent("level", CO2_level);

}

void setup() { WiFi.begin(SSID, PASS); Serial.begin(BAUD_RATE); SinricPro.begin(APP_KEY, APP_SECRET); }

void loop() { SinricPro.handle(); updateCO2Level(); }

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

TPCQitek commented 1 year ago

Hello,

just a question thanks in advance .. sorry to bother you so much..

my test system is OK running the AirQuality and the Custom C02,, remains on line and stable as all DEVICE etc are simply hard coded

however in the mainstream code , I need to read the eeprom to get the value of the DEVICE etc etc

the statement : CSensor &cSensor = SinricPro[DEVICE_C02]; currently gets and error unless its placed in the Initialization section, but I cant read eeprom until setup()

can you suggest please how that can be set in the ... Setup() or void setupSinricPro() function?

As by then I have read eeprom and populated the DEVICE values, if I HARD CODE the DEVICE_C02 then it's fine, but that's not a fix!

is there another format I can use?

Error because Missing DEVICE_ID websocket Invalid message format: {"header":{"payloadVersion":2,"signatureVersion":1},"payload":{"action":"setRangeValue","cause":{"type":"PHYSICAL_INTERACTION"},"createdAt":1669354021 ,"deviceId":"" ,"replyToken":"4c2e9747-8a4c-4f47-9d63-9c516c4ebff5","type":"event","value":{"rangeValue":580},"instanceId":"C02"},"signature":{"HMAC":"UU8mv8iDpYzPnzqWtUVKrCekuXyvloAGTOWi9OvSypk="}}

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Thu, 24 Nov 2022 at 13:38, Aruna Tennakoon @.***> wrote:

@sivar2311 https://github.com/sivar2311 has created a much-simplified version of my code.

include

include

if defined(ESP32)

include

elif defined(ESP8266)

include

endif

include "CSensor.h"

define APP_KEY ""

define APP_SECRET ""

define DEVICE_ID ""

define SSID ""

define PASS ""

define BAUD_RATE 115200

CSensor &cSensor = SinricPro[DEVICE_ID];

int getCO2_level() { // Implement your CO2 Sensor reading here and return the co2 value // For now this function only return a dummy value between 1 and 20000 return random(1, 2000); }

void updateCO2Level() { if (SinricPro.isConnected() == false) return;

static unsigned long last_millis;
unsigned long        current_millis = millis();
if (last_millis && current_millis - last_millis < 60000) return;
last_millis = current_millis;

int CO2_level = getCO2_level();
cSensor.sendRangeValueEvent("level", CO2_level);

}

void setup() { WiFi.begin(SSID, PASS); Serial.begin(BAUD_RATE); SinricPro.begin(APP_KEY, APP_SECRET); }

void loop() { SinricPro.handle(); updateCO2Level(); }

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

TPCQitek commented 1 year ago

Hello,

the Activity log shows the C02 being set ok and also on the SinricPro Dashboard but then something resets the C02 to 0 automatically

this is the (crude) code for that testing, any comment ? thanks.. my mainstream code has the same effect but I don't see any thing that obvious yet,,

// 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

ifdef ESP8266

include

endif

ifdef ESP32

include

endif

include "SinricPro.h"

include "SinricProAirQualitySensor.h"

include "CSensor.h"

define WIFI_SSID "nnnn"

define WIFI_PASS "xx"

define APP_KEY "cc82ac77-a778-4d1b-886b-0ed047434f91" //

Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"

define APP_SECRET

"00c1a04c-218b-4d83-a1e7-12f854622fd4-42309bee-792d-4909-ac12-7529c45f9728" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"

define DEVICE_SENS "637f0661333d12dd2afc250b" // Should look like

"5dc1564130xxxxxxxxxxxxxx"

define DEVICE_C02 "637efe47b8a7fefbd647b3f2"

define BAUD_RATE 115200

int CO2_level = 20; CSensor &cSensor = SinricPro[DEVICE_C02];

int getCO2_level() { return (CO2_level += 1); }

void updateCO2Level() { if (SinricPro.isConnected() == false) return;

static unsigned long last_millis; unsigned long current_millis = millis(); if (last_millis && current_millis - last_millis < 30000) return; last_millis = current_millis;

CO2_level = getCO2_level(); Serial.print(" Set C02 level:"); Serial.println(CO2_level); cSensor.sendRangeValueEvent("C02", CO2_level);

}

// Air quality sensor event dispatch time. Min is every 1 min.

define MIN (1000UL 60 1)

unsigned long dispatchTime = millis() + MIN;

// setup function for WiFi connection void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS); Serial.println(" AirQualitySensor_baseline1 "); while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str()); }

// setup function for SinricPro void setupSinricPro() { // add device to SinricPro SinricProAirQualitySensor& mySinricProAirQualitySensor = SinricPro[DEVICE_SENS];

// set callback function to device

// 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(); updateCO2Level();

if ((long)(millis() - dispatchTime) >= 0) { SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_SENS]; // get sensor device

int pm1 = 20;
int pm2_5 = 40;
int pm10 = 45;

mySinricProAirQualitySensor.sendAirQualityEvent(pm1, pm2_5, pm10,

"PERIODIC_POLL"); dispatchTime += MIN; Serial.println("Sending Air Quality event .."); } }

for example

IP ADDRESSLOCATIONAPP NAMEACTIVITYTIMESTAMP

101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor, QiTek MIDI] disconnected 2022-11-25 19:01:47 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor, QiTek Sensors] disconnected 2022-11-25 19:01:47 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-25 18:56:21 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 43 2022-11-25 18:56:08 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-25 18:56:06 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-25 18:55:51 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 42 2022-11-25 18:55:38 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-25 18:55:36 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-25 18:55:21 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 41 2022-11-25 18:55:08

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Thu, 24 Nov 2022 at 13:38, Aruna Tennakoon @.***> wrote:

@sivar2311 https://github.com/sivar2311 has created a much-simplified version of my code.

include

include

if defined(ESP32)

include

elif defined(ESP8266)

include

endif

include "CSensor.h"

define APP_KEY ""

define APP_SECRET ""

define DEVICE_ID ""

define SSID ""

define PASS ""

define BAUD_RATE 115200

CSensor &cSensor = SinricPro[DEVICE_ID];

int getCO2_level() { // Implement your CO2 Sensor reading here and return the co2 value // For now this function only return a dummy value between 1 and 20000 return random(1, 2000); }

void updateCO2Level() { if (SinricPro.isConnected() == false) return;

static unsigned long last_millis;
unsigned long        current_millis = millis();
if (last_millis && current_millis - last_millis < 60000) return;
last_millis = current_millis;

int CO2_level = getCO2_level();
cSensor.sendRangeValueEvent("level", CO2_level);

}

void setup() { WiFi.begin(SSID, PASS); Serial.begin(BAUD_RATE); SinricPro.begin(APP_KEY, APP_SECRET); }

void loop() { SinricPro.handle(); updateCO2Level(); }

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

kakopappa commented 1 year ago

the global CSensor &cSensor = SinricPro[DEVICE_ID]; can be changed to a local just before using the cSensor object

to something like below;

const char *deviceId = "whatever";
CSensor &cSensor = SinricPro[deviceId];
cSensor.sendRangeValueEvent(instance, value);

[C02 Sensor] set to 0 2022-11-25 18:55:36 101.178.35.49

According to the event log, your ESP is sending the value 0. Have you taken a look at the Arduino serial monitor to confirm this? The code looks fine though.

kakopappa commented 1 year ago

I tried your code. it seems to work fine image

One thing I noticed was the time difference between the two events is too close almost as if 2 device sending events

TPCQitek commented 1 year ago

Hello,, thanks for the reply..

note these are using the example as in: AirQualitySensor_baseline1_C02

I see the set C02 to 0 happens on the Dashboard side, as below, the Device (IE the ESP32 code of that C02 sens) is not running, ( IE I can simply comment out the C02 code) but the Dashboard is setting to "0". Anyway, it thinks the C02 is active, but it's not actually. I tried refresh the browser and that stuff,

I have the code only doing the SinricProAirQualitySensor &mySinricProAirQualitySensor = SinricPro[DEVICE_SENS] but that Send event from the Console log here.. 14:07:03.911 -> Connected to SinricPro 14:07:58.491 -> Sending Air Quality event ..

is not showing also in the Activity report,

the LOG shows ok , please see attached,

101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:09:26 2001:8003:2673:7700:4d99:897b:ea40:8ea6 Sydney, Australia (AU) googlehome-action Google Home action linked 2022-11-26 14:09:17 2001:8003:2673:7700:4d99:897b:ea40:8ea6 Sydney, Australia (AU) googlehome-action Logged in with username and password 2022-11-26 14:09:17 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:09:11 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:08:57 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:08:41 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:08:26 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:08:11 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:07:56 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:07:41 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:07:26 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 0 2022-11-26 14:07:11 101.178.35.49 Sydney, Australia (AU) websocket [QiTek Sensors] connected 2022-11-26 14:07:07 101.178.35.49 Sydney, Australia (AU) websocket Login via App key: [IAQ] 2022-11-26 14:07:04

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Sat, 26 Nov 2022 at 11:38, Aruna Tennakoon @.***> wrote:

I tried your code. it seems to work fine [image: image] https://user-images.githubusercontent.com/7474406/204065759-912d8b52-76fe-4806-9dc4-1d69e6225fa5.png

One thing I noticed was the time difference between the two events is too close almost as if 2 device sending events

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

TPCQitek commented 1 year ago

Hello, ok

my point was that placing the statement CSensor &cSensor = SinricPro[deviceId]; in the void setup() caused an error, as the cSensor is not declared,

I need to have that in void setup(0 as I can read the eeprom and load the DeviceId.

I am not sure what type I can declare that as?

using the same example.

thanks..

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Sat, 26 Nov 2022 at 11:13, Aruna Tennakoon @.***> wrote:

the global CSensor &cSensor = SinricPro[DEVICE_ID]; can be changed to a local just before using the cSensor object

to something like below;

const char *deviceId = "whatever"; CSensor &cSensor = SinricPro[deviceId]; cSensor.sendRangeValueEvent(instance, value);

[C02 Sensor] set to 0 2022-11-25 18:55:36 101.178.35.49

According to the event log, your ESP is sending the value 0. Have you taken a look at the Arduino serial monitor to confirm this? The code looks fine though.

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

sivar2311 commented 1 year ago

Hi @TPCQitek !

my point was that placing the statement CSensor &cSensor = SinricPro[deviceId]; in the void setup() caused an error, as the cSensor is not declared,

Can you post your code and the error message, please? There should be no error using a local variable. I think the error must be somewhere else.

Please use codeblocks! This keeps the formatting of your code and helps us to read your code more clearly.

TPCQitek commented 1 year ago

Hello, ..

I have some time to test more today, but I am getting an error that says the App secret and Device are not correct, so I did a reset . clear the browser history etc, (no change), i removed all devices in SinricPro dashboard

also I can not add the Sensor to Google now, but the SinricPro dashboard is showing the data PM25 etc, as a trace.

at BOOT UP, my ESP32 log shows the Device 20:18:04.102 -> [SinricPro]: Device "638464f5b8a7fefbd64c6dfc" does not exist. Creating new device 20:18:04.102 -> [SinricPro:add()]: Adding device with id "638464f5b8a7fefbd64c6dfc". 20:18:04.102 -> [SinricPro:Websocket]: Connecting to WebSocket Server using SSL (ws.sinric.pro) 20:18:04.102 -> [SinricPro:Websocket]: headers:

101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 20:18:45 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 20:18:30 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 20:18:15 101.178.35.49 Sydney, Australia (AU) websocket [QiTek Sensors] connected 2022-11-28 20:18:10 101.178.35.49 Sydney, Australia (AU) websocket Login via App key: [IAQ] 2022-11-28 20:18:07

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Sat, 26 Nov 2022 at 11:38, Aruna Tennakoon @.***> wrote:

I tried your code. it seems to work fine [image: image] https://user-images.githubusercontent.com/7474406/204065759-912d8b52-76fe-4806-9dc4-1d69e6225fa5.png

One thing I noticed was the time difference between the two events is too close almost as if 2 device sending events

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

kakopappa commented 1 year ago

the app key and secret are not associated with this device id: 638464f5b8a7fefbd64c6dfc is wrong. According to your device settings, you have to put the appkey/secret associated with the new appkey name "IAQ"

TPCQitek commented 1 year ago

currently I have 3 new device using the IAQ as reference,

[image: image.png]

the activity refers to : 637efe47b8a7fefbd647b3f2 ? what I am i misreading?

IP ADDRESSLOCATIONAPP NAMEACTIVITYTIMESTAMP

101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 667 2022-11-28 21:44:42 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 21:44:37 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 21:44:22 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 21:44:07 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-28 21:43:52 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 684 2022-11-28 21:43:42 Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Mon, 28 Nov 2022 at 20:57, Aruna Tennakoon @.***> wrote:

the app key and secret are not associated with this device id: 638464f5b8a7fefbd64c6dfc is wrong. According to your device settings, you have to put the appkey/secret associated with the new appkey name "IAQ"

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

kakopappa commented 1 year ago

Your account has 3 devices.

6384xxx00df29 - QiTek MIDI 6384xxx00e7c8 - C02 Sensor 6384xxx00f582 - QiTek Sensors

637efe47b8a7fefbd647b3f2 << Is not one of them. Likely you need to update your sketch / config in EEPROM

TPCQitek commented 1 year ago

Hello,

there is 2 issues here, but firstly there is no use of the 637efe47b8a7fefbd647b3f2 device , the eeprom and the console do not use that number, it was a previous Device in SindricPro record, also the current device for DevICE_SENS is correct but the console said it didn't exist,

The System Console shows:

11:04:24.860 -> Setup SinricPro.... 11:04:24.860 -> add device AirQuality DEVICE_SENS: 63848db5333d12dd2a00f582 11:04:24.860 -> add DEVICE_C02: 63847f4b333d12dd2a00e7c8 11:04:24.860 -> [SinricPro]: Device "63848db5333d12dd2a00f582" does not exist. Creating new device 11:04:24.860 -> [SinricPro:add()]: Adding device with id "63848db5333d12dd2a00f582". 11:04:24.860 -> begin.. 11:04:24.860 -> Done SinricPro:

and if I read the eeprom with my SYS_215 command I get the result.

10:58:54.269 -> BT_Data SYS_215 10:58:54.269 -> void SYS_215 10:58:54.314 -> Voice: Google or Alexa 10:58:54.314 -> APP_KEY: cc82ac77-a778-4d1b-886b-0ed047434f91 10:58:54.314 -> APP_SECRET: ** 10:58:54.314 -> DEVICE_SENS: 63848db5333d12dd2a00f582 10:58:54.360 -> DEVICE_FAN: 6384797f333d12dd2a00df29 10:58:54.360 -> DEVICE_C02: 63847f4b333d12dd2a00e7c8 10:58:54.360 -> DEVICE_PM25: 000

the same devices are set up: DEVICEDESCRIPTIONPOWER STATEROOMAPP KEYLAST CONNECTEDNO OF TIMES CONNECTED C02 Sensor ID: 63847f4b333d12dd2a00e7c8 Copy Code Generator Winsen C02 Off Living Room IAQ 2 minutes ago 9 QiTek MIDI ID: 6384797f333d12dd2a00df29 Copy MIDI 2014 Off Living Room IAQ 14 hours ago 1 QiTek Sensors ID: 63848db5333d12dd2a00f582 Copy QiTek Winsen Off Living Room IAQ 2 minutes ago 7 the Sensor is reading data etc,

BUT: the Activity LOG in Portal is full of the error messages,

IP ADDRESSLOCATIONAPP NAMEACTIVITYTIMESTAMP

101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:10:32 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:10:18 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:10:02 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:09:46 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 613 2022-11-29 11:09:40 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:09:32 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:09:16 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:09:02 101.178.35.49 Sydney, Australia (AU) websocket AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct? 2022-11-29 11:08:46 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor] set to 612 2022-11-29 11:08:40 Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Tue, 29 Nov 2022 at 00:25, Aruna Tennakoon @.***> wrote:

Your account has 3 devices.

6384xxx00df29 - QiTek MIDI 6384xxx00e7c8 - C02 Sensor 6384xxx00f582 - QiTek Sensors

637efe47b8a7fefbd647b3f2 << Is not one of them. Likely you need to update your sketch / config in EEPROM

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

TPCQitek commented 1 year ago

Hello,

I see now the Activity LOG is clear and not showing the error. Was something found / fixed? the error cleared about 11 45 today..

101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor, QiTek MIDI] connected 2022-11-29 12:41:24 101.178.35.49 Sydney, Australia (AU) websocket Login via App key: [IAQ] 2022-11-29 12:41:21 101.178.35.49 Sydney, Australia (AU) websocket [C02 Sensor, QiTek Sensors] connected 2022-11-29 12:41:12 101.178.35.49 Sydney, Australia (AU) websocket Login via App key: [IAQ] 2022-11-29 12:41:09 101.178.35.49 Sydney, Australia (AU) websocket [QiTek MIDI] disconnected 2022-11-29 12:41:09

but the boot up console shows the device 63848db5333d12dd2a00f582 as unknown, and while this shows in the SinricPro portal as (3 devices) working,

12:51:08.369 -> Setup SinricPro.... 12:51:08.369 -> add device AirQuality DEVICE_SENS: 63848db5333d12dd2a00f582 12:51:08.369 -> add DEVICE_C02: 63847f4b333d12dd2a00e7c8 12:51:08.369 -> [SinricPro]: Device "63848db5333d12dd2a00f582" does not exist. Creating new device 12:51:08.369 -> [SinricPro:add()]: Adding device with id "63848db5333d12dd2a00f582". 12:51:08.369 -> begin..

when I go to google HOME to add device / relink the SinricPro it only shows 2 devices (available), but only one (QiTek Midi) is shown in Google Home. ??

[image: image.png]

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Tue, 29 Nov 2022 at 00:25, Aruna Tennakoon @.***> wrote:

Your account has 3 devices.

6384xxx00df29 - QiTek MIDI 6384xxx00e7c8 - C02 Sensor 6384xxx00f582 - QiTek Sensors

637efe47b8a7fefbd647b3f2 << Is not one of them. Likely you need to update your sketch / config in EEPROM

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

kakopappa commented 1 year ago

1. 11:04:24.860 -> [SinricPro]: Device "63848db5333d12dd2a00f582" does not exist. Creating new devices

this refers to the internal list of device ids SDK holds. It's not creating devices on the server.

2) AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct?

When your ESP connects it sends the following details.

Device Ids: "637xxxx7fefbd647b3f2;638479xxxxxa00df29," AppKey: cc82ac77-xxxx-0ed047434f91

may be you delete these devices on the server but ESP reconnected with the above appkey. since the server could not find the appkey it just logs every time.

You can enable the SDK logs so you can see these ids are being sent. To enable the SDK logs, add this code to top of the ino file.

#define ENABLE_DEBUG

#ifdef ENABLE_DEBUG
       #define DEBUG_ESP_PORT Serial
       #define NODEBUG_WEBSOCKETS
       #define NDEBUG
#endif 
TPCQitek commented 1 year ago

Hello,

ok I deleted all Device, clean start, and the IAQ credentials, and restarted over, loaded the eeprom and a manual sketch,

with new API key / secret, and new device the device is not found, but it does load and run,

15:04:55.556 -> 63857ad8b8a7fefbd64d5f00 15:04:55.556 -> [SinricPro]: Device "63857ad8b8a7fefbd64d5f00" does not exist. Creating new device 15:04:55.556 -> [SinricPro:add()]: Adding device with id "63857ad8b8a7fefbd64d5f00". 15:04:55.556 -> begin.. 15:04:55.556 -> Done SinricPro:

so when I change to other hardware, (there are 2 EP32, one has sensors and one has FAN

15:14:30.851 -> Setup SinricPro.... 15:14:30.851 -> add device FAN to SinricPro 15:14:30.851 -> 63857ad8b8a7fefbd64d5f00 15:14:30.851 -> [SinricPro]: Device "63857ad8b8a7fefbd64d5f00" does not exist. Creating new device 15:14:30.851 -> [SinricPro:add()]: Adding device with id "63857ad8b8a7fefbd64d5f00". 15:14:30.851 -> begin.. 15:14:30.851 -> Done SinricPro:

Thus looks more like a issue to clear memory cache? As these are 100% correct. The api key / secret are also correct.

So in sinricpro portal the devices are actually on line shows data .

But: if I go to google the portal only shows 2 devices but only loads 1 .

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Tue, 29 Nov 2022 at 13:48, Aruna Tennakoon @.***> wrote:

  1. 11:04:24.860 -> [SinricPro]: Device "63848db5333d12dd2a00f582" does not exist. Creating new devices

this refers to the internal list of device ids SDK holds. It's not creating devices on the server.

2) AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct?

When your ESP connects it sends the following details.

Device Ids: "637xxxx7fefbd647b3f2;638479xxxxxa00df29," AppKey: cc82ac77-xxxx-0ed047434f91

may be you delete these devices on the server but ESP reconnected with the above appkey. since the server could not find the appkey it just logs every time.

You can enable the SDK logs so you can see these ids are being sent. To enable the SDK logs, add this code to top of the ino file.

define ENABLE_DEBUG

ifdef ENABLE_DEBUG

   #define DEBUG_ESP_PORT Serial
   #define NODEBUG_WEBSOCKETS
   #define NDEBUG

endif

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

TPCQitek commented 1 year ago

Hello, OK I need to wrap this up now, (I have a lot things to do).. as I see it there are a couple of (probably related) issues that are falling short and not workable, essentially the overall is working BUT..

The first issue:

The error Device "63857b12b8a7fefbd64d5f85" does not exist? , looks like a Server cache problem. I think this comes about after Devices are deleted and the recreated new, this included new API KEY and SECRET, all are linked and stored correctly, eeprom is correct; the Server has retained some DEVICE ID info, as result while the Device shows in the SinricPro Portal and "looks OK" it's not possible to Link the Account Devices in Google Home. So I can't use Google Home to check IAQ .

17:35:00.747 -> [SinricPro]: Device "63857b12b8a7fefbd64d5f85" does not exist. Creating new device 17:35:00.747 -> [SinricPro:add()]: Adding device with id "63857b12b8a7fefbd64d5f85".

Note: this is not correct, the Device ID is as entered and API and Secret are confirmed. Yes I am very familiar with the Debug etc.

Second issue: is the custom Device (C02 in this case) but I need to add others for Alexa.

The Code generator puts the statement

CSensor &cSensor = SinricPro[DEVICE_ID]; in the initialisation section, but in reality we need to set the DEVICE ID from eeprom and that can only be done in Setup() or main.

when I put CSensor &cSensor = SinricPro[DEVICE_ID]; in the void Setup(), the error is cSensor not defined.

what's the correct way to define cSensor in the initialisation section?

Note: normally the FAN device has been OK. and OK on Google.

What is your view?

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Tue, 29 Nov 2022 at 13:48, Aruna Tennakoon @.***> wrote:

  1. 11:04:24.860 -> [SinricPro]: Device "63848db5333d12dd2a00f582" does not exist. Creating new devices

this refers to the internal list of device ids SDK holds. It's not creating devices on the server.

2) AppSecert not found for 637efe47b8a7fefbd647b3f2. Is device id correct?

When your ESP connects it sends the following details.

Device Ids: "637xxxx7fefbd647b3f2;638479xxxxxa00df29," AppKey: cc82ac77-xxxx-0ed047434f91

may be you delete these devices on the server but ESP reconnected with the above appkey. since the server could not find the appkey it just logs every time.

You can enable the SDK logs so you can see these ids are being sent. To enable the SDK logs, add this code to top of the ino file.

define ENABLE_DEBUG

ifdef ENABLE_DEBUG

   #define DEBUG_ESP_PORT Serial
   #define NODEBUG_WEBSOCKETS
   #define NDEBUG

endif

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

sivar2311 commented 1 year ago

You can put the statement CSensor &cSensor = SinricPro[DEVICE_ID]; anywhere in your code and use it as a local variable! If it is not a global variable, you have to put this line of code in all your functions that use this device.

Example:

void updateCO2Level() {
    CSensor &cSensor = SinricPro[DEVICE_ID]; // <- cSensor as local variable
    if (SinricPro.isConnected() == false) return;

    static unsigned long last_millis;
    unsigned long        current_millis = millis();
    if (last_millis && current_millis - last_millis < 60000) return;
    last_millis = current_millis;

    int CO2_level = getCO2_level();
    cSensor.sendRangeValueEvent("level", CO2_level);
}
TPCQitek commented 1 year ago

Ok I see, tks,

what can be resolved about the

17:35:00.747 -> [SinricPro]: Device "63857b12b8a7fefbd64d5f85" does not exist. Creating new device 17:35:00.747 -> [SinricPro:add()]: Adding device with id "63857b12b8a7fefbd64d5f85".

Regards:

Terence Curtis

CONTACTS: SKYPE: terencepcurtis

Mobile: Australia +61 412 262 646


On Tue, 29 Nov 2022 at 18:27, sivar2311 @.***> wrote:

You can put the statement CSensor &cSensor = SinricPro[DEVICE_ID]; anywhere in your code and use it as a local variable! If it is not a global variable, you have to put this line of code in all your functions that use this device.

Example:

void updateCO2Level() { CSensor &cSensor = SinricPro[DEVICE_ID]; // <- cSensor as local variable if (SinricPro.isConnected() == false) return;

static unsigned long last_millis;
unsigned long        current_millis = millis();
if (last_millis && current_millis - last_millis < 60000) return;
last_millis = current_millis;

int CO2_level = getCO2_level();
cSensor.sendRangeValueEvent("level", CO2_level);

}

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

sivar2311 commented 1 year ago

There is nothing to solve. As kakopappa said: This message comes from the SDK running on the ESP.

When a device is used for the first time in your Sketch, e.g. CSensor& cSensor = SinricPro[DEVICE_ID];, the SDK checks if this device is already created (on the ESP) and set up in the SDK. If the device has not yet been created (on the ESP), it will be created so that your Sketch can use the device.

This does not mean that the device is created server-side!