logo elektroda
logo elektroda
X
logo elektroda

[Solved] Home Assistant integration with Mysensors on RPi 3 and Arduino Mega - missing all entities

klakier_2006 1095 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20845839
    klakier_2006
    Level 9  

    Welcome, perhaps someone has already encountered a problem like the one I am experiencing and can help me solve it.
    I have Home Assistant installed on an RPi 3 and to this connected an Arduino Mega via USB with a sketch for 28 relays uploaded. I am using the Mysensors libraries. Theoretically everything should integrate automatically when I add the Mysensors integration, point to the port etc. And up to a certain point it is ok. HA sees the arduino, only that there should be 28 entities (relays), and in fact there is only one entity, and a fake one at that (some battery indicator which is not mentioned in my sketch). The fact is that the relays did show up for me, but after a long time and it was on the basis of the individual entities "flowing" over a period of about 24 hours. However, they never "flowed" more than 21 units. In the logs I have the info: WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 0, cannot add child - and so on for each relay. I've used the same sketch and hardware before, only with Domoticz and it worked. What could be wrong?
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • Helpful post
    #2 20846096
    gulson
    System Administrator
    It looks like you have a child_id name conflict, each relay should have a unique child_id. Not sure how it is defined in the Arduino and not sure what the mysensors configuration is, for example:

    
    mysensors:
      gateways:
        - device: '/dev/ttyACM0' # Zastąp '/dev/ttyACM0' swoim portem
          persistence_file: 'path/to/your/persistence/file.json'
          baud_rate: 115200
      optimistic: false
      persistence: true
      version: '2.3' # Użyj wersji MySensors zgodnej ze swoją biblioteką
    


    It is also possible to dump the persisence file, dump everything home assistant and add again.
  • ADVERTISEMENT
  • #3 20846867
    klakier_2006
    Level 9  
    I'll honestly admit that I'm a total novice in this area so why don't I paste my arduino code here, and below also the mysensors file that generates the Home Assistant. If you could take a look at it and direct me more precisely I would be very grateful.
    Mega arduino code for 28 relays with buttons:
    Code: Arduino
    Log in, to see the code
    .
  • ADVERTISEMENT
  • Helpful post
    #4 20846881
    gulson
    System Administrator
    I'm not that familiar with the solution, but throwing your code into GPT4, it recognised that you have a double call to the present() function with the same child_id. Same thing in the for loop.
    Maybe remove the repeated call to present() and preferably look for another program.
  • ADVERTISEMENT
  • #5 20865431
    klakier_2006
    Level 9  

    Hello again, thanks for the suggestion. There was actually something wrong with my sketch. In the end, I looked for a completely new one and converted it to my needs and now it is ok. Thanks anyway. Best regards and topic closed.
  • #6 20865433
    klakier_2006
    Level 9  

    New sketch for Arduino under the latest MySensors libraries. It works!
ADVERTISEMENT