Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setMode callback and instance #30

Open
smoi opened this issue Jun 11, 2022 · 6 comments
Open

setMode callback and instance #30

smoi opened this issue Jun 11, 2022 · 6 comments

Comments

@smoi
Copy link

smoi commented Jun 11, 2022

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
Copy link
Collaborator

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
Copy link
Author

smoi commented Jun 11, 2022

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
Copy link
Collaborator

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
Copy link
Author

smoi commented Jun 11, 2022

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

@sivar2311
Copy link

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants