Skip to content

New Components - philips_hue #16456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025
Merged
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
41 changes: 41 additions & 0 deletions components/philips_hue/actions/activate-scene/activate-scene.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import philipsHue from "../../philips_hue.app.mjs";

export default {
key: "philips_hue-activate-scene",
name: "Activate Scene",
description: "Activates a Philips Hue light scene. [See the documentation](https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_light__id__put)",
version: "0.0.1",
type: "action",
props: {
philipsHue,
username: {
propDefinition: [
philipsHue,
"username",
],
},
sceneId: {
propDefinition: [
philipsHue,
"sceneId",
(c) => ({
username: c.username,
}),
],
},
},
async run({ $ }) {
const response = await this.philipsHue.updateScene({
$,
username: this.username,
sceneId: this.sceneId,
data: {
recall: {
action: "active",
},
},
});
$.export("$summary", `Successfully activated scene with ID: ${this.sceneId}`);
return response;
},
};
92 changes: 92 additions & 0 deletions components/philips_hue/actions/set-light-color/set-light-color.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import philipsHue from "../../philips_hue.app.mjs";
import { ConfigurationError } from "@pipedream/platform";
import convert from "color-convert";

export default {
key: "philips_hue-set-light-color",
name: "Set Light Color",
description: "Sets the light color of a Philips Hue light. [See the documentation](https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_light__id__put)",
version: "0.0.1",
type: "action",
props: {
philipsHue,
username: {
propDefinition: [
philipsHue,
"username",
],
},
lightId: {
propDefinition: [
philipsHue,
"lightId",
(c) => ({
username: c.username,
}),
],
optional: true,
},
groupId: {
propDefinition: [
philipsHue,
"groupId",
(c) => ({
username: c.username,
}),
],
optional: true,
},
color: {
type: "string",
label: "Color",
description: "A hexidecimal color value to set the light(s) to. E.g. `#800080`",
},
},
methods: {
hexToCIE(hex) {
const rgb = convert.hex.rgb(hex);
const xyz = convert.rgb.xyz(rgb);
const x = xyz[0] / (xyz[0] + xyz[1] + xyz[2]);
const y = xyz[1] / (xyz[0] + xyz[1] + xyz[2]);
return {
x,
y,
};
},
},
async run({ $ }) {
if ((!this.lightId && !this.groupId) || (this.lightId && this.groupId)) {
throw new ConfigurationError("Must specify exactly one of Light ID or GroupID");
}

const {
x, y,
} = this.hexToCIE(this.color);

const opts = {
$,
username: this.username,
data: {
color: {
xy: {
x,
y,
},
},
},
};

const response = this.lightId
? await this.philipsHue.updateLight({
lightId: this.lightId,
...opts,
})
: await this.philipsHue.updateGroup({
groupId: this.groupId,
...opts,
});

$.export("$summary", `Successfully set light color to ${this.color}`);
return response;
},
};
75 changes: 75 additions & 0 deletions components/philips_hue/actions/turn-light-on/turn-light-on.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import philipsHue from "../../philips_hue.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "philips_hue-turn-light-on",
name: "Turn Light On",
description: "Turns on or off a Philips Hue light or group of lights. [See the documentation](https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_light__id__put)",
version: "0.0.1",
type: "action",
props: {
philipsHue,
username: {
propDefinition: [
philipsHue,
"username",
],
},
lightId: {
propDefinition: [
philipsHue,
"lightId",
(c) => ({
username: c.username,
}),
],
optional: true,
},
groupId: {
propDefinition: [
philipsHue,
"groupId",
(c) => ({
username: c.username,
}),
],
optional: true,
},
turnLightOff: {
type: "boolean",
label: "Turn Light(s) Off",
description: "Set to `true` to turn the light(s) off instead of on",
optional: true,
},
},
async run({ $ }) {
if ((!this.lightId && !this.groupId) || (this.lightId && this.groupId)) {
throw new ConfigurationError("Must specify exactly one of Light ID or GroupID");
}

const opts = {
$,
username: this.username,
data: {
on: {
on: !this.turnLightOff,
},
},
};

const response = this.lightId
? await this.philipsHue.updateLight({
lightId: this.lightId,
...opts,
})
: await this.philipsHue.updateGroup({
groupId: this.groupId,
...opts,
});

$.export("$summary", `Successfully turned ${this.turnLightOff
? "off"
: "on"} light(s)`);
return response;
},
};
4 changes: 2 additions & 2 deletions components/philips_hue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/philips_hue",
"version": "0.6.0",
"version": "0.7.0",
"description": "Pipedream philips_hue Components",
"main": "philips_hue.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
"@pipedream/platform": "^3.0.3"
}
}
Loading
Loading