Created
December 10, 2020 00:14
-
-
Save nayelyzarazua-bluetrail/0ec6d52dbf560491b2cc6e382267fc53 to your computer and use it in GitHub Desktop.
MultiComponent_ST_Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {SchemaConnector, DeviceErrorTypes} = require('st-schema'); | |
const deviceStates = { switch: 'off',switch2: 'off', temperature: 40, humidity:80, healthStatus:'online', healthStatus2:'online',listElement:'monthFlow'}//1-10 | |
const connector = new SchemaConnector() | |
.enableEventLogging(2) | |
.discoveryHandler((accessToken, response) => { | |
const d = response.addDevice('st-schema-component', 'st-schema-component', 'e0c682fd-46d9-4fee-8bdd-9edc5da7e053') | |
//Device manufacturer | |
d.manufacturerName('xxxx'); | |
//Device model | |
d.modelName('xxxxx'); | |
}) | |
.stateRefreshHandler((accessToken, response) => { | |
let d1 = response.addDevice('st-schema-component') | |
let main = d1.addComponent('main'); | |
main.addState('st.switch','switch',deviceStates.switch) | |
main.addState('st.temperatureMeasurement','temperature',deviceStates.temperature,"C") | |
main.addState('st.relativeHumidityMeasurement','humidity',deviceStates.humidity) | |
main.addState('st.healthCheck','healthStatus',deviceStates.healthStatus) | |
let humidityControl = d1.addComponent('HumidityControl'); | |
humidityControl.addState('st.switch','switch',deviceStates.switch2) | |
humidityControl.addState('schoolwater29967.numberFieldTest','listElement',deviceStates.listElement) | |
humidityControl.addState('st.healthCheck','healthStatus',deviceStates.healthStatus2) | |
}) | |
.commandHandler((accessToken, response, devices) => { | |
//... | |
}); | |
module.exports = connector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"mnmn": "xxxx", | |
"vid": "5de770b2-08fd-3f82-ad4c-0f4e72bc62bf", | |
"type": "profile", | |
"dashboard": { | |
"states": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"version": 1 | |
} | |
], | |
"actions": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"version": 1 | |
} | |
] | |
}, | |
"detailView": [ | |
{ | |
"component": "main", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "temperatureMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "relativeHumidityMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "schoolwater29967.numberFieldTest", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
} | |
], | |
"automation": { | |
"conditions": [ | |
{ | |
"component": "main", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "temperatureMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "relativeHumidityMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "schoolwater29967.numberFieldTest", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
} | |
], | |
"actions": [ | |
{ | |
"component": "main", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "temperatureMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "relativeHumidityMeasurement", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "main", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "switch", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "schoolwater29967.numberFieldTest", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
}, | |
{ | |
"component": "HumidityControl", | |
"capability": "healthCheck", | |
"version": 1, | |
"values": [], | |
"patch": [] | |
} | |
] | |
}, | |
"migration": true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment