Broadlink S1C Kit sensors in HA using python and MQTT

@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

‘{% if value is equalto “13527306” %} Door Unlocked {% elif value is equalto “13527310”%} Door Locked {% else %} what you want to show {% endif %}’

thanks. I just want to know how I can show the previous state of the sensor; either door locked or door unlocked.

in history or logbook but that template sensor. will will display

If I say it, in other words, the sensor should only be required to respond to above two codes and hold the previous state for other codes.

I’m not sure whether retain: true can be use or not.

I fond the way to do it. I just followed NightRanger’s post

Here is what I did,

Automation.yaml

- alias: 'Front Door Sensor Opened Retain'
  initial_state: 'on'
  trigger:
    platform: mqtt
    topic: sensors/rf/receiver
    payload: 13527306
  action:
    service: mqtt.publish
    data:
      topic: 'home/entrance/door'
      payload: '13527306'
      retain: 'true'


- alias: 'Front Door Sensor Closed Retain'
  initial_state: 'on'
  trigger:
    platform: mqtt
    topic: sensors/rf/receiver
    payload: 13527310
  action:
    service: mqtt.publish
    data:
      topic: 'home/entrance/door'
      payload: '13527310'
      retain: 'true'

Binary_Sensor.yaml

  - platform: mqtt
    name: "Front door sensor"
    state_topic: "home/entrance/door"
    payload_on: "13527306"
    payload_off: "13527310"
    qos: 0
    device_class: opening
2 Likes

I’ve created a Custom Component as a Sensor platform based on @NightRanger script.
No need for mqtt with it and it requires a simple yaml configuration.

2 Likes

thanks for the guide.
I would like to ask if someone has tried the same guide using the Broadlink S2 hub?