From dd61c6826c064f61fbc4256ea04fd53fcc977087 Mon Sep 17 00:00:00 2001 From: Ryan Bahm Date: Mon, 23 Oct 2017 19:55:54 -0700 Subject: [PATCH 1/5] Update example to use binary sensor for PIR HASS supports a binary sensor for motion, so this commit leverages that. --- example_home_assistant_configuration.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/example_home_assistant_configuration.yaml b/example_home_assistant_configuration.yaml index 8173058..50383c3 100644 --- a/example_home_assistant_configuration.yaml +++ b/example_home_assistant_configuration.yaml @@ -45,11 +45,21 @@ sensor: - platform: mqtt state_topic: "bruh/sensornode1" - name: "SN1 Real Feel" + name: "SN1 Real Feel" unit_of_measurement: "°F" 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 From 45a7724b8a2b3ccc4a3c8826c4f21f020bfba34d Mon Sep 17 00:00:00 2001 From: Ryan Bahm Date: Mon, 23 Oct 2017 19:58:15 -0700 Subject: [PATCH 2/5] Break PIR on/off strings into defines --- .../bruh_mqtt_multisensor_github.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino b/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino index 6615f5c..8825cac 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 DEFINITIONS *******************************************/ +#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; } From 72ab1fbccc16e14579b9cfba5eef9082c889b21e Mon Sep 17 00:00:00 2001 From: Ryan Bahm Date: Mon, 23 Oct 2017 19:59:15 -0700 Subject: [PATCH 3/5] Remove trailing space Whoops, added a space that I didn't mean to add... --- example_home_assistant_configuration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_home_assistant_configuration.yaml b/example_home_assistant_configuration.yaml index 50383c3..ec67c31 100644 --- a/example_home_assistant_configuration.yaml +++ b/example_home_assistant_configuration.yaml @@ -45,7 +45,7 @@ sensor: - platform: mqtt state_topic: "bruh/sensornode1" - name: "SN1 Real Feel" + name: "SN1 Real Feel" unit_of_measurement: "°F" value_template: '{{ value_json.heatIndex | round(1) }}' From 658fc8a02ed53790eef92bb5394681d919c0d5a7 Mon Sep 17 00:00:00 2001 From: Ryan Bahm Date: Mon, 23 Oct 2017 20:03:01 -0700 Subject: [PATCH 4/5] Fix header --- bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino b/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino index 8825cac..802f266 100644 --- a/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino +++ b/bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino @@ -75,7 +75,7 @@ const int bluePin = D3; -/**************************** SENSOR DEFINITIONS *******************************************/ +/**************************** SENSOR CONFIGURATION *****************************************/ #define PIR_ON_STRING "motion detected" #define PIR_OFF_STRING "standby" From d91b3ea2180ca02852d9883bef57a5b9cab1624a Mon Sep 17 00:00:00 2001 From: Ryan Bahm Date: Mon, 23 Oct 2017 20:04:18 -0700 Subject: [PATCH 5/5] Remove old PIR sensor I've been fighting with line endings and must have missed this in the chaos. --- example_home_assistant_configuration.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/example_home_assistant_configuration.yaml b/example_home_assistant_configuration.yaml index ec67c31..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"