Using Conrad RSL sockets with RFXCom and Home Assistant
I wanted to get my Conrad RSL sockets (RSL3660R-UK) working with Home Assistant
The user guide for the RFXCom describes how to get them working, but I needed to work out what the device id for Home Assistant. Luckily Home Assistant just uses the parsing of a RFXtrx packet to work this out, so I just had to work out the format. I used the user guide and pyRFXtrx code to work it out. The bytes break down as follows:
- 09 - length
- 13 - lighting 4
- 00 - subtype = PT2262
- 04 - sequence number
- XX - cmd 1 - Group:
- 15 - Group I
- 45 - Group II
- 51 - Group III
- 54 - Group IV
- YY - cmd 2 - Unit:
- 15 - Unit 1
- 45 - Unit 2
- 51 - Unit 3
- 54 - Unit 4
- ZZ - cmd 3 - State:
- 55 - On
- 54 - Off
- 01 - high byte of pulse timing (425ms)
- A9 - low byte of pulse timing (425ms)
- 00 - seems to always be null
# Group I, unit 1 - on echo -ne '\x09\x13\x00\x04\x15\x15\x55\x01\xA9\x00' > /dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1WRPM1W-if00-port0Trying to work out the correct stack of escaping of text in both YAML and shell (which will be dash on Ubuntu and Debian systems) makes it far easier to write a script to do this. So I put the following into /home/hass/bin/switch_rsl.sh:
#!/bin/bash set -e # Path to your RFXCOM device RFXCOM_DEV=/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1WRPM1W-if00-port0 # Number of times to send the command REPEAT=2 # Pause between each command being sent REPEAT_DELAY=0.2 function print_usage() { echo "Usage: $0 [I|II|III|IV] [1|2|3|4] [On|Off]" } case $1 in I) GROUP=15 ;; II) GROUP=45 ;; III) GROUP=51 ;; IV) GROUP=54 ;; *) echo "Invalid group: $1" print_usage exit 1 ;; esac case $2 in 1) UNIT=15 ;; 2) UNIT=45 ;; 3) UNIT=51 ;; 4) UNIT=54 ;; *) echo "Invalid unit: $2" print_usage exit 1 ;; esac case $3 in On|on|1) STATE=55 ;; Off|off|0) STATE=54 ;; *) echo "Invalid state: $3" print_usage exit 1 ;; esac for V in 1 .. $REPEAT do echo -ne "\\x09\\x13\\x00\\x04\\x$GROUP\\x$UNIT\\x$STATE\\x01\\xA9\\x00" > "$RFXCOM_DEV" sleep $REPEAT_DELAY doneThen the configuration for Home Assistant is just:
switch: - platform: command_line switches: rsl_i_1: command_on: "/home/hass/bin/switch_rsl.sh I 1 On" command_off: "/home/hass/bin/switch_rsl.sh I 1 Off" rsl_i_2: command_on: "/home/hass/bin/switch_rsl.sh I 2 On" command_off: "/home/hass/bin/switch_rsl.sh I 2 Off" rsl_i_3: command_on: "/home/hass/bin/switch_rsl.sh I 3 On" command_off: "/home/hass/bin/switch_rsl.sh I 3 Off"
No comments:
Post a Comment