Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Home Assistant
  4. Delay processing messages

Delay processing messages

Scheduled Pinned Locked Moved Home Assistant
9 Posts 2 Posters 2.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • abmantisA Offline
    abmantisA Offline
    abmantis
    wrote on last edited by
    #1

    Sometimes I notice that there is some delay in Home Assistant processing or receiving MySensors messages.
    For example, I have a node with two switches. I press switch A and right after switch B. Looking at the debug logs from HA's MySensors component, switch B state is updated about a second after switch A.

    I have never noticed this delay when using Pimatic instead of HA.

    1 Reply Last reply
    0
    • martinhjelmareM Offline
      martinhjelmareM Offline
      martinhjelmare
      Plugin Developer
      wrote on last edited by
      #2

      Are you using a serial gateway? There's a timeout on the serial read operation of 1 second, which might explain your observed behavior. It might be possible to make this more efficient.

      abmantisA 2 Replies Last reply
      0
      • martinhjelmareM martinhjelmare

        Are you using a serial gateway? There's a timeout on the serial read operation of 1 second, which might explain your observed behavior. It might be possible to make this more efficient.

        abmantisA Offline
        abmantisA Offline
        abmantis
        wrote on last edited by
        #3

        @martinhjelmare yes, I'm using the serial gateway. It should be possible to make it better, since I had no issues with the same gateway on Pimatic. I'll try to have a look at the code and let you know if I also find anything

        1 Reply Last reply
        0
        • martinhjelmareM martinhjelmare

          Are you using a serial gateway? There's a timeout on the serial read operation of 1 second, which might explain your observed behavior. It might be possible to make this more efficient.

          abmantisA Offline
          abmantisA Offline
          abmantis
          wrote on last edited by abmantis
          #4

          @martinhjelmare have you found anything? I've had a quick look at the code and found nothing relevant. The 1 second timeout you're referring to is just a connection timeout, right? It shouldn't affect communication after connecting I guess.
          I'll try to add some debug prints to see if I find anything.

          1 Reply Last reply
          0
          • martinhjelmareM Offline
            martinhjelmareM Offline
            martinhjelmare
            Plugin Developer
            wrote on last edited by
            #5

            No the timeout is for the readline operation. It will read for 1 sec or until a newline character is received. I'm not sure why that would "block" for 1 second between two messages that are sent closer than 1 second. But it's my only explanation at this point. I have an idea for changing the reading from the serial port, making it non blocking without timeout, by checking if there's data available in the read buffer before reading. But I don't have time right now to code that up and test it. I'll probably have time during Christmas. If you want to make a PR before that, you're welcome and I'll review it.

            abmantisA 1 Reply Last reply
            0
            • abmantisA Offline
              abmantisA Offline
              abmantis
              wrote on last edited by
              #6

              Thanks. I've been debugging it, and it seems that sometimes "self.handle_queue()" in run() takes one or two seconds. It is not very frequent, but it seems to be the cause of my issues.
              Also, my node is sending the message twice sometimes (I have yet to check why), and that increases the time also.

              1 Reply Last reply
              0
              • martinhjelmareM martinhjelmare

                No the timeout is for the readline operation. It will read for 1 sec or until a newline character is received. I'm not sure why that would "block" for 1 second between two messages that are sent closer than 1 second. But it's my only explanation at this point. I have an idea for changing the reading from the serial port, making it non blocking without timeout, by checking if there's data available in the read buffer before reading. But I don't have time right now to code that up and test it. I'll probably have time during Christmas. If you want to make a PR before that, you're welcome and I'll review it.

                abmantisA Offline
                abmantisA Offline
                abmantis
                wrote on last edited by
                #7

                @martinhjelmare Have you looked into this? I've been noticing delays very frequently :/
                I don't have those delays with other components, and also had not had them when using Pimatic instead of HA.

                1 Reply Last reply
                0
                • martinhjelmareM Offline
                  martinhjelmareM Offline
                  martinhjelmare
                  Plugin Developer
                  wrote on last edited by martinhjelmare
                  #8

                  I did some debugging for another issue:
                  https://github.com/home-assistant/home-assistant/issues/5163
                  But I wasn't able to find anything wrong at that time on the home assistant / pymysensors side.

                  I could see that the serial read operation was not blocking when there were incoming messages. So the full timeout of 1 second only came into play if there were not any messages to read.

                  Pymysensors also responded with a send "immediately" (~1 ms) after receiving a request for time in my testing.

                  Please post debug logs and version of home assistant and anything else that might be useful. It would be interesting if you can test to use only pymysensors without home assistant and see if you still notice delays.

                  I'm not saying there's no problem, but I've just not been able to pinpoint it yet. If you have a test case, that I can replicate, that would be good.

                  abmantisA 1 Reply Last reply
                  0
                  • martinhjelmareM martinhjelmare

                    I did some debugging for another issue:
                    https://github.com/home-assistant/home-assistant/issues/5163
                    But I wasn't able to find anything wrong at that time on the home assistant / pymysensors side.

                    I could see that the serial read operation was not blocking when there were incoming messages. So the full timeout of 1 second only came into play if there were not any messages to read.

                    Pymysensors also responded with a send "immediately" (~1 ms) after receiving a request for time in my testing.

                    Please post debug logs and version of home assistant and anything else that might be useful. It would be interesting if you can test to use only pymysensors without home assistant and see if you still notice delays.

                    I'm not saying there's no problem, but I've just not been able to pinpoint it yet. If you have a test case, that I can replicate, that would be good.

                    abmantisA Offline
                    abmantisA Offline
                    abmantis
                    wrote on last edited by
                    #9

                    @martinhjelmare No problem, I'll try to get some more data. Regarding HA version, I'm always on the latest version (with one or two days delay).

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    16

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.1k

                    Posts


                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • MySensors
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular