I am trying to integrate the Sonoff PIR2, I have HA set up so that it is properly receiving the JSON formatted MQTT messages from the RF Bridge (flashed with tasmota)
The problem I am having is that the PIR sensor is a single code sensor, sends a message when motion detected only, not when motion is cleared. So I built an automation that has a 10 second delay and then publishes a similar code to the correct topic. But the Binary sensor is set up with the value template for both on and off. So I am not sure how to post the proper json format to get the binary sensor to go back off.
Here is the error I am getting
"Error parsing value: ‘value_json’ is undefined (value: FAEE7Eoff, template: {{value_json.RfReceived.Data}})
Here is the config for the binary sensor
#Garage Motion Sensor
- platform: mqtt
name: Garage Motion Sensor
value_template: '{{value_json.RfReceived.Data}}'
state_topic: "tele/RF_Bridge/RESULT"
payload_on: "FAEE7E"
payload_off: "FAEE7Eoff"
device_class: motion
qos: 1
The config for the automation is pretty basic.
alias: Reset Garage PIR
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_motion_sensor
to: 'on'
condition: []
action:
- delay: '00:00:10'
- service: mqtt.publish
data:
topic: tele/RF_Bridge/RESULT
payload: FAEE7Eoff
mode: single
The problem is that the mqtt.publish format does not match the payload_off JSON format. I tried copying and pasting the JSON formatted MQTT message from listening to that topic and then just changing the “data” portion of it but HA didn’t like the formatting of the multiple lines or whatever.
This is basically a Carbon Copy of DrZZZs YouTube Video but it does not seem to be working for me.