Mysensors: cannot add child?

I keep getting these error messages in the log file when I start one specific sensor:

child_id 1 already exists in children of node 227, cannot add child

This is an energy meter sensor, using the default sketch from the Mysensors libraries. The sensor works as expected (e.g it shows up in HA and shows values for kWh and W), but everytime it starts I get the above message. Do I need to worry about it?

Here’s the serial log from the sensor:

0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
4 TSM:INIT
4 TSF:WUR:MS=0
12 TSM:INIT:TSP OK
14 TSF:SID:OK,ID=227
16 TSM:FPAR
53 TSF:MSG:SEND,227-227-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2060 !TSM:FPAR:NO REPLY
2062 TSM:FPAR
2099 TSF:MSG:SEND,227-227-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2666 TSF:MSG:READ,0-0-227,s=255,c=3,t=8,pt=1,l=1,sg=0:0
2672 TSF:MSG:FPAR OK,ID=0,D=1
4108 TSM:FPAR:OK
4108 TSM:ID
4110 TSM:ID:OK
4112 TSM:UPL
4118 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
4233 TSF:MSG:READ,0-0-227,s=255,c=3,t=25,pt=1,l=1,sg=0:1
4239 TSF:MSG:PONG RECV,HP=1
4241 TSM:UPL:OK
4243 TSM:READY:ID=227,PAR=0,DIS=1
4249 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
4390 TSF:MSG:READ,0-0-227,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
4399 TSF:MSG:SEND,227-227-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
4409 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4888 TSF:MSG:READ,0-0-227,s=255,c=3,t=6,pt=0,l=1,sg=0:M
4896 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Energy Meter
4909 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
4919 TSF:MSG:SEND,227-227-0-0,s=1,c=0,t=13,pt=0,l=0,sg=0,ft=0,st=OK:
4925 MCO:REG:REQ
4964 !TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
6973 TSF:MSG:SEND,227-227-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
7049 TSF:MSG:READ,0-0-227,s=255,c=3,t=27,pt=1,l=1,sg=0:1
7055 MCO:PIM:NODE REG=1
7057 MCO:BGN:STP
7061 TSF:MSG:SEND,227-227-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
7067 MCO:BGN:INIT OK,TSP=1
7360 TSF:MSG:READ,0-0-227,s=1,c=1,t=24,pt=0,l=2,sg=0:79
Received last pulse count from gw:79

And here’s the mosquitto_sub output when starting the sensor:

mysensors-out/227/255/0/0/17 2.1.1
mysensors-out/227/255/3/0/6 0
mysensors-in/227/255/3/0/6 M
mysensors-out/227/255/3/0/11 Energy Meter
mysensors-out/227/255/3/0/12 1.0
mysensors-out/227/1/0/0/13 (null)
mysensors-out/227/1/2/0/24 (null)
mysensors-in/227/1/1/0/24 79

i always get that error when i restart any of my already known sensors.
i dont worry about the error, but it shouldnt be there :wink:

If using persistence existing children will be added when starting home assistant. So restarting a node will generate this warning log message. Even without persistence, restarting a node when its children are already added to home assistant will generate the warning.

You don’t need to worry about it as long as you haven’t changed the child type and want to add the new child type to home assistant.

@martinhjelmare can that warning be changed in future version to something more understandable like:

  • child_id 1 from node 227 has represented itself, didnt add anything to persistance file.

I don’t think it needs to change. Your example is not really true either, sorry.

Better to document this warning and the data structure. If you understand the data structure, the log message is very clear in my opinion. But the data structure is not documented in home assistant, only at pymysensors.

We should have a section on the data structure and log messages in home assistant mysensors section.

then i probably dont understand the datastructure and would welcome a section like that :wink:

Yes, the data structure and rules around that are not clear for the users and we should document those and log messages.

Everyone is welcome to submit pull requests for both the documentation and source code. I’ll review and make suggestions for changes. If I have time I’ll update the docs, but I have a long todo list for mysensors so I welcome all help.

Thanks for pointing out that this message needs explaining better.

i would love to help but its hard to document things i dont know anything about :wink:

@ReneTode I understand what you mean, although I think you know a lot about home assistant and mysensors. If you do want to help with the documentation, I will try to help and fill in any gaps while reviewing the PR.

PRs usually are processes and discussions. They don’t have to be correct from the beginning. Most often they are not. That’s true for both beginners and experienced contributors. And correct is subjective and up for discussion.

a lot is also subjective :wink:
but we were talking about the datastructure and the rules around that, and for me its clear that i certainly dont know a lot about that :wink:

if there is anything else i can take off your to do list in an area i know something about (to help you get to that part) i gladly help.
you could also give me pointers to find out all there is to find out about the datastructure and the rules around that, and i can see if i can gather enough knowledge to provide documentation.

The readme at pymysensors explains the data structure:

One rule that is not mentioned is that it’s not possible to dynamically replace nodes or children that already have been added in memory. One have to restart home assistant and re-populate the dictionaries that store the nodes and children. I intentionally made this change to avoid overwriting children or mixing old stale data with new data, by mistake. Downside of this is that it’s not so easy to replace a node or child id. If using JSON persistence one can edit the persistence file and remove the old node or child, and then restart home assistant and start your node with a fresh sketch.

A child can be added into the children dict either after receiving a presentation message or via loading data from a persistence file.

i will read up on that but i just took a look on how to submit changes to the docs.
small edits i can see myself doing.

but creating bigger part for sure not.
to see how it would look i would need to create a local working version from the home assistant website.
at least that is said here https://home-assistant.io/developers/website/

i dont even want to start thinking about the problems and questions i would have trying that on a windows 10 PC without Linux.

if there is a way that i just can download - edit - upload a docfile with a windows editor and create new files and then upload with a windows editor it would be something i would like to do.

if it would help you i could also write plain text docs and PM them to you.

i must really say that everything on github is still confusing me.

on the page they say:

You can use the “Edit this page on GitHub” link to edit pages without creating a fork. Keep in mind that you can’t upload images while working this way.

and then all i can find is a link which says:

edit the file in your fork of this project

i think i will download and install github desktop in the hope things get easier and clearer.

This is a nice guide for small edits on the docs via github:

Some editors have local preview of markdown text, although everything doesn’t always render exactly like it will online. But it helps I think. I’m using atom editor. I’m sure there are more that have this feature. Of course, I always double check with jekyll preview locally too, but this requires ruby.

that already shows what i suspected, there is a failure in the first part from the doc about how to change the docs :stuck_out_tongue:
it says “without creating a fork” and if you click on the edit button a fork will automaticly be created :wink:

i downloaded atom and github desktop.
lets see if i can get used to the github workflow :wink:

That explains why an additional sensor on an existing node didn’t show up when I added it (e.g I added one more presentation call in the startup of the sketch). HA had already loaded the config for that node from the persistance file.

As long as child ids don’t clash, you should be able to add more children to an existing node.

Any news in this thread ? Is any chance to go out this warning ?

We could change it to debug level if users think it’s just an annoyance.

i changed to using mqtt and connect mysensors directly to appdaemon. so i got no problem with it anymore :wink: