Well, it was worth a try.
We might not have solved the entire problem, but I learned a new trick for my Node-Red fu, so I am happy.
Thank you
My findings:
Rest API creates only read-only entities/states without unique id. Therefore it can’t be used in dashboards to enter / change data.
The entity node can only create switches but with predefined names and not number or select entities.
For me these findings are for the moment very disappointing.
Compared to ioBroker which I use for the moment this is going more then 10 years back.
KO Criteria for HA if I do not find a solution !
You can do it with NR but you’ll need to create the API calls yourself. https://community.home-assistant.io/t/help-merging-2-node-red-flows-in-1/154642/23
mqtt discovery can also work for you.
We already got the sensor up and running with NR, but it seems the poster would like a switch and that I could not figure out to make.
But I found a link to another post from you.
This pallet have been mentioned here, but it looked like the name could not be set dynamically.
In this thread there seems to be a solution to that.
How do you create them dynamically?
it’s an ha template, I’d assume how you would insert a variable in an automation template. It can also execute python scripts if the template can’t be incorporated into the command.
Thanks for your input. I would like to test but I do have still 2 questions:
- Would your solution work for input entities (switch, number, select) as well - or just for sensors?
- What do I need to install for testing?
(2) It looks like I have installed everything … so just node-red companion needed.
My findings so far for websocket usage:
-
I can create sensors and switches and both are getting an id.
-
I can update values of both by node-red flow
-
Update switch from dashboard will deactivate the entity - so not working
-
Select or Number entities are not shown in ha even if they seem to get an id. So they can’t be used
I’m still not sure why you need to all this work.
Can’t these devices be integrated in Home Assistant via normal integrations?
Yes I could try to write my own integration. I am using HA now for approx. 1 week to evaluate if I should move from ioBroker to ha.
Since I do have a lot of JS written code, I could easily adapt this to node-red. The only part I am missing is to create the entities from NR/JS. I do understand the two phases: first register / then assign state value. (will be 130-150 entities for my device)
I am not an IT guy - just retired with some time to learn and test. I tried to understand how to build an integration for ha, but compared to ioBroker it seems to be quite complex or I am too stupid to understand. (and learning YAML and Python would be other tasks for me …)
Ok… But I still don’t understand all these switches and sensors you are creating. What are they linked to?
Is it physical devices? is it just virtual?
I don’t think anyone using HA has that many node red created entities. Perhaps there is something you don’t know about Home Assistant and you are using what you know from ioBroker, and that is perhaps not the best method?
I believe this is a xy problem and because you have not given us any background all we can do is help you with the generic answers to the generic questions.
Take a step (or two) back and explain what this is and how it is linked to something.
I want to integrate my heating system into ha. The existing integration does not work for me and since I have written the respective ioBroker adapter I do have the right js-coding and the polling part works already fine in ha and node-red. I tried so far to understand the ha possibilities for integrations of devices if no existing and working integration is available:
- NR with Rest-API / Websockets do not seem to work.
- MQTT discovery I do not really want to use to create the entities
- I could create the respective yaml-file with a node-red flow to define the entities and include this one into configuration.yaml
- … or I start to write my own integration
I need to decide, but if there is no other solution, I rather prefer the creation of yaml-files as a start.