Send configuration (numbers) from HA to Arduino



  • I would like to make changes to my Arduino sensor after it is deployed. I have developed an autocalibration scheme, but it needs its zero point set, which can't be done until it's in its final location. Yes, I suppose I could, with long wires, connect a push button to an input. But that doesn't completely solve the problem because I need to send a number that can be interpreted to be the interval between sending data to HA.

    This is my receive routine:

    //-------------------------------------------------------------------------receive
    void receive(const MyMessage &message)
    {
    	// We only expect one type of message from controller. But we better check anyway.
    	if (message.getType()==V_VAR1) {
        ConfigurationFromMySensors = message.getLong();
    	}
    }
    

    In HA, I would pack the information in a 4 byte integer (long) and unpack it in the loop where I would operate on it as needed.

    But how do I send the 4 byte integer from HA?

    Thanks for your consideration and hopefully, help!

    OSD


  • Mod

    @OldSurferDude I have not tried it myself, but I think you request it, like https://www.mysensors.org/build/pulse_power does in setup().

    You could request it periodically to remove the need for an input button.



  • @mfalkvidd Thanks for the tip! It led me to the Home Assistant page that explains how to do it. I'll be having a look at that and report back what I find.



  • @mfalkvidd
    I still don't see how to send a 4 byte value.

    If I have an LED, the message variable type is V_STATUS, the presentation variable is S_BINARY and the request variable is V_STATUS, and the receive variable is V_STATUS. This will set up a nice toggle switch under Controls in Home Automation. (Home Assistant-->Settings-->Devices & Services-->Devices-->"(my device name [node id])"--> )

    What V_variable/S_variable combination yields a control in Home Assistant?

    Let us suppose my node ID is 71, and my child id is 5. There will appear as a toggle control in Home Assistant. If I publish to the MQTT broker the topic mysensors-in/71/5/1/1/2 (2 being the number associated with V_STATUS) with a payload of 1, my LED turns on. Yeah!

    Now I set up a V_CUSTOM/S_CUSTOM device at child ID 3. This appears as a Sensor in Home Assistant, not as a control. If I publish to the MQTT broker the topic mysensors-in/71/3/1/1/48 (48 being the number associated with V_CUSTOM) the payload 1280, it arrives at my device and it deals with it as expected.

    Thus my question: "What V_variable/S_variable combination that yields a control in Home Assistant?" Oh, and have Home Assistant be able to send an unsigned long?

    I suspect that that capability has yet to be developed for the MySensors Integration in Home Assistant. I'd like to know if this is the case. Perhaps I can figure out how to have Home Assistant send the MQTT message for me?

    Thanks for your consideration!

    OSD


  • Mod

    @OldSurferDude great questions. I'm afraid I have no idea. I have never used MySensors with HA.



  • I'm doing a similar thing, but use node red to inject the values directly to mqtt. This brings more flexibility as it allows any value to be injected, while home assistant checks on values as they are defined in the mysensors protocol specification.



  • @electrik Thanks, I think I can do the same with the MQTT integration (not MySensors MQTT)

    OSD



Suggested Topics

  • 2
  • 1
  • 5
  • 1
  • 7
  • 3
  • 4
  • 4

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts