YET another take on an alarm system

The application uses the code to access the settings and send the disarm command. Since the code can’t be passed along with the MQTT message, it does not sync with HASS. However you can set the code to be the same as HASS if you want, but they are not connected at this time.

I have used this for a while now and it really works good.

A few weeks ago I suggested a future feature - the possibility to have several codes, typically one for each family member (and to lay the grounds for the a future feature - to track who armed and/or disarmed and perform actions based on that).

I never saw any response to that, so I’ll try again:
Do you have any thoughts about that? Interesting/to much work/not interesting?

Hi All,

I’m new to all HA stuff so please bear with me, I learn quickly :wink:
I’ve just installed and managed to run a freshly downloaded version of this alarm system on my RPi3B.
I have a SONOFF RF bridge (flashed Espurna) with a SONOFF PIR2 and SONOFF DW1 door sensor connected to HA.
When ssh’d into my RPI, I can see MQTT messages like
SRFB/rfin 30C0019004E2D459CE
SRFB/relay/0 1
and
RFB/rfin 37FA020805DC641421
SRFB/relay/6 1

respectively, so I assume it can be picked up by the alarm panel.

My question is how to add these sensor to my config, considering that they are not switches and don’t actually change any state?
Any help is appreciated.

I noticed See the README for guidance in mqtt section of README.md, but cannot see any other readme.

I did spot that suggestion and I like it.

I’ll add it to the To do list

You need to checkout Mqtt help to create a binary_sensor based on messages received from your sonoff.

Once you have the binary_sensor reading and creating a state of On/Off you’re good to go. If you need a hand let me know.

I added the following to configuration.yaml
binary_sensor:
- platform: mqtt
state_topic: “SRFB/rfin 384A01FE05D2641421”
device_class: opening
name: “Door sensor”

and it shows when the sensor was open on the Overview page, but that’s not exactly what I’m looking for, right? And I have no idea how to configure its On/Off state as it has no such thing being a sensor :wink:
So the question is how to add this sensor to the alarm system.

Can you post both the topic and payload you see when you open the switch and when you close the switch

So according to the espurna instructions

State topic Example payload Notes
{root topic}/rfin 26C0013603CA511451 received code

The payload is a hex? representation of the RF code being generated by the device. I’m assuming the code is the same everytime the door switch opens and closes? One code for each state? Or does it only send one signal ie when the door opens?

If its the latter then this may be tricky, using an automation to set the open state back to closed after say 5 seconds may work unless anyone can suggest a slicker method?

The door sensor generates a message when the door is open (i.e its two parts being separated). It does not generate anything if the door is closed.
The message is SRFB/rfin 389A01FE05D2641421 followed by SRFB/relay/6 1 if I define only On combination. If I define Off with the same code, it would flip the relay state every time I open the door (fun, but useless).

Same applies to the PIR sensor.

Ok so it looks as though you have door switch configured as relay 6 so its sending out a repeat message after it detects the rf signal.

This may work:

binary_sensor:
  platform: mqtt
  state_topic: "SRFB/relay/6"
  name: "Door Sensor"
  payload_on: 1
  payload_off: 0
  sensor_class: opening

The automation:

- alias: '[DOOR] - State off'
  trigger:
    platform: state
    entity_id: binary_sensor.door_sensor
    state: 'on'
    for:
      seconds: 5
  action:
    service: mqtt.publish
    data:
      topic: 'SRFB/relay/6'
      payload: '0'

Give that a go. You can buy 433 rf devices which also report the closed state too which work with sonoff

Do I get it right that the same idea applies when I register motion sensor (PIR)?
And I understand that your code triggers the relay off after 5 seconds.
What else do I need to do to connect my door sensor/PIR to the alarm panel so it would trigger alarm when in Away mode?

Yes it should be the same for the motion sensor.

you would need to add these devices into either the immediate or delayed group (in alarm.yaml) depending on your preference

Thanks, it kind of work… apart form the automation bit.
I don’t understand where you got entity_id: binary_sensor.door_sensor from.
And I can see no mqtt messages switching the relay off. But if I send the same message manually via HA, I can see it and it does the job…

if the binary_sensor sets up properly it should be named binary_sensor.door_sensor given you named it

name: "Door Sensor"

Yes, the name is correct, and binary_sensor.door_sensor is listed in States section.
However, the automation you provided does not seem to work.
I added it into /config/automation.yaml

Can see no reason why it doesn’t work.
Added a random sensor and appropriate automation from Get Started section, and it doesn’t work as well.

This might be the cause of it, but there is no solution yet as far as I can tell…

Do you have any errors messages you can share?

I’ll test it tonight on my setup and post the result.

I can see nothing special in System log or homeassistant.log.
That constant “time out of sync, resetting” error is something that might impact the overall behaviour though (as some users report). And tonight my RPi rebooted itself without a reason (I just saw Connection lost while connected to the main HA screen via web browser).
But apparently some automation IS working, otherwise your alarm panel wouldn’t work.
Will update later on if I have anything to add.

By the way, to switch the relay off the command should be SRFB/relay/6/set 0, not just SRFB/relay/6 0

Update: I managed to make it work. First of all, I used automation.yaml to add my automation, but it only picked up when I switched to automations.yaml.
That means automation.yaml file that is a part of your alarm is not active by default, is that correct?
It also required initial_state: on bit to be active.

WHat would you recommend as hardware companion for a 4 key alarm button?

(07/03/18) NEW Feature - Pending and Trigger time can be determined per state. For example arming the alarm in away mode can be set to 60 seconds pending time, yet arming in home mode can be set to 30 seconds.

By the way, your alarm prevents one from arming when a door is open, for example.
But if it is open during pending time before arming, it does not matter. Do you think it’s the right behaviour?

What devices would you recommend?