Unable to replay subghz .pub file over serial connection

Hello, i have some problems using flipper subghz module over uart link.

I’m trying to use my flipper zero with home assistant to replace a dysfunctional rfplayer for 433 and 868 Mhz frequencies.

I tried to see under subghz a command to emulate a previously recorded raw file but it didn’t found a way to do it over serial.

Is there a possibility to do it programmatically ? is this feature planned ?

1 Like

I absolutely love that you are trying to use the Flipper with HA! A Flipper seems like total overkill but I love the idea. Your project should be doable. I think the we can establish an ssh connection between HA and the Flipper. I’ll need to know how you are connecting the Flipper and what version of Home Assistant you are using. Is it HAOS, supervised, or Docker? On a Raspberry PI or something else. Are you using a dongle or GPIO pins? Much of the Home Assistant information is located under Setting >> About.

I know that using the flipper for this kind of task is a little overkill, but actually it’s the only device that can communicate with my shutters :sweat_smile:

To integrate with HA it’s easy using the uart link :

#!/usr/bin/env python3
import serial
FLIP="/dev/serial/by-id/usb-Flipper_Devices_Inc._Flipper_O*****e_flip_O*****e-if00"
link = serial.Serial(FLIP, 9600)

def r():
    ret=b""
    while True:
        if ret[-3:] == b">: ": # btw i hope flipper dev will add EOM and EOT char instead of expect prompt over serial 
            break
        c = link.read(1)
        ret+=c
    return ret.decode()

def send(c):
    link.write(c.encode()+b"\r\n")
    print(r())

r() # strip flipper ascii art


send("storage list /ext/subghz")
send("subghz decode_raw /ext/subghz/Clo_all.sub")
send("subghz foo")

link.close()

it outputs

storage list /ext/subghz
	[D] assets
	[F] Raw_signal_.sub 254b
	[F] Garage.sub 17319b
	[F] RAW_.sub 12636b
	[F] Op.sub 36985b
	[F] Op_all.sub 9458b
	[F] Up_volet.sub 4444b
	[F] Clo_all.sub 6504b
	[F] Sto_all.sub 6496b
	[F] Ultra_aptechka.sub 180b

>: 
subghz decode_raw /ext/subghz/Clo_all.sub
SubGhz decode_raw: Load_keystore keeloq_mfcodes OK
SubGhz decode_raw: Load_keystore keeloq_mfcodes_user ERROR
Listening at /ext/subghz/Clo_all.sub.

Press CTRL+C to stop

KeeLoq 64bit
Key:23B121******1C01
Fix:0x80****F3    Cnt:0000
Hop:0x74****C4    Btn:8
MF:Unknown
Sn:0x0****F3 

Packets received 1

>: 
subghz foo
Usage:
subghz <cmd> <args>
Cmd list:
	chat <frequency:in Hz>	- Chat with other Flippers
	tx <3 byte Key: in hex> <frequency: in Hz> <te: us> <repeat: count>	- Transmitting key
	rx <frequency:in Hz>	- Receive
	rx_raw <frequency:in Hz>	- Receive RAW
	decode_raw <file_name: path_RAW_file>	- Testing

>: 

i looked at firmware source code that handle the serial connection
https://github.com/flipperdevices/flipperzero-firmware/tree/dev/applications/services/cli
https://github.com/flipperdevices/flipperzero-firmware/blob/dev/applications/main/subghz/subghz_cli.c
and it doesn’t seems to have an “emulate” option to fire the recorded signal.

So that’s why i requested an update to add with option in cli application.
Maybe if i have time in the next weeks i’ll fork the firmware to add this option and the HA plugin that uses it.

1 Like

I can establish a link over bluetooth or usb cable from HA to the flipper, i don’t think an SSH connection is easy to setup to access the flipper ( you need to use stm32 libraries that handle correctly SSH kex protocol and ciphers for crypto on flipper it’s difficult to add i think ).
BTW i use the supervised version of HA, the last one, “Home Assistant 2023.2.4” on a x86_64 dedicated server at home.

1 Like

Have you looked in the Sonoff RF bridge flashed with Tasmota and Portisch?

Yes it’s a good solution for 433Mhz frequency, but my rolling shutters are using 868.3 Mhz.

1 Like

The Sonoff RF Bridge works great for me. I forgot you mentioned needing 868. The radio in the Flipper(CC1101) can be bought pretty cheaply. It sounds like it might be usable with HA through homegear. There is also the rflink project.