Enable serial debugs from the RS485 GW in the log



  • Hi!

    Pardon my ignorance but I was not able to achieve this. How do I see what's happening on the /dev/ttyUSB0 console when pymysensors is using it? Should I enable something specifically in the logger component?

    Right now I am using the following setting:

    logger:
      default: warn
      logs:
        homeassistant.components.mysensors: info
    

    thanks.


  • Plugin Developer

    @Bart

    Try this:

    logger:
      default: warning
      logs:
        homeassistant.components.mysensors: debug
        mysensors.mysensors: debug
    
    mysensors:
      debug: true
    ... 
    


  • @martinhjelmare said:

    mysensors.mysensors

    Ah, so in a nutshell I could easily change logging level for any Python lib that is using logger lib? Is that one for pymysensors lib?


  • Plugin Developer

    Yes, you can set a filter on any child of the root logger in home assistant. The convention is that each module has it's own logger, which will be a child of the root logger. Yes, the first name in mysensors.mysensors is the package installed by pymysensors and the last name (mysensors.mysensors) is the module name.



  • Hm, strange but I do not see any mysensors messages shown in the log. I am seeing:

    16-09-20 22:05:29 DEBUG (Thread-2) [homeassistant.components.mysensors] InputBinary1 1 69: value_type 2, value = 0
    

    and

    16-09-20 22:40:45 INFO (Thread-2) [mysensors.mysensors] Disconnecting from /dev/ttyACM0
    

    but how to observe what is being sent out on the console line?


  • Plugin Developer

    Did you set debug to true in the configuration for mysensors component?



  • @martinhjelmare yup it is set to true.


  • Plugin Developer

    Have you tested that you get the expected serial output from the gateway by connecting a serial monitor while having home assistant not connected?



  • @martinhjelmare Yes. It actually works for the switches. I have some issues with getting the lights being shown correctly (although sending the initial values, but that's off topic 🙂 ).

    EDIT: to be sure I've copy/pasted these sections from your post. I see mysensors.mysensors debugs and the component debugs. Just no console print outs.

    EDIT2: I need to double check it - not sure IF I am seeing any mysensors.mysensors debugs. Will do that in the evening today.


  • Plugin Developer

    Please post the serial log from the gateway and the debug log from home assistant. It will be from two different runs but that is OK. If you can post a parallel serial log from a node that would be great.



  • @martinhjelmare Thanks for the suggestions.



  • @martinhjelmare So unfortunately haven't had much time to spend on getting these logs yet. But one thing is sure. The domoticz mysensors connection works flawlessly. I am able to see all the sensors, all of them are correctly updated in the domoticz on sketch start up, no events are lost (did same test doing quickly switch toggling from the GUI and from the sketch, same tests on HA were often missing the events). So there's got to be some problem with HA module.

    So the bottom line - logs are needed 🙂

    So do I understand correctly that with the above logs setting I should be able to see the serial transmissions in the HA log? I will try to obtain the serial port data with something like this: http://unix.stackexchange.com/questions/12359/how-can-i-monitor-serial-port-traffic but it would be ideal to figure out why these debugs are not there in the first place. Can I make some changes to the module and force the debug (in the python source file)?


  • Plugin Developer

    I haven't tested the RS485 gateway so I can't say how much it prints to serial. I know that the regular serial gateway prints received messages to serial. The ethernet based gateways will not do this of course.

    It's up to the controller how it implements the mysensors API, so each controller can have different requirements. You can't be sure that your setup works for all controllers just because it works for one. You could be experiencing a bug in home assistant or pymysensors, but it's hard to tell without further information. When we see the logs we will know more.

    Edit:
    Can't you use Arduino IDE and its serial monitor? First make a run without home assistant. Monitor both gateway and node at the same time with two IDE instances.

    Then disconnect IDE from gateway and connect home assistant instead and do a second run.



  • There's no difference between Serial GW and Serial GW with RS485 transport. It is just a matter of not using RF transport. So on the serial console side the communication is the same.



  • Just a FYI if anyone else will stuck trying to enable this. There's no debug print out for the serial connection in pymysensors as it appears. You need to add the debugs in the code on your own.

    Here's the diff:

    --- mysensors/mysensors.py.orig	2016-11-19 17:51:39.000000000 +0100
    +++ mysensors/mysensors.py	2016-11-19 18:27:43.705631204 +0100
    @@ -483,6 +483,7 @@
                         'Error decoding message from gateway, '
                         'probably received bad byte.')
                     continue
    +            _LOGGER.debug('Received %s', string.rstrip())
                 self.fill_queue(self.logic, (string,))
             self.disconnect()  # Disconnect after stop event is set
     
    @@ -492,6 +493,7 @@
                 return
             # Lock to make sure only one thread writes at a time to serial port.
             with self.lock:
    +            _LOGGER.debug('Sending %s', message.rstrip())
                 self.serial.write(message.encode())
     
     
    

  • Plugin Developer

    @Bart

    If you make a pull request we can add this to the upstream repo.



  • @martinhjelmare thanks. I am still not really good at git kung-fu to do it quickly. will try to do the PR when I have some spare time 🙂


Log in to reply
 

Suggested Topics

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts