Open/close door sensor (EV1527)

Hello all!

I’m quitte new with home assistant (comming from pimatic). First of all great platform!!

I have a question about my door/window sensor. When I open my door I receive an on command (see below) and when I close the door I also receive an on commando (different ID). Now how can I make this into an device open/close?

Open command:
DEBUG (MainThread) [rflink.protocol] received data: 20;0D;EV1527;ID=08ebb0;SWITCH=0a
DEBUG (MainThread) [rflink.protocol] received data: ;CMD=ON;
DEBUG (MainThread) [rflink.protocol] got packet: 20;0D;EV1527;ID=08ebb0;SWITCH=0a;CMD=ON;
DEBUG (MainThread) [rflink.protocol] decoded packet: {‘switch’: ‘0a’, ‘node’: ‘gateway’, ‘command’: ‘on’, ‘protocol’: ‘ev1527’, ‘id’: ‘08ebb0’}
DEBUG (MainThread) [rflink.protocol] got event: {‘command’: ‘on’, ‘id’: ‘ev1527_08ebb0_0a’}
DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {‘command’: ‘on’, ‘id’: ‘ev1527_08ebb0_0a’}

Close command:
DEBUG (MainThread) [rflink.protocol] received data: 20;09;EV1527;ID=08ebb0;SWITCH=0e
DEBUG (MainThread) [rflink.protocol] received data: ;CMD=ON;
DEBUG (MainThread) [rflink.protocol] got packet: 20;09;EV1527;ID=08ebb0;SWITCH=0e;CMD=ON;
DEBUG (MainThread) [rflink.protocol] decoded packet: {‘switch’: ‘0e’, ‘node’: ‘gateway’, ‘command’: ‘on’, ‘protocol’: ‘ev1527’, ‘id’: ‘08ebb0’}
DEBUG (MainThread) [rflink.protocol] got event: {‘command’: ‘on’, ‘id’: ‘ev1527_08ebb0_0e’}
DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {‘command’: ‘on’, ‘id’: ‘ev1527_08ebb0_0e’}

Thanks in advance!

Hi @Gratizzz

Try adding a switch with the debug info.

- platform: rflink
  device_defaults:
    fire_event: true
    signal_repetitions: 2
  devices:
    ev1527_08ebb0_0a:
      name: switchxx
1 Like

Hi @Petrica

Thanks for your quick reply!

I see the switch and it does switch on when I open the door.

In the log I see:
2018-01-02 23:14:12 DEBUG (MainThread) [homeassistant.components.rflink] passing event to []
2018-01-02 23:14:12 DEBUG (MainThread) [homeassistant.components.rflink] Fired bus event for switch.switchxx: on

But how can I merge the two on commands to an open/closed sensor?

@Gratizzz
I’m not very familiar with RFlink platform but I would say create two automations (one for the open signal from the first sensor and the other from the close signal) that have the payloads “on” and “off” sent in a single topic named “home/open_door_sensor_xxx” or similar, and a MQTT binary sensor setup with “on” and “off” payloads above.

Alternatively, as you already use RFLink, flash the Arduino Mega with https://github.com/1technophile/OpenMQTTGateway.

Setup is much easier than RFLink as the topic for the messages is unique, however the payloads are different. The integration is through MQTT (which is the greatest thing since the invention of hot water :slight_smile: )

@Petrica

Thanks! I think I will fix it with a few automations (a bit more work but fine for now!).

I will have a look at the OpenMQTTGatewat (new for me, but looks like hot water indeed!). Thanks for that! :slight_smile:

@Gratizzz
You’re welcome. Come back if you need help on the automation.

Hi @Gratizzz

You can change the commands to ON/OFF with RFlink and ‘RF Signal Learning’.

https://kris.bogaerts.org/2018/02/21/cheap-door-window-contact-ev1527-with-home-assistant-and-rflink/

Does it mean using OpenMQTTGateway instead of RFLink?

Hi all,
i dont know if is just for me, but every door sensor ev1527 that i have, send always SWITCH=0e when off and SWITCH=0a when on.
Since RFLink Signal Learning isnt stable for me, i tried to fix by adding on parser.py after the line 265 and before “return data” this:

correct ev1527 device ON/OFF command

if data.get('protocol', '') == 'ev1527' and data.get('switch', '') == '0e':
    data['command'] = 'off'


if data.get('protocol', '') == 'ev1527' and data.get('switch', '') == '0a':
    data['command'] = 'on'

Hope this can help someone.

Hi @jackdalma, this would be really cool and very helpful for me!

I just gave it a try but I end up with the following error:

2018-08-22 19:24:42 ERROR (MainThread) [homeassistant.setup] Error during setup of component rflink
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 145, in _async_setup_component
hass, processed_config)
File “/usr/local/lib/python3.6/asyncio/coroutines.py”, line 212, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/rflink.py”, line 111, in async_setup
from rflink.protocol import create_rflink_connection
File “/home/pi/.homeassistant/deps/lib/python3.6/site-packages/rflink/protocol.py”, line 11, in
from .parser import (
File “/home/pi/.homeassistant/deps/lib/python3.6/site-packages/rflink/parser.py”, line 267
if data.get(‘protocol’, ‘’) == ‘ev1527’ and data.get(‘switch’, ‘’) == ‘0e’:
^
TabError: inconsistent use of tabs and spaces in indentation
2018-08-22 19:24:43 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.rflink. Setup failed for dependencies: rflink
2018-08-22 19:24:43 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.rflink: Could not setup all dependencies.

Screenshot of the parser.py file:

File location: …\home assistant\deps\lib\python3.6\site-packages\rflink

Hope you can help me out :slight_smile:

the error is related to indentation, check indentation of the first and third “if” on the screenshot, and apply the same on the second one.

Thanks! It was indeed that simple :slight_smile: working like a charm! Thanks a lot!

Hi @jackdalma, I just did a new install on my second hass platform (hassio image on raspberry pi 3). But now where can I find the file to edit? Do you know if it is even possible?

Hi,
I never used Hass.io image and i dont know if it is possible. I found this discussion
Editing Component Files in Hassio

Hey, @Gratizzz any chance you could post your config with the few extra automations? I’m using Hass.io so the Jacks’s solution isnt a solution for me.

Hi anyone get this to work on HASSIO install…tried the parser.py method but no joy…

2 @parfour & all:
I don’t think changing rflink source files is a particularly good idea to achieve what you want and offer a different approach.

You need:

  1. Define two rflink binary sensors:
binary_sensor:
   - platform: rflink
     devices:
       # on command
       ev1527_08ebb0_0a:
         off_delay: 1
       # off command
       ev1527_08ebb0_0e:
         off_delay: 1

These 2 sensors will be internal ones to receive those on and off commands. To enable it work as planned we need them to go back to off state as soon as possible (1 second here).

  1. Define a input_boolean that will represent state of your door sensor:
input_boolean:
  my_door_sensor:
  1. Create automations that will trigger that my_door_sensor as a reaction to any of our binary_sensors changing their states to on (meaning on or off command received):
automation:
  - alias: update_my_door_sensor
    trigger:
      - platform: state
        entity_id: binary_sensor.ev1527_08ebb0_0a
        from: 'off'
        to: 'on'
      - platform: state
        entity_id: binary_sensor.ev1527_08ebb0_0e
        from: 'off'
        to: 'on'
    action:
      service_template: input_boolean_turn{% if trigger.to_state.object_id.split('_')[2] == '0a'}on{%else%}off{%endif%}
      data:
         entity_id: input_boolean.my_door_sensor
  1. You can use this input_boolean as internal one if you don’t need to expose it to GUI.
    For GUI it’s better to show a sensor rather than input_boolean so you’ll need to define a template binary sensor for that:
binary_sensor:
  platform: template
    sensors:
      my_door:
        friendly_name: my door
        device_class: 'door'
        value_template: "{{ is_state('input_boolean. my_door_sensor', 'on') }}"

Hope it helps. I could’t check indentation and if it works at the moment but it should.
And ideally it requires some additional safety checks in templates like none/unknown etc.

  service_template: input_boolean_turn{% if trigger.to_state.object_id.split('_')[2] == '0a'}on{%else%}off{%endif%}
  data:
     entity_id: input_boolean.my_door_sensor

I hate to bump an old post but I need help. I managed to get everything set up but since “service_template” has been removed from HA and “service” has taken over, I am unable to figure this out.

What would the action portion look like if I were to use “service” instead. No matter what I try, I get a “Does not match format”

Bump? Can anyone shine some light on this?

I know it is an old topic, but i have figured out and fixed AhmadK’s script:

automation:
  - alias: update_my_door_sensor
    trigger:
      - platform: state
        entity_id: binary_sensor.ev1527_08ebb0_0a
        from: 'off'
        to: 'on'
      - platform: state
        entity_id: binary_sensor.ev1527_08ebb0_0e
        from: 'off'
        to: 'on'
    action:
      service: input_boolean_turn_{% if trigger.to_state.object_id.split('_')[2] == '0a'%}on{%else%}off{%endif%}
      data:
         entity_id: input_boolean.my_door_sensor

What i did:
service_template to service
input_boolean_turn to input_boolean_turn_
and there was a missing ‘%’ char after ‘0a’

But now i have a door open sensor.