# Creating custom node using nodejs repo (Govee)

**URL:** <https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746>\
**Category:** Developing Nodes\
**Created:** [16 January 2022 13:22 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746 "2022-01-16T13:22:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![m661](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@m661](https://discourse.nodered.org/u/m661)\
**Post date:** [16 January 2022 13:22 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/1 "2022-01-16T13:22:20Z")

</div>

Hi,

Been playing with Node-Red for a couple of months, working great so far.

I would like to use [node-govee-led - npm ([npmjs.com](http://npmjs.com))]

[node-govee-led - npm](https://www.npmjs.com/package/node-govee-led) in Node-Red, not sure How to do this any advice.

Try to manually install, but nothing is visible in Node-RED.

thanks

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 January 2022 13:26 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/2 "2022-01-16T13:26:28Z")

</div>

As it is not a node-red node (just an NPM package) you wont see anything in node-red pallete.

If you are using node-red V2+ you can add it as an import on a function node...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1fcb463f18024d86e10be61e16ea664429850f28.png)

then use the code as described in the readme.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/65b887747fba987406c343a1996eeb13465f0a17.png)

---

<div class="post-metadata">

**Author:** ![m661](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@m661](https://discourse.nodered.org/u/m661)\
**Post date:** [16 January 2022 22:02 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/3 "2022-01-16T22:02:06Z")

</div>

Thanks for the info, I have implemented all the steps, as described, so far, it is returning a payload of Object Promise, led is not turning on or off. Not sure how to debug. Will do some more testing.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 January 2022 22:08 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/4 "2022-01-16T22:08:25Z")

</div>

It wasnt clear from the [readme](https://www.npmjs.com/package/node-govee-led) that `getState` returned a `promise`.

Instead try...

```auto
var Client = new Govee({
	apiKey: "<govee api key>",
	mac: "<MAC address>",
	model: "<device model>"
});

Client.getState()
  .then(state => {
    msg.payload = state;
    node.send(msg);
  })
  .catch(err => node.error(err, msg));

```

---

<div class="post-metadata">

**Author:** ![m661](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@m661](https://discourse.nodered.org/u/m661)\
**Post date:** [16 January 2022 22:15 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/5 "2022-01-16T22:15:25Z")

</div>

Ok, a bit better, getting

function : (error)  
"Error: Request failed with status code 400"

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 January 2022 22:19 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/6 "2022-01-16T22:19:39Z")

</div>

> [@m661](#):
>
> status code 400

# 400 Bad Request

The HyperText Transfer Protocol (HTTP) **`400 Bad Request`** response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).

Are your details correct?

My guess is you have something wrong.

what does this return...?

```auto
const Client = new Govee({
	apiKey: "<govee api key>",
	mac: "",
	model: ""
})

Client.getDevices()
  .then(data => {
    msg.payload = data;
    node.send(msg);
  })
  .catch(err => node.error(err, msg))

```

---

<div class="post-metadata">

**Author:** ![m661](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@m661](https://discourse.nodered.org/u/m661)\
**Post date:** [16 January 2022 22:27 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/7 "2022-01-16T22:27:22Z")

</div>

WOW, it is working, the mac address was wrong, I guess there is more than one mac address, in the app it is not showing up the same one. with your command getdevices, I was able to validate the mac.

thanks a lot.

Mario

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 January 2022 22:28 UTC](https://discourse.nodered.org/t/creating-custom-node-using-nodejs-repo-govee/56746/8 "2022-01-30T22:28:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
