Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 34 additions & 65 deletions .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,38 @@
{
"id": "ady.smartthings",
"version": "2.0.40",
"compatibility": ">=12.0.1",
"sdk": 3,
"platforms": [
"local"
],
"brandColor": "#2ACAEA",
"name": {
"en": "SmartThings Community"
},
"description": {
"en": "Make your SmartThings smarter with Homey"
},
"category": [
"appliances"
],
"contributing": {
"donate": {
"paypal": {
"username": "adyrock"
}
}
},
"permissions": [],
"images": {
"large": "/assets/images/large.png",
"small": "/assets/images/small.png",
"xlarge": "/assets/images/xlarge.png"
},
"author": {
"name": "Adrian Rockall",
"email": "ady@rockalls.com"
},
"bugs": {
"url": "https://github.com/AdyRock/com.smartthings/issues"
},
"source": "https://github.com/AdyRock/com.smartthings",
"support": "https://github.com/AdyRock/com.smartthings/issues",
"homeyCommunityTopicId": 61418,
"api": {
"getLog": {
"method": "get",
"path": "/getLog/"
"id": "com.smartthings",
"name": {
"en": "SmartThings",
"da": "SmartThings"
},
"version": "1.0.0",
"compatibility": ">=5.0.0",
"permissions": [
"homey:app:com.smartthings"
],
"drivers": [
{
"id": "st_device",
"name": {
"en": "SmartThings Enhed",
"da": "SmartThings Enhed"
},
"class": "other",
"capabilities": ["onoff", "dim", "alarm_contact"],
"pair": [
{
"id": "pat_input",
"template": "login_credentials",
"options": {
"title": "Forbind til SmartThings",
"usernameLabel": "Brugernavn (efterlad tom)",
"passwordLabel": "Indsæt PAT Token her"
}
},
"getDetect": {
"method": "get",
"path": "/getDetect/"
},
"clearLog": {
"method": "post",
"path": "/clearLog/"
},
"sendCmd": {
"method": "post",
"path": "/sendCmd/"
},
"SendDeviceLog": {
"method": "post",
"path": "/SendDeviceLog/",
"public": true
},
"SendInfoLog": {
"method": "post",
"path": "/SendInfoLog/"
{
"id": "list_devices",
"template": "list_devices"
}
]
}
}
]
}
1 change: 1 addition & 0 deletions home
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b779b38e-da2b-499e-844e-1b88daa6692a
33 changes: 33 additions & 0 deletions homebott
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const Homey = require('homey');
const fetch = require('node-fetch');

class SmartThingsDriver extends Homey.Driver {
async onPair(session) {
let patToken = '';

// Trin 1: Tjek om token virker
session.setHandler('login', async (data) => {
patToken = data.password;
const res = await fetch('https://api.smartthings.com/v1/devices', {
headers: { 'Authorization': 'Bearer ' + patToken }
});
if (!res.ok) throw new Error('Ugyldig PAT Token. Tjek dine rettigheder.');
return true;
});

// Trin 2: Hent enhedslisten
session.setHandler('list_devices', async () => {
const res = await fetch('https://api.smartthings.com/v1/devices', {
headers: { 'Authorization': 'Bearer ' + patToken }
});
const json = await res.json();

return json.items.map(device => ({
name: device.label || device.name,
data: { id: device.deviceId, token: patToken },
store: { capabilities: device.components[0].capabilities.map(c => c.id) }
}));
});
}
}
module.exports = SmartThingsDriver;