Skip to content

Commit

Permalink
added icons for devices
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 28, 2017
1 parent fd089e7 commit f8ca4f7
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ The result object `ret` looks as follows:

## Changelog

#### 0.5.2 (2017-10-28)
* (AlCalzone) Added icons for devices

#### 0.5.1 (2017-10-28)
* (AlCalzone) Support virtual groups
* (AlCalzone) Validate hex colors on input
Expand Down
Binary file added admin/icons/bulb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/bulb_2700k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/bulb_rgb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/bulb_ws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/door_ws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/gateway.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/gu10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/gu10_2700k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/gu10_ws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/motion_sensor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/panel_ws.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/plug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/remote.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/icons/remote_dimmer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 42 additions & 1 deletion build/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,54 @@ function getTransitionDuration(accessoryOrGroup) {
return 0.5; // default
});
}
function getAccessoryIcon(accessory) {
const model = accessory.deviceInfo.modelNumber;
switch (model) {
case "TRADFRI remote control":
return "remote.png";
case "TRADFRI motion sensor":
return "motion_sensor.png";
case "TRADFRI wireless dimmer":
return "remote_dimmer.png";
case "TRADFRI plug":
return "plug.png";
}
if (accessory.type === accessory_1.AccessoryTypes.lightbulb) {
let prefix;
if (model.indexOf(" panel ") > -1) {
prefix = "panel";
}
else if (model.indexOf(" door ") > -1) {
prefix = "door";
}
else if (model.indexOf(" GU10 ") > -1) {
prefix = "gu10";
}
else {
prefix = "bulb";
}
let suffix = "";
const spectrum = accessory.lightList[0].spectrum;
if (spectrum === "white") {
suffix = "_ws";
}
else if (spectrum === "rgb") {
suffix = "_rgb";
}
return prefix + suffix + ".png";
}
}
/**
* Returns the common part of the ioBroker object representing the given accessory
*/
function accessoryToCommon(accessory) {
return {
const ret = {
name: accessory.name,
};
const icon = getAccessoryIcon(accessory);
if (icon != null)
ret.icon = "icons/" + icon;
return ret;
}
/**
* Returns the native part of the ioBroker object representing the given accessory
Expand Down
10 changes: 7 additions & 3 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"common": {
"name": "tradfri",
"version": "0.5.1",
"version": "0.5.2",
"news": {
"0.5.2": {
"en": "Added icons for devices",
"de": "Icons für Geräte hinzugefügt"
},
"0.5.1": {
"en": "Support of virtual groups",
"de": "Unterstützung virtueller Gruppen"
},
"0.4.5": {
"en": "Bugfixes.",
"de": "Bugfixes."
"en": "Bugfixes",
"de": "Bugfixes"
},
"0.4.4": {
"en": "Experimental support for RGB and lightbulbs with fixed color.",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.tradfri",
"version": "0.5.1",
"version": "0.5.2",
"description": "ioBroker tradfri Adapter",
"author": {
"name": "AlCalzone",
Expand Down
39 changes: 38 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,50 @@ async function getTransitionDuration(accessoryOrGroup: Accessory | Group | Virtu
return 0.5; // default
}

function getAccessoryIcon(accessory: Accessory): string {
const model = accessory.deviceInfo.modelNumber;
switch (model) {
case "TRADFRI remote control":
return "remote.png";
case "TRADFRI motion sensor":
return "motion_sensor.png";
case "TRADFRI wireless dimmer":
return "remote_dimmer.png";
case "TRADFRI plug":
return "plug.png";
}
if (accessory.type === AccessoryTypes.lightbulb) {
let prefix: string;
if (model.indexOf(" panel ") > -1) {
prefix = "panel";
} else if (model.indexOf(" door ") > -1) {
prefix = "door";
} else if (model.indexOf(" GU10 ") > -1) {
prefix = "gu10";
} else {
prefix = "bulb";
}
let suffix: string = "";
const spectrum = accessory.lightList[0].spectrum;
if (spectrum === "white") {
suffix = "_ws";
} else if (spectrum === "rgb") {
suffix = "_rgb";
}
return prefix + suffix + ".png";
}
}

/**
* Returns the common part of the ioBroker object representing the given accessory
*/
function accessoryToCommon(accessory: Accessory): ioBroker.ObjectCommon {
return {
const ret: ioBroker.ObjectCommon = {
name: accessory.name,
};
const icon = getAccessoryIcon(accessory);
if (icon != null) ret.icon = "icons/" + icon;
return ret;
}

/**
Expand Down

0 comments on commit f8ca4f7

Please sign in to comment.