changed layout to work as a repository in hassio
This commit is contained in:
parent
acb3cc1ad3
commit
471ec7023e
12 changed files with 47 additions and 14 deletions
|
|
@ -22,9 +22,10 @@ const logger = getLogger();
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
class PlejdApi extends EventEmitter {
|
class PlejdApi extends EventEmitter {
|
||||||
constructor(siteName, username, password) {
|
constructor(siteName, username, password, includeRoomsAsLights) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.includeRoomsAsLights = includeRoomsAsLights;
|
||||||
this.siteName = siteName;
|
this.siteName = siteName;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
|
@ -89,6 +90,8 @@ class PlejdApi extends EventEmitter {
|
||||||
logger(JSON.stringify(this.site));
|
logger(JSON.stringify(this.site));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const roomDevices = {};
|
||||||
|
|
||||||
for (let i = 0; i < this.site.devices.length; i++) {
|
for (let i = 0; i < this.site.devices.length; i++) {
|
||||||
const device = this.site.devices[i];
|
const device = this.site.devices[i];
|
||||||
const deviceId = device.deviceId;
|
const deviceId = device.deviceId;
|
||||||
|
|
@ -119,9 +122,37 @@ class PlejdApi extends EventEmitter {
|
||||||
|
|
||||||
logger(JSON.stringify(newDevice));
|
logger(JSON.stringify(newDevice));
|
||||||
|
|
||||||
|
if (roomDevices[device.roomId]) {
|
||||||
|
roomDevices[device.roomId].push(newDevice);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
roomDevices[device.roomId] = [newDevice];
|
||||||
|
}
|
||||||
|
|
||||||
devices.push(newDevice);
|
devices.push(newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.includeRoomsAsLights) {
|
||||||
|
logger('includeRoomsAsLights is set to true, adding rooms too.');
|
||||||
|
for (let i = 0; i < this.site.rooms.length; i++) {
|
||||||
|
const room = this.site.rooms[i];
|
||||||
|
const roomId = room.roomId;
|
||||||
|
const roomAddress = this.site.roomAddress[roomId];
|
||||||
|
|
||||||
|
const newDevice = {
|
||||||
|
id: roomAddress,
|
||||||
|
name: room.title,
|
||||||
|
type: 'light',
|
||||||
|
typeName: 'Room',
|
||||||
|
dimmable: roomDevices[roomId].find(x => x.dimmable).length > 0
|
||||||
|
};
|
||||||
|
|
||||||
|
logger(JSON.stringify(newDevice));
|
||||||
|
|
||||||
|
devices.push(newDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Plejd",
|
"name": "Plejd",
|
||||||
"version": "3",
|
"version": "4",
|
||||||
"slug": "plejd",
|
"slug": "plejd",
|
||||||
"description": "Adds support for the Swedish home automation devices from Plejd.",
|
"description": "Adds support for the Swedish home automation devices from Plejd.",
|
||||||
|
"url": "https://github.com/icanos/hassio-plejd/",
|
||||||
"arch": [
|
"arch": [
|
||||||
"armhf",
|
"armhf",
|
||||||
"armv7",
|
"armv7",
|
||||||
|
|
@ -12,15 +13,6 @@
|
||||||
],
|
],
|
||||||
"startup": "application",
|
"startup": "application",
|
||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
"auto_uart": true,
|
|
||||||
"gpio": true,
|
|
||||||
"privileged": [
|
|
||||||
"SYS_RAWIO"
|
|
||||||
],
|
|
||||||
"devices": [
|
|
||||||
"/dev/mem:/dev/mem:rwm"
|
|
||||||
],
|
|
||||||
"apparmor": false,
|
|
||||||
"host_network": true,
|
"host_network": true,
|
||||||
"options": {
|
"options": {
|
||||||
"site": "Default Site",
|
"site": "Default Site",
|
||||||
|
|
@ -28,7 +20,8 @@
|
||||||
"password": "",
|
"password": "",
|
||||||
"mqttBroker": "mqtt://",
|
"mqttBroker": "mqtt://",
|
||||||
"mqttUsername": "",
|
"mqttUsername": "",
|
||||||
"mqttPassword": ""
|
"mqttPassword": "",
|
||||||
|
"includeRoomsAsLights": false
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
"site": "str",
|
"site": "str",
|
||||||
|
|
@ -36,6 +29,7 @@
|
||||||
"password": "str",
|
"password": "str",
|
||||||
"mqttBroker": "str",
|
"mqttBroker": "str",
|
||||||
"mqttUsername": "str",
|
"mqttUsername": "str",
|
||||||
"mqttPassword": "str"
|
"mqttPassword": "str",
|
||||||
|
"includeRoomsAsLights": "bool"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ PASSWORD=$(jq --raw-output ".password" $CONFIG_PATH)
|
||||||
MQTTBROKER=$(jq --raw-output ".mqttBroker" $CONFIG_PATH)
|
MQTTBROKER=$(jq --raw-output ".mqttBroker" $CONFIG_PATH)
|
||||||
MQTTUSERNAME=$(jq --raw-output ".mqttUsername" $CONFIG_PATH)
|
MQTTUSERNAME=$(jq --raw-output ".mqttUsername" $CONFIG_PATH)
|
||||||
MQTTPASSWORD=$(jq --raw-output ".mqttPassword" $CONFIG_PATH)
|
MQTTPASSWORD=$(jq --raw-output ".mqttPassword" $CONFIG_PATH)
|
||||||
|
INCLUDEROOMSASLIGHTS=$(jq --raw-output ".includeRoomsAsLights" $CONFIG_PATH)
|
||||||
|
|
||||||
PLEJD_PATH=/data/plejd.json
|
PLEJD_PATH=/data/plejd.json
|
||||||
PLEJD_CONFIG="{
|
PLEJD_CONFIG="{
|
||||||
|
|
@ -16,7 +17,8 @@ PLEJD_CONFIG="{
|
||||||
\"password\": \"$PASSWORD\",
|
\"password\": \"$PASSWORD\",
|
||||||
\"mqttBroker\": \"$MQTTBROKER\",
|
\"mqttBroker\": \"$MQTTBROKER\",
|
||||||
\"mqttUsername\": \"$MQTTUSERNAME\",
|
\"mqttUsername\": \"$MQTTUSERNAME\",
|
||||||
\"mqttPassword\": \"$MQTTPASSWORD\"
|
\"mqttPassword\": \"$MQTTPASSWORD\",
|
||||||
|
\"includeRoomsAsLights\": \"$INCLUDEROOMSASLIGHTS\"
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
6
repository.json
Normal file
6
repository.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "Unofficial Plejd Add-on",
|
||||||
|
"url": "https://github.com/icanos/hassio-plejd",
|
||||||
|
"maintainer": "Marcus Westin <marcus@sekurbit.se>"
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue