MySensors: Sending an unsigned long to device

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 and this controls my LED. 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. Thus, I cannot send anything to the device/entity… 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

Hello ,

Have you found a solution ? I wanted to switch from Pimatic to Home Assistant. I’m not sure if that was the right decision :frowning: . The Mysensors integration is somehow not running smoothly here and I have not yet found any information on how to configure anything and where. Except for the YAML file, in which no Mysensors entries can be made.

Greetings Frank

This thread was started two years ago - the information in it may be out of date. It might be better to start a new thread in which you can describe your own situation, with a link to this one to provide context if necessary.

Yeah, the communication between MySensors and HA is sometimes frustrating. I know I found a solution, but I don’t remember exactly what it was. This is the line I found in my code in the MySensors sensor:
MyMessage msgZone(CHILD_ID_ZONE,V_TEXT); // ?must be type V_TEXT for Home Assistant to send data
In the HA YAML the corresponding code:

        "sensor_id": 0,
        "children": {
            "1": {
                "id": 1,
                "type": 36,
                "description": "Zone",
                "values": {
                    "47": "0"
                }
            },

The HA Automation code is:

repeat:
  count: "25"
  sequence:
    - if:
        - condition: template
          value_template: "{{ (states('sensor.sip')|from_json)[ repeat.index - 1] == 1 }}"
      then:
        - service: text.set_value
          target:
            entity_id: text.zone
          data:
            value: "{{ repeat.index }}"

As I remember, if a number is converted to text and then sent, it works. What happens is that the value that is put on the MQTT broker topic will be a string of characters, not a binary. That way both HA and MySensors can process it. (or something like that).

I feel guilty that I didn’t better document my success. Perhaps with the experimentation you do you can put down what worked for you.

Best of luck

OSD