esp-rainmaker
esp-rainmaker copied to clipboard
Device works with Alexa app but can't be used as trigger in routine creation in Alexa app (MEGH-3849)
I Have Alexa app on my iPhone and ESP Rinmaker skill enabled. I see my devices and can control (switching or viewing devices state). But when i try to create routine and don't want use command voice for "When it happen" step, but want use state from my smart home device (e.g. if input state in device changed to ON, it will do something...), i'm choosing "Smart Home" from "When this happens" list and there is not anyone from my devices. I see "No devices found". Is it some special restrictions for device that can be use as trigger in alexa routine creation? I tried with some different types of parameter, but basically use esp.param.mode type. Is it problem with ESP Rainmaker skill or i have to use some specjal parameter in device, or something else?
@jacek12345 , I could not see any such option in the Android Alexa app, so I could not validate if it is not showing any device at all, or not showing just the RainMaker devices. I will check internally, but can you
- Check if other Smart Home devices show up in the list (in case you have any, and can share the skill name they are linked to).
- Share screenshot of the Alexa app page where you can create this route.
https://user-images.githubusercontent.com/34368502/191615273-7705cd8c-e872-4676-812e-7a6f6732507a.MOV
I will try to find some other smart device and check if it is visible. I should have something from Tuya and Shelly.
I have "Shelly Plus 1" switch and doesn't appear on list also.
@jacek12345 , Even I found that option in Android (was looking at wrong place earlier). I have several devices from Tuya and Xiaomi, but I couldn't see any of those in the list
I found this on Alexa developers forum: https://amazon.developer.forums.answerhub.com/questions/226814/smart-home-skill-as-trigger-for-a-routine.html I Suppose that it is possible to create device that can trigger routine (e.g. lock or Contact Sensor). Could You investigate if it is Alexa skill and/or backend related theme? Only specified devices can trigger routines, but it should be properly used on Alexa skill side, e.g. 'state report' (retrievable = true) and 'change report' (proactivelyReported = true) implemented.
I created ESP_RMAKER_DEVICE_LOCK device with esp.param.lockstate parameter type (bool). Now can see device as routine creation trigger but it is signed as unresponsive in Alexa app. Device works with RainMaker app. I suppose, that it is skill depended issue? Created also second device that is ESP_RMAKER_DEVICE_SWITCH type and also added esp.param.lockstate parameter type (bool). It is also available from routine creation trigger list, also unresponsive. Addidtionally, there is great feature. The Alexa app creates voice password for control ESP_RMAKER_DEVICE_LOCK device and don't do it for ESP_RMAKER_DEVICE_SWITCH. Great function for security maintaining (changing device type can change security level). But why devices ar unresponsive....? I can't see any action on monitor console when pushing switch on alexa app, so suspect some problem with skill incompatibility. I didn't found "esp.param.lockstate" in esp_rmaker_standard_types.h so probably also not supported in skill? Can You check?
https://user-images.githubusercontent.com/34368502/192955874-46114650-7777-4356-ba32-9f26f03b4fcb.MP4
Updating from Allexa Team Support (according to devices that can be trigger for routines):
"We do not have official document for supported interfaces but these below are supported. In the parentheses, I put supported properties. Although some of them might be supported by only Amazon devices. Please let us know if these interfaces are not working as triggers, we will make sure it with internal team.
- Motion Sensor - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-motionsensor.html (Motion detected, Motion not detected for x minutes)
- Contact Sensor - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-contactsensor.html (Contact detected, Contact not detected)
- Doorbell Event - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-doorbelleventsource.html (Doorbell pressed)
- Security Panel - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-securitypanelcontroller.html (Security Panel changes state to 'Armed Away', 'Armed Stay', or 'Disarmed'
- Lock - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-lockcontroller.html (When lock changes state to 'Locked', 'Unlocked' or 'Jammed') No other interfaces are currently supported by Routines as triggers"
Can You confirm if RainMaker is compatible with some of these Alexa interfaces (and properties)?
@jacek12345 , thanks for this info. I will check with the team and provide an answer soon
@shahpiyushv Hello Any update on this issue? we are having the same problem. need to define a trigger from rainmaker in the Alexa routine but nothing is available in the Alexa list. Should we expect to be added though an update?
We are checking this internally and will provide an update soon. We already support sending events to Alexa asynchronously, so hopefully, only some minor tweaks in the skill may be required.
Thats great! While You're working with this, please try to add "Contact Sensor" device as it is strongly needed for us. Contact Sensor - https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-contactsensor.html (Contact detected, Contact not detected)
We are checking this internally and will provide an update soon. We already support sending events to Alexa asynchronously, so hopefully, only some minor tweaks in the skill may be required.
Thank you. looking forward to hearing about the updates.
I also need trigger type of device. Following this issue for update
Looks like a skill needs to be created to make the rainmaker devices work with routines. I have been looking into it but it would take me a long time to get there. Would be nice if the rainmaker skill was adapted to incorporate all the sensors and items it supports to work with routines. Is this something that is in the works?
@rushwind , we are checking what changes are required to support the routines and then will also add support for the missing sensors.
That is wonderful news. Thank you and I am looking forward to it. Will you post updates here or somewhere else? Thanks again!
@rushwind , we are checking what changes are required to support the routines and then will also add support for the missing sensors.
Any estimation on how long it might take till this feature gets added to the main stream?
@shahpiyushv Do You have any new information?
Routines can now be used with the ESP RainMaker Alexa skill for "Locks". We have also updated the standard types docs here with information about what params are required for each device type. A lock device (esp.device.lock) with an integer parameter for lock state (esp.param.lockstate) will work with Alexa routines.
@shahpiyushv Thank You for information. Now i can use lock device as trigger. There is some problem, that Alexa doesn't offer "Unlock" function as an Action for routine, there is only "Lock" function available, but this is Alexa bug i think. I asked Alexa support. Can You tell when other device types (especially Contact sensor) will be added in RainMaker?
BTW: esp.param.lockstate definition is still missing in standard param types
From Alexa support, lack of "Unlock" function as an Action for routine is due to security issue.
we are checking what changes are required to support the routines and then will also add support for the missing sensors.
@shahpiyushv Can You estimate when it will be added? Contac Sensor needed.
@shahpiyushv We are close to private deploy and production phase. But need develop last thing, contact sensor device. Can You estimate when this device will be added to RainMaker?
@jacek12345 , I have asked to prioritise this. Now that there are no technical unknowns, this should not be hard.
@shahpiyushv Thank You for information. Now i can use lock device as trigger. There is some problem, that Alexa doesn't offer "Unlock" function as an Action for routine, there is only "Lock" function available, but this is Alexa bug i think. I asked Alexa support. Can You tell when other device types (especially Contact sensor) will be added in RainMaker?
BTW: esp.param.lockstate definition is still missing in standard param types
Hiii @jacek12345 I am also looking for a way to trigger alexa routines from esp rainmaker.. Can you please send me your example code for "Lock" soo that I can test and see... I tried to code myself but unfortunately I had no luck.
@VarunKumaran this should work:
esp_rmaker_device_t* device;
esp_rmaker_param_t* state_param;
uint8_t state = 0; //for esp.param.lockstate it can be 0,1 or 2
device = esp_rmaker_device_create("device name", ESP_RMAKER_DEVICE_LOCK, NULL);
if(device)
{
//add editable device name
esp_rmaker_device_add_param(device, esp_rmaker_name_param_create("Name", "device name"));
//add state param
state_param = esp_rmaker_param_create("state", "esp.param.lockstate", esp_rmaker_int(state), PROP_FLAG_READ | PROP_FLAG_WRITE);
if(state_param)
{
esp_rmaker_param_add_ui_type(state_param, ESP_RMAKER_UI_SLIDER);
esp_rmaker_param_add_bounds(state_param, esp_rmaker_int(0), esp_rmaker_int(2), esp_rmaker_int(1));
esp_rmaker_device_add_param(device, state_param);
esp_rmaker_device_assign_primary_param(device, state_param);
esp_rmaker_device_add_cb(device, write_cb, NULL); // You should also add appriopriate code in write_cb()
esp_rmaker_node_add_device(node, device);
}
}
@VarunKumaran this should work:
esp_rmaker_device_t* device; esp_rmaker_param_t* state_param; uint8_t state = 0; //for esp.param.lockstate it can be 0,1 or 2 device = esp_rmaker_device_create("device name", ESP_RMAKER_DEVICE_LOCK, NULL); if(device) { //add editable device name esp_rmaker_device_add_param(device, esp_rmaker_name_param_create("Name", "device name")); //add state param state_param = esp_rmaker_param_create("state", "esp.param.lockstate", esp_rmaker_int(state), PROP_FLAG_READ | PROP_FLAG_WRITE); if(state_param) { esp_rmaker_param_add_ui_type(state_param, ESP_RMAKER_UI_SLIDER); esp_rmaker_param_add_bounds(state_param, esp_rmaker_int(0), esp_rmaker_int(2), esp_rmaker_int(1)); esp_rmaker_device_add_param(device, state_param); esp_rmaker_device_assign_primary_param(device, state_param); esp_rmaker_device_add_cb(device, write_cb, NULL); // You should also add appriopriate code in write_cb() esp_rmaker_node_add_device(node, device); } }
Hiii @jacek12345 Thank you for replying... I tried to add your code but I am getting many errors while compiling it's cuz I have no idea on how to add your code in existing esp rainmaker examples.. Can you please send me a full working code.. in which the lock shld be unlocked and locked in loop for every 30sec.. to check and test alexa routines
@VarunKumaran Take the "gpio" example and paste my code after:
esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Device", "GPIO-Device");
if (!node) {
ESP_LOGE(TAG, "Could not initialise node. Aborting!!!");
vTaskDelay(5000/portTICK_PERIOD_MS);
abort();
}
Add #include <esp_rmaker_standard_params.h>
on the file beginning.
Replace write_cb function with:
/* Callback to handle commands received from the RainMaker cloud */
static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param,
const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx)
{
if (ctx) {
ESP_LOGI(TAG, "Received write request via : %s", esp_rmaker_device_cb_src_to_str(ctx->src));
}
if (app_driver_set_gpio(esp_rmaker_param_get_name(param), val.val.b) == ESP_OK) {
esp_rmaker_param_update_and_report(param, val);
}
else if ((strcmp(esp_rmaker_param_get_type(param), "esp.param.lockstate") == 0))
esp_rmaker_param_update_and_report(param, val);
return ESP_OK;
}
Now You should detect lock device in Your Alexa app and use it as trigger source in Alexa routine.
Take the "gpio" example and paste my code after:
Can you Please share the GPIO example INO sketch.(I'm trying to write code in arduino ide)
Sorry, i don't use arduino. I suppose that You can get any arduino example and change device and param type and go on.