thanks, any idea to fix this
You need to add in your else
section the current state of the sensor, so that if neither of the sensor values is detected, the current state is maintained.
I don’t have the syntax at the moment, but that’s the principal.
Edit: I think
{% else %}
{{ states("front_doorlock") }}
{% endif %}
Thanks. good hint. I will try
Out of interest, what sensors do you use ?
front_doorlock:
friendly_name: "Front Doorlock"
value_template: >-
{%- if is_state('sensor.rf_receiver.state', '13527306') -%}
Door Unlocked
{%- elif is_state('sensor.rf_receiver.state', '13527310') -%}
Door Locked
{%- else -%}
{{ is_state('sensor.front_doorlock') }}
{%- endif %}
Above code not generating an error. However, no value shows on the sensor. What I am missing??
should be
states('sensor.front_doorlock')
Thanks. still no luck. sensor state is still unknown.
I found the way to do it.
I hope it is not too late to ask. I would like to add more door sensor to my ha. Is this wirelss door magnetic strip for goldgen security gs works and can add in to ha? Is the communication between the door status and ha is by using mqtt follows from your latest post?
I do have broadlink rm pro and broadlink s1c / I found that broadlink door sensor from broadlink itself is x2 price from the door sensor you posted.
The communication is 433 mhz codes, you need a decoder to convert codes to mqtt for homeassistant actions.
Don’t forget these sensors also report dead battery, and tamper codes.
You should template all 4 modes.
From a customer review on banggood…
Has 4 functions: 2018-09-08 05:08:16
This sensor has 4 functions as described in the offer: - Activate and - Deactivate (others often do not provide this) via the internal reed relay - Anti-tamper switch function via an extra switch on the rear side. - Low voltage alert function (try it with a weak battery). All those 4 states are transmitted by separate codes which are different in the last hexnumber: close: “E”, Open: “A”, Battery: “6”, Tamper: “7” Works for example with RF-Link and Sonoff RF Bridge. Don’t know how long the AAA Battery lasts, but they are easy to replace.
FYI, in order for the tamper function to work you need to add a switch inside on the cheap ones they are selling now. The PWB has a place for the switch, but it’s not there. You could however use that missing switch to be an input from something else, so that is cool. Close that circuit, or open it, not sure, and you will I’m sure get a code 7.
Hi
I got this sensor https://goo.gl/7giu6R but I am confused.
The codes I am seeing in this post are in format:
12345678 (short numeral).
But my codes read by my Broadlink RM pro is like:
“shE0ABAAAcsRLBEsLg8RLS0PESwvDy8QLg8RLRAtESwRLBEsESwuEBEsEC0RLBEsLg8SLC4PES0AAAAA”
RM Pro can read different codes (open/close) but even stranger I get different codes for the same state (ex. open). Not very different, just a couple of letters /numbers.
The beginning of the code doesn’t change , for open is always starts with “sh…”
Anyone has any idea if it is normal?
Try this code:
- platform: mqtt
name: “Front door”
payload_on: “xxx on code xxx”
payload_off: “xxx off code xxx”
device_class: door
state_topic: “tele/sonoff_bridge/RESULT”
value_template: ‘{{ value_json.RfReceived.Data }}’
I got a Sonoff RF bridge, all good now. Reads and sends correct short code.
I haven’t used the RM Pro for 433, but it looks like that needed to be changed from base 64 to hex possibly. I use the sonoff bridge and it functions awesome.
Just received four of these - thanks for the detail. I can confirm that there IS a place on the PCB for a tamper switch - four PTH in a 5mm square. If you s/c the upper left and lower right ‘holes’ (seen from top with battery to right of board), you will get a xxxxx7 code. And, yes, works perfectly with Sonoff RF Bridge with v8.2.0 Tasmota.
Yup, and I believe it sends it’s code when the circuit opens. I was going to use the 7 code for something but that action was backwards, so even though i have a dozen of those things around the house, I haven’t used that code yet. But it is there…