Broadlink S1C Kit sensors in HA using python and MQTT

Here is the s1c_keyfob.yaml in package
keyfob

############################################################################
# Broadlink S1C Keyfob Armed_away, Armed_home and SOS
# Test with HA 0.61.1
# Please change broadlink ip, mac address, broadlink friendly_name and name
############################################################################

switch:
  - platform: broadlink
    host: brodlinkip
    mac: broadlinkmac
    timeout: 30
    friendly_name: "Pro1"
    type: rm
    switches:
      s1c_armed_away:
        friendly_name: "S1C Armed Away"
        command_on: 'sgGEAx8JHgkKHQscCxwLHB8JCxwLHB8IHwkeCR4JCxwfCAsdHgkeCR8IHwkeCR4JCxwLHR4JCxweCQscCx0eCR4JHgkLHAsdHgkLHB8ICxwLHR4JHgkfCAsdCh0eCQscHwgfCR4JHgkfCQoJCzoLCQoJCwkLCQoJCwkLCAsJCwkKCQsJCwgLCQsICwkLCQoKCgkLCQodCwgVCR8ICwkLEh4JCxwLHR4JCxwLHAscHwkKHQscCxwLHQodCh0eCQscCx0eCR4JHwgLHB8JHgkLHAscCxwLHR4JCxwLHB8JHgkeCR4JCx0eCQscHgkfCB8IHwkeCR4JCxwLHR4JCxweCQsdCxweCR4JHgkLHQodHgkLHR4ICx0LHB4JHwgfCQodCxweCQscHwkeCR4JHwkeCQoKCjoLCQsJCgkLCQsICwkLCQoJCwkLCAsJCwkLCAsJCwgLCQsJCwgLCQscCwkUCR8ICwkLEh8ICxwLHR4JCxwLHAsdHgkLHAscCxwMHAscCxwfCAsdCxweCR8IHwgLHR4JHgkLHAsdCh0LHB4JCxwLHR4JHgkfCB8JCxwfCAscHwkeCR4JHgkeCR8JCh0LHB4JCxwfCQscCxwfCB8JHgkLHAscHwkKHR4JCxwLHB8JHgkeCQscCx0eCQscHwgeCR8JHgkeCQsJCzoKCQsJCwgLCQsJCgkLCQsICwkLCQoJCwkLCAsJCwkKCQsJCwkKCQscCwkVCR4JCwgLEh8JCh0LHB4JCx0KHQscHgkLHAsdCh0LHAscCxwfCQscCxwfCB8JHgkLHB4JHgoKHQodCxwLHB8ICx0KHR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h4JHgkeCR4KCh0KHR4JCx0eCQodCxwLHAsdHgkLHAsdHggLHR4JCxwLHR4JHgkeCQscCx0KHR4JCxwfCB8JHgkeCQsJCjsKCQsJCgoKCQsJCwgLCQoKCgkLCQoJCwkLCQoKCgkKCQsJCwkKCgodCgkUCh4JCwgLEh4KCh0LHB4JCx0KHQodHgkLHQodCh0LHAscCx0eCQodCx0eCR4JHgkLHB4KHggLHQodCxwLHR4JCh0KHR4KHgkeCR4JCx0dCgodHgkeCh0JHwkeCR4JCxwLHR4JCxweCQsdCh0KHQoeHQkLHAsdHgkLHB4KCh0KHR4JHgkfCQodCh0LHB4KCh0eCR4JHgoeCQoJCzoLCQoKCgkLCQoKCgkKCQsJCgoKCQsJCwgLCQsJCgoKCQsJCgkLCQodCwkUCh0JCwkKFB0JCxwLHR4JCh0LHQocHgoKHQsdChwLHQodCh0eCQsdCh0eCR4KHQoKHR4JHgkLHQodCh0KHR4JCxwLHR4JHgkeCR8JCh0eCQsdHggeCh4JHgkeCR4KCh0KHR4JCx0eCQodCh0LHAsdHgkKHQodHgoKHR4JCh0LHR4JHgkeCQscCx0KHR4JCx0eCB8JHgkeCQsJCjsKCQsJCgoKCQsJCgoKCQsJCgkLCQoKCgkLCQoKCgkKCQsJCwkKCQsdCgkUCh0KCgkLEx4JCh0KHR4KCh0KHQodHgkLHQodCh0LHQocCx0eCQscCxweCh4JHgkKHR4KHQoKHQodCx0KHR4JCh0LHB4KHgkeCR4JCh0eCgodHgkeCR4JHwkeCR4JCh4KHB4KCh0eCQscCx0KHQodHgkLHAsdHgkLHB4KCh0KHR4JHgoeCQodCh0KHh4ICx0eCR4JHgkeCgoKCgAF3AAAAAA='	  
###############		  
# Group
###############

group:
  s1c_keyfob:
    name: S1C Alarm and SOS
    control: hidden
    entities:
     - switch.s1c_armed_away
     - switch.s1c_armed_home    
     - script.sos  
#########################################################
# script SOS / Can deactivate SOS from e-control app only
#########################################################

script:
  sos:
    sequence:
      - service: switch.broadlink_send_packet_broadl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CxweCQsdCh0eCR8JHgkKHR4JHgkLHQodCxwLHB4JCx0KHR4JHgoeCR4JCh0eCQsdHgkeCR4JHwkeCR4JCh0LHB4KCh0eCR4JCx0KHR4JHgkLHQodHgkKHR4KCh0KHR4JHwgeCgodHgkLHB4JHgoeCR4JHgkfCQoJCwAF3AAAAAA="

@NightRanger Have you ever managed to capture the signals of a Broadlink S1C door sensor using 433MHz receivers? I am trying to get a signal with my ESP8266 running OpenMQTTGateway and a 433MHz receiver and transmitter connected. But I am not having any luck.

@starkillerOG No I wasn’t able to capture the broadlink sensors RF codes which is really strange, I bought a regular 433 door/window sensors (which has 3 states, open, closed and tamper) and PIR sensors and I am using it with the openmqtt gateway.

@NigthRanger @Sunonline, Thanks for your quick replay.
Indeed I do not have the S1C gateway/host, I only have the sensor, so I cannot use the standard library.
That is a shame that it does not work by directly sniffing the 433MHz packets, lookes like I wasted a few dollars on this sensor.
@NightRanger could you sent me a link to the sensors you bought? I will probably have to buy some other sensor, because I do not want yet another bridge.

@starkillerOG

The door/window sensor (with 3 states):

https://www.gearbest.com/access-control/pp_593451.html

PIR Sensor:

Has only one state, you need to create an automation to switch state after a few seconds

1 Like

@NightRanger thank you!

@NightRanger in the product discription it states that it has a “Loud Voice”.
I hope the sensor does not make any sound when you do not use the gateway but only the sensor?
Does the sensor produce any sound when using it with the OpenMQTTGateway?

@starkillerOG which one ?

I have both models and there is no sound coming out of them

@NightRanger I ment the GS - WDS07 you shared the link to.
Thanks for conforming that they do not produce any sound.
I yust ordered one, so hopefully that one will work with my OpenMQTTGateway.
Thanks for all your help @NightRanger

I was trying to setup S1C by following the instructions through the add-on procedure but I end up with the following:

checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/pip-build-rnoknu93/pycrypto':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Traceback (most recent call last):

I use the following options

{
“code”: “/share/s1c.py”,
“requirements”: [
“broadlink”
]
}

all relevant files have been placed on /share.

Any ideas?

RUN apk add --no-cache
jq
py2-pip
clang
libgcc
gcc-gnat
libgc++
g++
make
libffi-dev
openssl-dev
python2-dev
mosquitto
mosquitto-dev
mosquitto-libs
mosquitto-clients

check my post Broadlink S1C Kit sensors in HA using python and MQTT

Gabriel thanks for the help, I must have missed something…whatever I do I always get:

configure: error: in /tmp/pip-build-ommb80cf/pycrypto': configure: error: no acceptable C compiler found in $PATH See config.log’ for more details
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-build-ommb80cf/pycrypto/setup.py”, line 456, in
core.setup(**kw)
File “/usr/lib/python3.6/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.6/distutils/dist.py”, line 955, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/data/venv/lib/python3.6/site-packages/wheel/bdist_wheel.py”, line 204, in run
self.run_command(‘build’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/lib/python3.6/distutils/command/build.py”, line 135, in run
self.run_command(cmd_name)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-build-ommb80cf/pycrypto/setup.py”, line 251, in run
self.run_command(cmd_name)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/tmp/pip-build-ommb80cf/pycrypto/setup.py”, line 278, in run
raise RuntimeError(“autoconf error”)
RuntimeError: autoconf error

I will try it again tomorrow when I will have more clear mind…Thanks again

I allowed myself to create a separate topic for us Hass.io users as this topic is mostly for Hassbian users and the two systems get mixed up. If you are using Hass.io, please feel free to post here:
Broadlink S1C Kit Sensors for Hass.io

Thanks to Gabriel and TomerFi for their input!

Got it done already!!!

Good mornng, I would like to ask regarding the mqtt binary_sensor you provided in the post.
I have the problem with the payload_on, payload_off. it won’t display the correct state whether open or closed. And do I have to re-run the s1c.py once more after change from sensor to binary_sensor. Thank you very much.

binary_sensor:
  - platform: mqtt
    name: "Front door sensor"
    qos: 0
    state_topic: "home/entrance/door"
    payload_on: "111111"   <=== what do I have to put for door sensor, motion sensor / is it on/off or 0/1
    payload_off: "222222"    <=== what do I have to put for door sensor, motion sensor / is it on/off or 0/1
    device_class: opening  <=== for door and window sensor.  motion for motion sensor

@NightRanger
How did you add door sensors to home assistant?
I use the following coding but not yet succeeded. Do you know what wrong with this code?

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 %}
       {{ states('sensor.front_doorlock') }}
     {% endif %}

I miss understood what you mean. If you use binary_sensor or template sensor. then you can use value_template

value_template: “{{ ‘on’ if is_state(‘device_tracker.echo_1’, ‘home’) else ‘off’ }}”

@Sunonline
Yes, I use template sensor. Can you understand whats wrong with my value_template?
My rf receiver keeps receiving the codes from other devices as well. So, what I really want to change the state of the sensor if one of above two codes received and else keep the previous state of the sensor on hold.

This will give you Door Unlocked when sensor.rf_receiver value is 13527306, apart from this value mean Door Locked.

value_template: “{{ ‘Door Unlocked’ if is_state(‘sensor.rf_receiver’, ‘13527306’) else ‘Door Locked’ }}”

This is working but the issue is sensor could not hold the state until next code from door sensor. Because rf.sensor receiving codes from other sensors meantime. Do you have any idea how I can ignore the other codes and only response to the code from door sensor and hold the state.

something like this
IF rf.sensor.state = 113210
THEN door unlocked
ELSE IF rf.sensor.state = 113205
THEN door locked
ELSE hold the previous state - {{ states(‘front_doorlock’) }}
END IF