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. General Discussion
  3. Expected reply from Controller if requesting a variable that does not exist?

Expected reply from Controller if requesting a variable that does not exist?

Scheduled Pinned Locked Moved General Discussion
6 Posts 2 Posters 1.5k 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.
  • E Offline
    E Offline
    Erik Forsberg
    wrote on last edited by
    #1

    I recently built a Pulse Powermeter Sensor and after wiring it up I realized that to start reporting data, it wants the pulse count from the controller. This creates a bit of a chicken/egg situation, as before the sensor has reported its first pulse count, there's no pulse count to report :-)

    So, is there a documented default value the controller should report whenever it gets a request for a variable that does not exist? Or should it simply not reply in this case?

    My controller, Home Assistant, returns nothing - but I think that's partly because the pymysensors library used underneath seems to lack support for returning values to the sensors.

    So how should this work from the controller's point of view?

    martinhjelmareM 3 Replies Last reply
    0
    • E Erik Forsberg

      I recently built a Pulse Powermeter Sensor and after wiring it up I realized that to start reporting data, it wants the pulse count from the controller. This creates a bit of a chicken/egg situation, as before the sensor has reported its first pulse count, there's no pulse count to report :-)

      So, is there a documented default value the controller should report whenever it gets a request for a variable that does not exist? Or should it simply not reply in this case?

      My controller, Home Assistant, returns nothing - but I think that's partly because the pymysensors library used underneath seems to lack support for returning values to the sensors.

      So how should this work from the controller's point of view?

      martinhjelmareM Offline
      martinhjelmareM Offline
      martinhjelmare
      Plugin Developer
      wrote on last edited by
      #2

      @Erik-Forsberg

      Regarding pymysensors, yes it doesn't support req message type yet. I'm working on that. Just needs some more testing before I can submit it.

      1 Reply Last reply
      0
      • E Erik Forsberg

        I recently built a Pulse Powermeter Sensor and after wiring it up I realized that to start reporting data, it wants the pulse count from the controller. This creates a bit of a chicken/egg situation, as before the sensor has reported its first pulse count, there's no pulse count to report :-)

        So, is there a documented default value the controller should report whenever it gets a request for a variable that does not exist? Or should it simply not reply in this case?

        My controller, Home Assistant, returns nothing - but I think that's partly because the pymysensors library used underneath seems to lack support for returning values to the sensors.

        So how should this work from the controller's point of view?

        martinhjelmareM Offline
        martinhjelmareM Offline
        martinhjelmare
        Plugin Developer
        wrote on last edited by martinhjelmare
        #3

        @Erik-Forsberg

        Regarding home assistant, I think you can solve this with an automation rule and a custom script that uses the home assistant API, python or REST, to set the state of the powermeter (pulse count) in home assistant.

        For example, you send a value of 0 from the power meter, as long as no other value is coming from the controller. When the controller detects the value 0 from the powermeter, it fires the script, that sets the new pulse count of the powermeter in home assistant. Then the powermeter requests the value from the controller and will get the updated pulse count. Make sure you do the request before doing the send from the powermeter sensor.

        1 Reply Last reply
        0
        • E Erik Forsberg

          I recently built a Pulse Powermeter Sensor and after wiring it up I realized that to start reporting data, it wants the pulse count from the controller. This creates a bit of a chicken/egg situation, as before the sensor has reported its first pulse count, there's no pulse count to report :-)

          So, is there a documented default value the controller should report whenever it gets a request for a variable that does not exist? Or should it simply not reply in this case?

          My controller, Home Assistant, returns nothing - but I think that's partly because the pymysensors library used underneath seems to lack support for returning values to the sensors.

          So how should this work from the controller's point of view?

          martinhjelmareM Offline
          martinhjelmareM Offline
          martinhjelmare
          Plugin Developer
          wrote on last edited by
          #4

          @Erik-Forsberg

          Regarding what the controller should reply when a device requests a value for a variable that doesn't exist, I think it shouldn't reply anything. I think it's the device that should initiate communication and setup and communicate the variables it will handle to the controller. The device should not ask the controller for a variable value that doesn't exist. If it does, the controller should just disregard that.

          That's my view, but I'd be interested in hearing others.

          E 1 Reply Last reply
          0
          • martinhjelmareM martinhjelmare

            @Erik-Forsberg

            Regarding what the controller should reply when a device requests a value for a variable that doesn't exist, I think it shouldn't reply anything. I think it's the device that should initiate communication and setup and communicate the variables it will handle to the controller. The device should not ask the controller for a variable value that doesn't exist. If it does, the controller should just disregard that.

            That's my view, but I'd be interested in hearing others.

            E Offline
            E Offline
            Erik Forsberg
            wrote on last edited by
            #5

            @martinhjelmare

            I tend to agree with that. In the case of the Power Meter, it should instead detect that it has never before booted and adapt to that.

            I'm glad to hear you're working on req message type. I, ehm, did that too: https://github.com/theolind/pymysensors/pull/22 :-)

            Your implementation is probably better since this is my first visit to this codebase, so feel free to reject the pull.

            martinhjelmareM 1 Reply Last reply
            0
            • E Erik Forsberg

              @martinhjelmare

              I tend to agree with that. In the case of the Power Meter, it should instead detect that it has never before booted and adapt to that.

              I'm glad to hear you're working on req message type. I, ehm, did that too: https://github.com/theolind/pymysensors/pull/22 :-)

              Your implementation is probably better since this is my first visit to this codebase, so feel free to reject the pull.

              martinhjelmareM Offline
              martinhjelmareM Offline
              martinhjelmare
              Plugin Developer
              wrote on last edited by
              #6

              @Erik-Forsberg

              I think one should be a bit careful about making too many special rules for different cases, between device and controller. I think there should be set ways of communicating between the controller and device. There should also be ways for the user to make rules to create the automations, but this should not change the set ways for communication.

              In this case, when we need an initial value from the user, which should be automated somehow, I think the user should be able to make rules, and somehow be able to set an initial state, by controller API or other means. But I think that should be detached from the specific device - controller communication.

              You can have a look at my handle_req branch here:
              https://github.com/MartinHjelmare/pymysensors/tree/handle_req

              I would say your implementation looks fine, although I have some comments. We can continue at github.

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


              26

              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