Home Assistant - Receiving IR code at trigger
-
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); } }
-
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
-
Thanks!
I didn't knew it was part of S_IR!
-
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.
-
Thanks for the help, it works!! I'm sorry for the late respons, I was busy