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. Home Assistant - Receiving IR code at trigger

Home Assistant - Receiving IR code at trigger

Scheduled Pinned Locked Moved Home Assistant
5 Posts 2 Posters 2.6k 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.
  • A Offline
    A Offline
    alex_9419
    wrote on last edited by
    #1

    Hi everyone,

    I'm trying to receive data to my sensor from my controller (Home assistant ) with the mysensors library.
    I'm using a RFM69 to communicate with the controller.
    I'd like to receive a certain code to a IR switch to control my heatpump.

    I made a test sketch and uploaded it to my sensor. The sensor is succesfully added to the controller.
    I also made a automation part to test it with a switch, every time the switch is off, (press of a button) a test code is send. The YAML file didn't gave an error.

    I don't receive the code to my sensor, and a also have an error on HA:


    17-02-01 11:33:39 homeassistant.components.switch.mysensors: missing value_type: V_STATUS at node: 6, child: 1

    I don't know why I should also send a V_STATUS message?
    Can anyone help me?
    YAML file, and ino file is added:

    - alias: 'turn HVAC on'
      trigger:
        - platform: state
          entity_id: binary_sensor.motion_sensor_1_1
          state: 'on'
      action:
        service: switch.mysensors_send_ir_code
        entity_id: switch.ir_switch_sensor_6_16
        data:
          V_IR_SEND: '0x26c6'
    
    
    #define MY_RADIO_RFM69
    #define MY_DEBUG
    
    #include <MyConfig.h>
    #include <MySensors.h>
    #include <SPI.h>
    
    #define CHILD_ID 16
    #define CHILD_ID_TEXT 17
    
    char code[10] = "abcd01234";
    MyMessage msgCode(CHILD_ID, V_IR_SEND);
    MyMessage textMsg(CHILD_ID_TEXT, V_TEXT);
    
    void setup() {
      send(textMsg.setSensor(CHILD_ID_TEXT).set("00000000"));
      send(msgCode.setSensor(CHILD_ID).set(code));
    }
    
    void loop() {
      
    }
    
    void presentation() {
      sendSketchInfo("IR Switch sensor","V1.0");
      present(CHILD_ID, S_IR,"IR Sender");
      present(CHILD_ID_TEXT, S_INFO, "IR data");
      
    }
    
    
    void receive(const MyMessage &message) {
      if(message.type == V_IR_SEND) {
        Serial.println("V_IR_SEND command received");
        int Ir_Code = message.getInt();
        Serial.println(Ir_Code);
      }
    }
    
    martinhjelmareM 1 Reply Last reply
    0
    • A alex_9419

      Hi everyone,

      I'm trying to receive data to my sensor from my controller (Home assistant ) with the mysensors library.
      I'm using a RFM69 to communicate with the controller.
      I'd like to receive a certain code to a IR switch to control my heatpump.

      I made a test sketch and uploaded it to my sensor. The sensor is succesfully added to the controller.
      I also made a automation part to test it with a switch, every time the switch is off, (press of a button) a test code is send. The YAML file didn't gave an error.

      I don't receive the code to my sensor, and a also have an error on HA:


      17-02-01 11:33:39 homeassistant.components.switch.mysensors: missing value_type: V_STATUS at node: 6, child: 1

      I don't know why I should also send a V_STATUS message?
      Can anyone help me?
      YAML file, and ino file is added:

      - alias: 'turn HVAC on'
        trigger:
          - platform: state
            entity_id: binary_sensor.motion_sensor_1_1
            state: 'on'
        action:
          service: switch.mysensors_send_ir_code
          entity_id: switch.ir_switch_sensor_6_16
          data:
            V_IR_SEND: '0x26c6'
      
      
      #define MY_RADIO_RFM69
      #define MY_DEBUG
      
      #include <MyConfig.h>
      #include <MySensors.h>
      #include <SPI.h>
      
      #define CHILD_ID 16
      #define CHILD_ID_TEXT 17
      
      char code[10] = "abcd01234";
      MyMessage msgCode(CHILD_ID, V_IR_SEND);
      MyMessage textMsg(CHILD_ID_TEXT, V_TEXT);
      
      void setup() {
        send(textMsg.setSensor(CHILD_ID_TEXT).set("00000000"));
        send(msgCode.setSensor(CHILD_ID).set(code));
      }
      
      void loop() {
        
      }
      
      void presentation() {
        sendSketchInfo("IR Switch sensor","V1.0");
        present(CHILD_ID, S_IR,"IR Sender");
        present(CHILD_ID_TEXT, S_INFO, "IR data");
        
      }
      
      
      void receive(const MyMessage &message) {
        if(message.type == V_IR_SEND) {
          Serial.println("V_IR_SEND command received");
          int Ir_Code = message.getInt();
          Serial.println(Ir_Code);
        }
      }
      
      martinhjelmareM Offline
      martinhjelmareM Offline
      martinhjelmare
      Plugin Developer
      wrote on last edited by martinhjelmare
      #2

      @alex_9419

      Since this is a switch platform you need to send a V_STATUS or V_LIGHT message to report state of the switch. Se example sketch on home-assistant.io.

      https://home-assistant.io/components/switch.mysensors/#ir-switch-sketch

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alex_9419
        wrote on last edited by
        #3

        Thanks!

        I didn't knew it was part of S_IR!

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

          It's not part of S_IR in the official mysensors API, but to implement this type in home assistant as a switch platform it was necessary, in my view, to require a message for the state of the switch. Otherwise how would the switch be turned off, after activation? This is described briefly in the docs.

          https://home-assistant.io/components/switch.mysensors/#services

          In general I try to follow the mysensors API when implementing it with home assistant, but sometimes there will be differences, either out of necessity or as an enhancement. That's why I've made it standard to include an example sketch for each mysensors platform in the home assistant docs. Everyone is welcome to contribute updates to both source code and docs.

          A 1 Reply Last reply
          1
          • martinhjelmareM martinhjelmare

            It's not part of S_IR in the official mysensors API, but to implement this type in home assistant as a switch platform it was necessary, in my view, to require a message for the state of the switch. Otherwise how would the switch be turned off, after activation? This is described briefly in the docs.

            https://home-assistant.io/components/switch.mysensors/#services

            In general I try to follow the mysensors API when implementing it with home assistant, but sometimes there will be differences, either out of necessity or as an enhancement. That's why I've made it standard to include an example sketch for each mysensors platform in the home assistant docs. Everyone is welcome to contribute updates to both source code and docs.

            A Offline
            A Offline
            alex_9419
            wrote on last edited by
            #5

            @martinhjelmare

            Thanks for the help, it works!! I'm sorry for the late respons, I was busy

            1 Reply Last reply
            1
            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