Smart Home Device showing small cog and no commands - actions-on-google

I have a node.js script in AWS Lambda which is connected to my Project via API Gateway.
I've got the actions-on-google library included OK and my devices get discovered. However, depending on what I select as the device type, affects whether in Google Home the device shows with a little cog on the icon (and no commands available).
The below works absolutely fine and I can see the device and commands available:
app.onSync(async (body, headers) => {
return {
requestId: body.requestId,
payload: {
agentUserId: '123',
devices: [{
id: 'washer-123',
type: 'action.devices.types.OUTLET',
traits: [
'action.devices.traits.OnOff',
'action.devices.traits.StartStop',
'action.devices.traits.RunCycle'
],
name: {
defaultNames: ['My Washer'],
name: 'Washer',
nicknames: ['Washer']
},
deviceInfo: {
manufacturer: 'Acme Co',
model: 'acme-washer',
hwVersion: '1.0',
swVersion: '1.0.1'
},
attributes: {
pausable: true
}
}]
},
}
});
However, exactly the same but with the type changed to Door fails and all I can see in Google Home is the app settings:
app.onSync(async (body, headers) => {
return {
requestId: body.requestId,
payload: {
agentUserId: '123',
devices: [{
id: 'washer-123',
type: 'action.devices.types.DOOR',
traits: [
'action.devices.traits.OnOff',
'action.devices.traits.StartStop',
'action.devices.traits.RunCycle'
],
name: {
defaultNames: ['My Washer'],
name: 'Washer',
nicknames: ['Washer']
},
deviceInfo: {
manufacturer: 'Acme Co',
model: 'acme-washer',
hwVersion: '1.0',
swVersion: '1.0.1'
},
attributes: {
pausable: true
}
}]
},
}
});
Is there anything specific about the DOOR device type compared to the OUTLET type that might be causing this to fail?

Touch controls are supported for OUTLET, but not for DOOR.

Related

Actions on google reservations for transaction API

We are building boot using action on builder SDK. In bot we have transaction related feature so we want to implement reservation feature to make appointment reservation. In our Bot we just need reservation. user can't cancel/delete reservation (As our member can contact the user for next 3 4 days, we are just asking user free time so we can contact user). (We did't have reservation feature yet but google team force us to do so). My Question is while implementing reservation we have https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#validate_transaction_requirements_optional this feature optional we are not implementing this, for second step we have to build Order like this https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#build_the_order
const order = {
createTime: '2019-09-24T18:00:00.877Z',
lastUpdateTime: '2019-09-24T18:00:00.877Z',
merchantOrderId: orderId, // A unique ID String for the order
userVisibleOrderId: orderId,
transactionMerchant: {
id: 'http://www.example.com',
name: 'Example Merchant',
},
contents: {
lineItems: [
{
id: 'LINE_ITEM_ID',
name: 'Dinner reservation',
description: 'A world of flavors all in one destination.',
reservation: {
status: 'PENDING',
userVisibleStatusLabel: 'Reservation is pending.',
type: 'RESTAURANT',
reservationTime: {
timeIso8601: '2020-01-16T01:30:15.01Z',
},
userAcceptableTimeRange: {
timeIso8601: '2020-01-15/2020-01-17',
},
partySize: 6,
staffFacilitators: [
{
name: 'John Smith',
},
],
location: {
zipCode: '94086',
city: 'Sunnyvale',
postalAddress: {
regionCode: 'US',
postalCode: '94086',
administrativeArea: 'CA',
locality: 'Sunnyvale',
addressLines: [
'222, Some other Street',
],
},
},
},
},
],
},
buyerInfo: {
email: 'janedoe#gmail.com',
firstName: 'Jane',
lastName: 'Doe',
displayName: 'Jane Doe',
},
followUpActions: [
{
type: 'VIEW_DETAILS',
title: 'View details',
openUrlAction: {
url: 'http://example.com',
},
},
{
type: 'CALL',
title: 'Call us',
openUrlAction: {
url: 'tel:+16501112222',
},
},
{
type: 'EMAIL',
title: 'Email us',
openUrlAction: {
url: 'mailto:person#example.com',
},
},
],
termsOfServiceUrl: 'http://www.example.com'
};
According to doc we have to create order object like above, but we are unable to find any doc what are optional filed in above object and what value to pass for reservationTime and userAcceptableTimeRange.
reservationTime: {
timeIso8601: '2020-01-16T01:30:15.01Z',
},
userAcceptableTimeRange: {
timeIso8601: '2020-01-15/2020-01-17',
}
Further more do we need to implement Set up asynchronous requests to the Orders API (https://developers.google.com/assistant/transactions/physical/dev-guide-physical-reservations#set_up_asynchronous_requests_to_the_orders_api) as we don't need to update user appoint time and user can't cancel appointment.
Is there any other way we can avoid reservation? please guide me, thanks in advance.

Payment token not in response

==== SOLVED ====
Problem is solved. Adyen wants you to send the whole string as an object. JSON.parse(token). Make sure Google pay is enabled in the Adyen platform.
================
I'm working on transactions with Actions on Google and integration Google Pay. I followed all steps according to the documentation of Actions on Google.
To propose an order I send the following snippet seen below.
Notes:
gateway value is replaced for security reasons.
gatewayMerchantId value is replaced for security reasons.
I'm using a registered gateway.
I have not yet registered as Google partner though the business console so I have no access to the production API.
// Handle order with Google Pay.
conv.ask(new TransactionDecision({
orderOptions: {
requestDeliveryAddress: true,
userInfoOptions: {
userInfoProperties: [
'EMAIL',
],
},
},
paymentParameters: {
googlePaymentOption: {
facilitationSpec: JSON.stringify({
apiVersion: 2,
apiVersionMinor: 0,
environment: 'TEST',
merchantInfo: {
merchantName: 'Example Merchant',
merchantId: '12345678901234567890',
},
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: [
'AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA',
],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'my_gateway',
'gatewayMerchantId': 'my_gateway_id',
},
},
},
],
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: prodPriceInclBtwInMicros.toString(),
currencyCode: 'EUR',
},
}),
},
},
presentationOptions: {
actionDisplayName: 'PLACE_ORDER',
},
order: order,
}));
The intent that handles the transaction decision value obtains the following arg value:
const arg = conv.arguments.get('TRANSACTION_DECISION_VALUE');
{
'#type': 'type.googleapis.com/google.actions.transactions.v3.TransactionDecisionValue',
transactionDecision: 'ORDER_ACCEPTED',
order: {
googleOrderId: '02458320178127324049',
merchantOrderId: 'example',
userVisibleOrderId: 'example',
buyerInfo: {
email: 'example#example.com',
firstName: 'example',
lastName: 'example',
displayName: 'example example'
},
createTime: '2020-07-21T10:59:16.624Z',
lastUpdateTime: '2020-07-21T10:59:16.624Z',
transactionMerchant: { name: 'Example Merchant' },
contents: { lineItems: [Array] },
priceAttributes: [ [Object], [Object], [Object] ],
paymentData: { paymentResult: [Object], paymentInfo: [Object] },
purchase: {
status: 'CREATED',
type: 'RETAIL',
userVisibleStatusLabel: 'CREATED'
},
vertical: {
'#type': 'type.googleapis.com/google.actions.orders.v3.verticals.purchase.PurchaseOrderExtension',
status: 'CREATED',
type: 'RETAIL',
userVisibleStatusLabel: 'CREATED'
}
}
}
According to [Adyen][1] I should provide the payment token: 'Get the token from PaymentData response from the Google Pay API.' [Google][2] states that the token will be returned in a response object after the user approves the payment. This is certainly not the case as can be seen in the `arg` object.
By digging deeper into the paymentData, we get the following values:
{
paymentResult: {
googlePaymentData: '{"signature":"MEYCIQDS8Tiu9bprWqamQ24oNx+Wa43Wg6Vi3sP5PArDeOtOEAIhAOBqe4sQvN5tD390qWzDn9DIgwA8gjS8ajynrusOix6O","protocolVersion":"ECv1","signedMessage":"{\\"encryptedMessage\\":\\"Some_tokens_IUHASIDHUSAGFUAHS\\",\\"ephemeralPublicKey\\":\\"SOMEKEYSASD\\\\u003d\\",\\"tag\\":\\"SOMETAG_OIASJDJSOIJ\\\\u003d\\"}"}'
},
paymentInfo: {
paymentMethodDisplayInfo: {
paymentType: 'PAYMENT_CARD',
paymentMethodDisplayName: 'Visa •••• 1234'
},
paymentMethodProvenance: 'PAYMENT_METHOD_PROVENANCE_GOOGLE'
}
}
Still no token returned in the response... This will be necessary for the gateway.
Does anyone know how to resolve this? Or does this have to with the production Transaction API?
Any help is appreciated.
[1]: https://docs.adyen.com/payment-methods/google-pay/api-only
[2]: https://developers.google.com/pay/api/web/reference/response-objects#PaymentData

Smart Home TemperatureSetting reading(celsius) custom range

I am using action.devices.types.THERMOSTAT with action.devices.traits.TemperatureSetting, i want to set custom range for Celsius from 16 to 28 is it possible ? i have tried using bufferRangeCelsius attribute but it did not produced any effect on range and default Celsius range from 10 to 32 appearing , i have tried as given below,
app.onSync((body, headers) => {
return {
requestId: body.requestId,
payload: {
agentUserId: '1836.15267389',
devices: [{
id: '123',
type: 'action.devices.types.THERMOSTAT',
traits: [
'action.devices.traits.TemperatureSetting'
],
name: {
defaultNames: ['Honeywell Thermostat T-1000'],
name: 'Homer Simpson Thermostat',
nicknames: ['living room thermostat']
},
willReportState: false,
attributes: {
availableThermostatModes: 'off,heat,cool,on',
thermostatTemperatureUnit: 'C',
bufferRangeCelsius : 16-28
},
deviceInfo: {
manufacturer: 'honeywell',
model: 't-1000',
hwVersion: '3.2',
swVersion: '11.4'
},
customData: {
fooValue: 74,
barValue: true,
bazValue: 'lambtwirl'
}
}]
}
};
});
The bufferRangeCelsius attribute is intended to report the minimum difference between two setpoints in heatcool mode, and doesn't affect the min/max range where setpoints are allowed (when the docs mention range they are generally referring to the distance between a current low and high setpoint).
Reporting the full supported range of your thermostat's temperature control is not currently supported by the API. If your service receives a request to set the temperature outside of the supported range, return a valueOutOfRange error response:
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"commands": [
{
"ids": ["123"],
"status": "ERROR",
"errorCode": "valueOutOfRange"
}
]
}
}

Google Actions Smart Home on Lambda not working

I've been trying to get my Google Actions Smart Home (nodejs) working in AWS lambda. However it isn't working. Whenever I connect it on the Google Home app, I just get a message of "Couldn't update the setting...". I've already configured the API gateway correctly and set the Handler to "index.smarthome" as shown in the below image link. Why isn't it working, and how can I get my lambda google action smart home working?
Image Link
My firebase version is working though (modified from the washing machine example at https://codelabs.developers.google.com/codelabs/smarthome-washer/#2).
const functions = require('firebase-functions');
const {smarthome} = require('actions-on-google');
const app = smarthome();
app.onSync(body => {
return {
requestId: 'ff36a3cc-ec34-11e6-b1a0-64510650abcf',
payload: {
agentUserId: '123',
devices: [{
id: 'washer',
type: 'action.devices.types.WASHER',
traits: [
'action.devices.traits.OnOff',
'action.devices.traits.StartStop',
'action.devices.traits.RunCycle',
'action.devices.traits.Modes',
'action.devices.traits.Toggles',
],
name: {
defaultNames: ['My Washer'],
name: 'Washer',
nicknames: ['Washer']
},
deviceInfo: {
manufacturer: 'Acme Co',
model: 'acme-washer',
hwVersion: '1.0',
swVersion: '1.0.1'
},
attributes: {
pausable: true,
availableModes: [{
name: 'load',
name_values: [{
name_synonym: ['load'],
lang: 'en'
}],
settings: [{
setting_name: 'small',
setting_values: [{
setting_synonym: ['small'],
lang: 'en'
}]
}, {
setting_name: 'large',
setting_values: [{
setting_synonym: ['large'],
lang: 'en'
}]
}],
ordered: true
}],
availableToggles: [{
name: 'Turbo',
name_values: [{
name_synonym: ['turbo'],
lang: 'en'
}]
}]
}
}]
}
};
});
app.onExecute((body) => {
const {requestId} = body;
const payload = {
commands: [{
ids: [],
status: 'SUCCESS',
states: {
online: true,
},
}],
};
for (const input of body.inputs) {
for (const command of input.payload.commands) {
for (const device of command.devices) {
const deviceId = device.id;
payload.commands[0].ids.push(deviceId);
for (const execution of command.execution) {
const execCommand = execution.command;
const {params} = execution;
switch (execCommand) {
case 'action.devices.commands.OnOff':
payload.commands[0].states.on = params.on;
break;
case 'action.devices.commands.StartStop':
payload.commands[0].states.isRunning = params.start;
break;
case 'action.devices.commands.PauseUnpause':
payload.commands[0].states.isPaused = params.pause;
break;
case 'action.devices.commands.SetModes':
break;
case 'action.devices.commands.SetToggles':
break;
}
}
}
}
}
return {
requestId: requestId,
payload: payload,
};
});
exports.smarthome = functions.https.onRequest(app);
And here is the code that I used in my AWS lambda function. I referenced https://github.com/actions-on-google/actions-on-google-nodejs & creating dialogflow v2 project with serverless to make it lambda compatible. The main difference between the lambda and firebase versions is the "exports.smarthome" code.
const {smarthome} = require('actions-on-google');
const app = smarthome();
app.onSync(body => {
return {
requestId: 'ff36a3cc-ec34-11e6-b1a0-64510650abcf',
payload: {
agentUserId: '123',
devices: [{
id: 'washer',
type: 'action.devices.types.WASHER',
traits: [
'action.devices.traits.OnOff',
'action.devices.traits.StartStop',
'action.devices.traits.RunCycle',
'action.devices.traits.Modes',
'action.devices.traits.Toggles',
],
name: {
defaultNames: ['My Washer'],
name: 'Washer',
nicknames: ['Washer']
},
deviceInfo: {
manufacturer: 'Acme Co',
model: 'acme-washer',
hwVersion: '1.0',
swVersion: '1.0.1'
},
attributes: {
pausable: true,
availableModes: [{
name: 'load',
name_values: [{
name_synonym: ['load'],
lang: 'en'
}],
settings: [{
setting_name: 'small',
setting_values: [{
setting_synonym: ['small'],
lang: 'en'
}]
}, {
setting_name: 'large',
setting_values: [{
setting_synonym: ['large'],
lang: 'en'
}]
}],
ordered: true
}],
availableToggles: [{
name: 'Turbo',
name_values: [{
name_synonym: ['turbo'],
lang: 'en'
}]
}]
}
}]
}
};
});
app.onExecute((body) => {
const {requestId} = body;
const payload = {
commands: [{
ids: [],
status: 'SUCCESS',
states: {
online: true,
},
}],
};
for (const input of body.inputs) {
for (const command of input.payload.commands) {
for (const device of command.devices) {
const deviceId = device.id;
payload.commands[0].ids.push(deviceId);
for (const execution of command.execution) {
const execCommand = execution.command;
const {params} = execution;
switch (execCommand) {
case 'action.devices.commands.OnOff':
payload.commands[0].states.on = params.on;
break;
case 'action.devices.commands.StartStop':
payload.commands[0].states.isRunning = params.start;
break;
case 'action.devices.commands.PauseUnpause':
payload.commands[0].states.isPaused = params.pause;
break;
case 'action.devices.commands.SetModes':
break;
case 'action.devices.commands.SetToggles':
break;
}
}
}
}
}
return {
requestId: requestId,
payload: payload,
};
});
exports.smarthome = function(event, context, callback) {
app.handler(event, {})
.then((res) => {
if (res.status != 200) {
callback(null, {
"fulfillmentText": `I got status code: ${res.status}`
});
} else {
callback(null, res.body);
}
}).catch((e) => {
callback(null, {
"fulfillmentText": `There was an error\n${e}`
});
});
};
Check your AWS CloudWatch logs and see what happens when the lambda is called. You can print to stdout in your lambda and have it show up in these logs.
Along with your Cloudwatch logs, you could also have a look at your Stackdriver logs.

Extjs PUT url with wrong id

I'm new to senach and ExtJs, and I'm trying to read and write json data. getting the data is already working, but I can't write changed data back to the server.
I'm using a ExtJs 4.2.
I configured one URL in the RestProxy url: /animals/dogs/
GET http://example.com/animals/dogs
PUThttp://example.com/animals/dogs/{id}
Get is working as expected. But the PUT URL is:
example.com/animals/dogs/project.model.dogs-3?dc435453...
The id also contains the model name. How can I change this to the id like above?
This is the store:
Ext.define('project.store.MyJsonStore', {
extend: 'Ext.data.Store',
requires: [
'project.model.dogs',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
model: 'project.model.dogs',
storeId: 'MyJsonStore',
proxy: {
type: 'rest',
limitParam: 'count',
url: '/animals/dogs,
reader: {
type: 'json',
idProperty: 'id',
root: 'data'
}
}
}, cfg)]);
}
});
This is the model:
Ext.define('project.model.dogs', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field'
],
clientIdProperty: 'id',
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'type',
type: 'string'
}
]
});
GET Respones: (reader root is data)
{
"success": true,
"data":
[
{
"id": 1,
"type": "Some Type",
"url": "/animals/dogs/1"
},
{
"id": 2,
"type": "Some other Type",
"url": "/animals/dogs/2"
},
]
}
The PUT urls look like:
example.com/animals/dogs/project.model.dogs-3?dc...
example.com/animals/dogs/project.model.dogs-7?dc...
example.com/animals/dogs/project.model.dogs-8?dc...
The numbers 3, 7, 8 are the id's, so extjs recognizes the id property in the model.
Regards,
Sencha Beginner