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"
}
]
}
}
Related
I can't find any answers or tips on how to work with deeply nested data with GraphQL and Mongoose. I would've thought this is a fairly common thing to do, but the docs are also pretty vague when it comes to stuff like this.
Here's how my data should look like. It is basically and a collection of invoices. Each invoice data for that invoice like customer name, invoice number, etc. It also contains an array of sections. Each section has data about that section like the type of products, color of products, etc. Each section itself contains an array of invoiceLines, and they all contain a product that takes properties from the section it is contained in, and also has it's own data.
Pseudo code:
{
"invoices": [
{
"_id": "123456",
"invoiceNumber": "i2022-123",
"customer": "John Doe",
"date": "2022-11-02",
"sections": [
{
"type": "phones",
"color": "red",
"invoiceLines": [
{
"product": "iPhone",
"year": "2022"
},
{
"product": "Samsung",
"year": "2021"
}
]
},
{
"type": "tablets",
"color": "black",
"invoiceLines": [
{
"product": "iPad",
"year": "2022"
},
{
"product": "Samsung tablet",
"year": "2021"
}
]
}
]
},
{
"Another": "Invoice"
}
]
}
My GraphQl queries look like so:
const query = new GraphQLObjectType({
name: 'RootQueryType',
fields: {
getInvoices: {
type: new GraphQLList(ProjectType),
resolve(parent, args) {
return Project.find();
}
},
getInvoice: {
type: ProjectType,
args: { id: { type: GraphQLID } },
resolve(parent, args) {
return Project.findById(args.id);
}
}
}
});
Question #1: How would I query a specific section or an invoice line? they all have MongoDB IDs, but for some reason I can't use that to query them.
const { Project } = require('../../models/Project');
const { SectionType, SectionInputType } = require('../TypeDefs/SectionType');
const ProjectType = require('../TypeDefs/ProjectType');
const mutation = new GraphQLObjectType({
name: 'Mutation',
fields: {
// Add a Project
addProject: {
type: ProjectType,
args: {
date: { type: GraphQLString },
invoiceNumber: { type: GraphQLNonNull(GraphQLString) },
customer: { type: GraphQLNonNull(GraphQLString) },
},
resolve(parent, args) {
const project = new Project({
date: args.date,
invoiceNumber: args.invoiceNumber,
customer: args.customer,
sections: [],
})
return project.save()
}
},
// Add a Section
addSection: {
type: SectionType,
args: {
// MongoDB ID for the project the section belongs to
id: { type: GraphQLID },
section: { type: SectionInputType }
},
async resolve(parent, args) {
const newSection = args.section;
return await Project.updateOne({ _id: args.id }, {
$push: { sections: newSection }
})
}
},
}
});
I'm using $push to add a section to the invoice.sections and that works perfectly because I can get a hold of the invoice by the MongoDB ID.
Question #2: In that case how would I be able to add invoice lines to these sections that I add with this method, since I'm not able to get a hold of the sections by their respective _id.
I guess my main issue is that I'm not able to get a hold of nested MongoDB IDs.
Any help would be appreciated, or any pointers to good resources for GraphQL and Mongoose.
P.S. Yes, I'm new to GraphQL, but I like the concept of it so I wanted to explore it.
I've tried resources from YouTube and from graphQL docs, but pretty much everything is vague when it comes to a problem like this. I would think the deeply nested data like this is a common occurrence, but I can't find proper resources
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.
I'm making lookalike custom audiences via the Facebook API but I keep getting this error message when I try to make a second audience from the same seed:
"(#2654) Can't create a duplicate lookalike: You've already created a Lookalike Audience with the same source, country and size. Please try using a different source or different specifications."
In this case, the country and seed are the same but the ratio is different for the two audiences. When I create lookalikes to the exact same specification through adsmanager in the browser, they are created successfully.
Here are examples of the payloads I sent:
//Audience successfully created
{
name: "LLA0%-FB | Engaged | 30 (2020-09-23) (US)",
subtype: "LOOKALIKE",
origin_audience_id: "123456789",
lookalike_spec: {
type: "reach",
ratio: 0.05,
allow_international_seeds: "on",
location_spec: {
geo_locations: { countries: ["US"] },
},
},
}
//Error
{
name: "LLA20%-FB | Engaged | 30 (2020-09-23) (US)",
subtype: "LOOKALIKE",
origin_audience_id: "123456789",
lookalike_spec: {
type: "reach",
ratio: 0.2,
allow_international_seeds: "on",
location_spec: {
geo_locations: { countries: ["US"] },
},
},
};
The problem with your api requests is you are specifying both type and ratio in api requests . So the ratio value is ignored by the facebook requests .
https://developers.facebook.com/docs/marketing-api/audiences/guides/lookalike-audiences/#lookalike-audiences
See type use either type or ratio. You should use ratio like this
{
name: "LLA0%-FB | Engaged | 30 (2020-09-23) (US)",
subtype: "LOOKALIKE",
origin_audience_id: "123456789",
lookalike_spec: {
type: "reach",
ratio: 0.05,
allow_international_seeds: "on",
location_spec: {
geo_locations: { countries: ["US"] },
},
},
}
I wish to use ECharts to implement a page. In this page, the user can use some buttons to add a node(or edge) or edit the name of a node(or edge). So I want to manipulate the nodes of a relation graph such as the force layout which is shown here:
https://echarts.apache.org/examples/en/editor.html?c=graph-force
Now my question is, since the data of the graph in the example is provided by a gexf file, is there any way to control them from javascript? Like adding a node, deleting a node, or editing a node(or edge).
The data used in the example is in XML format which is later converted to an array of objects, you can look at that format and generate your own using javascript. For instance,
var nodes = [
{
id: "0",
name: "",
itemStyle: null,
symbolSize: 50,
attributes: {
modularity_class: 0
},
value: 28.685715,
label: {
show: false
},
category: 0
},
{
id: "1",
name: "",
itemStyle: null,
symbolSize: 10,
attributes: {
modularity_class: 0
},
value: 4,
label: {
show: false
},
category: 0
},
{
id: "2",
name: "",
itemStyle: null,
symbolSize: 10,
attributes: {
modularity_class: 0
},
value: 9.485714,
label: {
show: false
},
category: 0
}];
var links = [
{
id: "0",
name: null,
source: "0",
target: "1",
lineStyle: {
normal: {}
}
},
{
id: "1",
name: null,
source: "0",
target: "2",
lineStyle: {
normal: {}
}];
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