# Help on how to use register device on Node-Red

**URL:** https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408
**Category:** eWeLink CUBE
**Tags:** advanced-plan
**Created:** [April 11, 2023, 9:06pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408 "2023-04-11T21:06:55Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [April 11, 2023, 9:06pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/1 "2023-04-11T21:06:56Z")

</div>

I am testing out the Node-Red integration with iHost. Especially now working on the register device node.

So far I managed to create a few device, I can figure out the Category and the Capabilities.

I also understood that we can use the tags to set for example the default state for a switch, or the unit of measure of a temp sensor. But is it documented anywhere where are the different options for tags? Especially if I have a device with multiple capabilities? How can I enter the tags in that case? for example if I have a device with Toggle and Temperature capability as well?

And the question is the same for state. Where is it document what can I enter for the state?

And probably the next question, for example if I have create a sensor, or a button, how can I send in update? I assume I can send in a message with a special payload. I tried `{ "temperature": 20 }`, `{ "state": {"temperature": 20 } }`, `{ "status": {"temperature": 20 } }`, `{ "temperature": {"temperature": 20 } }` but none of them works.

Also if I create a switch, light device can I toggle it using the register device node, or I should use the control device node?

Regards,  
Csongor

---

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [April 17, 2023, 11:24am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/2 "2023-04-17T11:24:39Z")

</div>

Also, related to the above question, when I tried to use the same node on NSPanel Pro, I just get an invalid paramter error message. The same settings that worked on iHost.

---

<div class="post-metadata">

### Author: ![dr.m.i.bell](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@dr.m.i.bell](https://forum.ewelink.cc/u/dr.m.i.bell)
#### Post date: [April 17, 2023, 1:44pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/3 "2023-04-17T13:44:17Z")

</div>

> [@csongor.varga](#):
>
> I am testing out the Node-Red integration with iHost.

I just received my iHost and will not be able to play with it for a few days, so I am keen to follow your progress. My approach would be to start with the published [API](https://sonoff.tech/ihost-open-api/) and look at the source code for each node to find out which API call(s) it implements. That could answer a lot of your questions.

---

<div class="post-metadata">

### Author: ![Alexie](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/alexie/32/1593_2.png) [@Alexie](https://forum.ewelink.cc/u/Alexie)
#### Post date: [April 18, 2023, 3:42am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/4 "2023-04-18T03:42:47Z")

</div>

At present, I do not know how to use this node correctly…

I think there will be some tutorials of how to use registered nodes published this week or next week

---

<div class="post-metadata">

### Author: ![Teki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/teki/32/1161_2.png) [@Teki](https://forum.ewelink.cc/u/Teki)
#### Post date: [August 4, 2023, 7:09am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/5 "2023-08-04T07:09:58Z")

</div>

here’s a video about the register-device:

[![](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/1/1a42c51e1394ad2f3f57790091e154898ea12cd1.jpeg "SONOFF iHost: Virtual Device Tutorial") ](https://www.youtube.com/watch?v=SK4EtCqhWY8)

---

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [August 4, 2023, 9:56pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/6 "2023-08-04T21:56:58Z")

</div>

Thanks @Teki this was useful. Where it is documented what can we use in the Tag and the State fields?  
For a switch, I understand that I can use the Tags to define the initial state. I can use the tags to define if a temperature sensor is using C or F, or for a multi gang switch what the names of the individual channels are. But anything else? Is this documented anywhere?

---

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [October 3, 2023, 9:54pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/7 "2023-10-03T21:54:46Z")

</div>

Hi @Teki, I can see that 1.1.0 version of the cube nodes are available now. Can you tell me if it is possible now to send data to sensors that I created from node-red?  
I am referring to a scenario where I create a temperature sensor using the register-device node (which I could do already), but I don’t know how to update its value from Node-Red.  
Is that now fixed in version 1.1.0?

---

<div class="post-metadata">

### Author: ![aerograf](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@aerograf](https://forum.ewelink.cc/u/aerograf)
#### Post date: [October 9, 2023, 7:52am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/8 "2023-10-09T07:52:10Z")

</div>

Hi csongor.varga

> [@Node-RED control-device node throw an error](https://forum.ewelink.cc/t/node-red-control-device-node-throw-an-error/22019/36):
>
> An example of the state of a real device being synchronized to a virtual device display: After running, if you operate the real device, its switch and brightness data will be automatically synchronized to the virtual device for display: By defining a virtual device and associating it with a real device, you can create a device with multiple capabilities in iHost, such as simultaneous switch, brightness, color temperature, temperature, humidity, and fan cap…

---

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [October 9, 2023, 9:24am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/9 "2023-10-09T09:24:05Z")

</div>

@aerograf Yes, this is good and I can also use the control-device node to use it. But I was specifically looking for sensors.  
I creates a “Test Sensor” which has temperature and humidity. But no matter what I send in, it is not getting processed by the put-device-state node:

```auto
[{"id":"9c242d75faa4c99d","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":700,"wires":[["72fad3b5e82dcbd4"]]},{"id":"72fad3b5e82dcbd4","type":"register-device","z":"f6f2187d.f17ca8","name":"Test Sensor","server":"3bd64653f454c56c","device_id":"5db53c3e-2fe4-11ee-be56-0242ac120002","device_name":"Test Sensor","category":"temperatureAndHumiditySensor","capabilities":"{\"toggleNum\":\"1\",\"values\":[\"temperature\",\"humidity\"]}","manufacturer":"NodeRed","model":"C5","firmware_version":"1.0.0","service_address":"192.168.1.109","tags":"{\"temperature_unit\":\"c\"}","state":"{}","x":310,"y":700,"wires":[[]]},{"id":"92f6db876e6b6dcc","type":"inject","z":"f6f2187d.f17ca8","name":"Temperature test","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"temperature\":{\"temperature\":22}}","payloadType":"json","x":540,"y":700,"wires":[["2e34f9b99ae92df5"]]},{"id":"3225afd7247705df","type":"debug","z":"f6f2187d.f17ca8","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":700,"wires":[]},{"id":"2e34f9b99ae92df5","type":"put-device-state","z":"f6f2187d.f17ca8","name":"Fixed temp","server":"3bd64653f454c56c","category":"temperatureAndHumiditySensor","device":"f1b018d1-591f-4af7-ba9c-c551fef052ae","state":"{\"temperature\":{\"temperature\":20}}","number":"5db53c3e-2fe4-11ee-be56-0242ac120002","x":730,"y":700,"wires":[["3225afd7247705df"]]},{"id":"165de480f690ca3c","type":"inject","z":"f6f2187d.f17ca8","name":"Humidity test","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"humidity\":{\"humidity\":35}}","payloadType":"json","x":530,"y":760,"wires":[["2e34f9b99ae92df5"]]},{"id":"d4267dd7deea0e7e","type":"inject","z":"f6f2187d.f17ca8","name":"Both test","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"humidity\":{\"humidity\":45},\"temperature\":{\"temperature\":13}}","payloadType":"json","x":520,"y":800,"wires":[["2e34f9b99ae92df5"]]},{"id":"3bd64653f454c56c","type":"api-server","name":"iHost","ip":" 192.168.1.109","token":"c63f92a1-ba08-4084-88bf-2a39a77e68f4"}]

```

If you check my code, I tried the same approach as you. I send the `payload.payload` par of when I can read from the event-state node. But in this case no matter if I send `{"temperature":{"temperature":22}}` or `{"humidity":{"humidity":35}}` or `{"humidity":{"humidity":45},"temperature":{"temperature":13}}` the device is not updated on the iHost.

---

<div class="post-metadata">

### Author: ![aerograf](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@aerograf](https://forum.ewelink.cc/u/aerograf)
#### Post date: [October 9, 2023, 9:29am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/10 "2023-10-09T09:29:06Z")

</div>

This definitely works!

> [@Node-RED control-device node throw an error](https://forum.ewelink.cc/t/node-red-control-device-node-throw-an-error/22019/37):
>
> Hi, aerograf. For sync your temp and hum sensor data to a virtual device. Use a register-device node to register a virtual device. Here are some initial state Use a event-state to monitor a real temp and hum sensor data. Use a function node to receive and transfer the data. Use a put-device-state node to recevie the data and sync to iHost. Then you can see your real data are syn…

---

<div class="post-metadata">

### Author: ![songal](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@songal](https://forum.ewelink.cc/u/songal)
#### Post date: [October 11, 2023, 3:07am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/11 "2023-10-11T03:07:19Z")

</div>

@csongor.varga  
Note that the put-device-state node can only receive JSON data types, and the keys and values of the data must match the capabilities of the virtual device, as specified in the device type in the [developer documentation](https://ewelink.cc/ewelink-cube/introduce-open-api/document/)

 ![图片](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/0/00d928535c0d093accedbf339c03aca1348daba8.png)  
 ![图片](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/7/7179c5bda049ced57a8cca2b7a43bdbabacce966.png)  
 ![图片](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/7/77cb5f8a377b8771d91dd21f57e1284114383816.png)  
 ![图片](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/4/49fd8ce13e66a5345ef4f0b09afb8ba533c5cd3c.jpeg)

---

<div class="post-metadata">

### Author: ![vico3341](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@vico3341](https://forum.ewelink.cc/u/vico3341)
#### Post date: [October 21, 2023, 5:19pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/12 "2023-10-21T17:19:42Z")

</div>

sorry for the stupid question, but how do you create a virtual device in ihost?

---

<div class="post-metadata">

### Author: ![vico3341](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@vico3341](https://forum.ewelink.cc/u/vico3341)
#### Post date: [October 21, 2023, 8:59pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/13 "2023-10-21T20:59:29Z")

</div>

after some time I found the virtual device among my devices in ihost and I can also see the virtual device in Alexa thanks to the matter connection between them.

---

<div class="post-metadata">

### Author: ![songal](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@songal](https://forum.ewelink.cc/u/songal)
#### Post date: [October 23, 2023, 3:02am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/14 "2023-10-23T03:02:58Z")

</div>

Virtual devices can be registered through the “register-device” node.

 ![图片](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/e/e153dee25ba014639c133a76c4909e6d6314bc74.png)

---

<div class="post-metadata">

### Author: ![psavie](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@psavie](https://forum.ewelink.cc/u/psavie)
#### Post date: [December 2, 2023, 11:50am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/15 "2023-12-02T11:50:55Z")

</div>

@Teki , @songal , @csongor.varga , does register device still work for you on CUBE V1.12.0 ? It has stopped working for me since I upgraded from V1.11.1. I’ve recreated a new flow, with new GUID but can’t resolve it.

---

<div class="post-metadata">

### Author: ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)
#### Post date: [December 2, 2023, 4:03pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/16 "2023-12-02T16:03:17Z")

</div>

I haven’t tried this but if you create a virtual device does it persist after node Red restarts?

I haven’t yet had a reason to create one when simple flow and global variables which can be stored in file do everything I need. I guess it is so you can copy whole device settings in one go rather than split them into variables?

The other eWeLink node I’ve never used is the event on-line one. An event off-line would be more useful. I could use event on-line in my error in device operating catching flows I suppose. At present I just catch the error and retry a few times after a bit.

---

<div class="post-metadata">

### Author: ![songal](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@songal](https://forum.ewelink.cc/u/songal)
#### Post date: [December 4, 2023, 4:00am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/17 "2023-12-04T04:00:23Z")

</div>

> [@eerke](#):
>
> I haven’t tried this but if you create a virtual device does it persist after node Red restarts?

yes, they will still be there.

---

<div class="post-metadata">

### Author: ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)
#### Post date: [December 4, 2023, 7:04pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/18 "2023-12-04T19:04:15Z")

</div>

And will it still be in the same state, like ON etc. thanks, Eerke

---

<div class="post-metadata">

### Author: ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)
#### Post date: [December 4, 2023, 7:26pm UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/19 "2023-12-04T19:26:19Z")

</div>

Sorry, I only upgraded to 1.12 now, and so far everything looks OK. My virtual sensors are still working, I can update them, they are appearing online.

---

<div class="post-metadata">

### Author: ![songal](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@songal](https://forum.ewelink.cc/u/songal)
#### Post date: [December 5, 2023, 1:36am UTC](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408/20 "2023-12-05T01:36:58Z")

</div>

> [@eerke](#):
>
> And will it still be in the same state, like ON etc.

Yes, it’s device state is persistently stored.

[Next page](https://forum.ewelink.cc/t/help-on-how-to-use-register-device-on-node-red/16408.md?page=2)
