sinricpro / nodejs-sdk

Nodejs library for https://sinric.pro
11 stars 7 forks source link

setMode callback and instance #30

Open smoi opened 2 years ago

smoi commented 2 years ago

it looks like on the nodejs lib there's no way to get the instance of the sent mode. I've tried debugging the response and there's no instance in the response. Is there maybe a param I can pass to the connection to have it? Like sdk version etc

ESP bool onSetMode(const String& deviceId, const String& instance, String &mode) { Serial.printf("[Device: %s]: Modesetting for \"%s\" set to mode %s\r\n", deviceId.c_str(), instance.c_str(), mode.c_str()); globalModes[instance] = mode; return true; }

Node function setMode(deviceid, data) { console.log(deviceid, data); return true; }

data only contains the mode value

kakopappa commented 2 years ago

Thanks will fix this ASAP.

There’s instanceId when you have multiple instances of RangeController/ ModeController which is available when you create custom devices. If you are in a hurry you can use the Python SDK

smoi commented 2 years ago

Great, I still have issues with the modes feature, it looks like Alexa does not recognize them always. Is it supported in other languages or only english? For example I want to set [mode name] window blind to [mode value] open on device blinds

The example on the template mode creation does not explain really well how to use the values with alexa

kakopappa commented 2 years ago

Here's what I did, created a new template and created a new device called blinds based on that template.

{ "name": "blinds2", "description": "blinds2", "deviceTypeId": "5ff0b112994fd31b7d5e8065", "capabilities": [ { "id": "5ff0b41b994fd31b7d5e8961", "mode": { "instanceId": "modeInstance1", "locale": "en-US", "modeName": "Position", "nonControllable": false, "modeValues": [ "open", "close" ] } } ] }

You can import the above template from the "Device Template"

image

image

set the blinds [device name] to open [mode value]. set the blinds [device name] position [mode name] to open [mode value].

above worked.

smoi commented 2 years ago

it looks like a device with more than one mode is not being added to Alexa, is there any limitation on this?

sivar2311 commented 2 years ago

The controls displayed in the Alexa app depend on the selected device type. Using the "Other" device type allows multiple mode controllers. image

image

kakopappa commented 2 years ago

Hi @smoi

I have released 2.6.1 with custom device support. You can find the example code here: https://github.com/sinricpro/nodejs-sdk/blob/master/examples/custom-devices/custom-devices.js