diff --git a/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino b/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino index 6615f5c..802f266 100644 --- a/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino +++ b/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino @@ -75,6 +75,12 @@ const int bluePin = D3; +/**************************** SENSOR CONFIGURATION *****************************************/ +#define PIR_ON_STRING "motion detected" +#define PIR_OFF_STRING "standby" + + + /**************************** SENSOR DEFINITIONS *******************************************/ float ldrValue; int LDR; @@ -453,13 +459,13 @@ void loop() { pirValue = digitalRead(PIRPIN); //read state of the if (pirValue == LOW && pirStatus != 1) { - motionStatus = "standby"; + motionStatus = PIR_OFF_STRING; sendState(); pirStatus = 1; } else if (pirValue == HIGH && pirStatus != 2) { - motionStatus = "motion detected"; + motionStatus = PIR_ON_STRING; sendState(); pirStatus = 2; } diff --git a/example_home_assistant_configuration.yaml b/example_home_assistant_configuration.yaml index 8173058..61a3ac2 100644 --- a/example_home_assistant_configuration.yaml +++ b/example_home_assistant_configuration.yaml @@ -32,11 +32,6 @@ sensor: unit_of_measurement: "LUX" value_template: '{{ value_json.ldr }}' - - platform: mqtt - state_topic: "bruh/sensornode1" - name: "SN1 PIR" - value_template: '{{ value_json.motion }}' - - platform: mqtt state_topic: "bruh/sensornode1" name: "SN1 Temperature" @@ -50,6 +45,16 @@ sensor: value_template: '{{ value_json.heatIndex | round(1) }}' +binary_sensor: + - platform: mqtt + state_topic: "bruh/sensornode1" + name: "SN1 PIR" + value_template: '{{ value_json.motion }}' + payload_on: "motion_detected" + payload_off: "standby" + device_class: motion + + group: sensor_node_1_card: name: Sensor Node 1