Help on how to use register device on Node-Red

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

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.

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 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.

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

here’s a video about the register-device:

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?

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?

1 Like

Hi csongor.varga

@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:

[{"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.

This definitely works!

@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




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

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.

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

@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.

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.

yes, they will still be there.

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

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.

Yes, it’s device state is persistently stored.