
Flipper Zero Python CLI Wrapper
Flipper Zero Python CLI Wrapper

This release brings the wrapper in line with the current Flipper Zero CLI
(validated on real hardware, firmware unlshd-089e):
info module: flipper.info.device_info() / power_info() /
power_debug_info() (the modern info device / info power commands).power info → info power: flipper.power.info() keeps working and now
reads info power under the hood. Added flipper.power.otg_on()/otg_off().date: use flipper.date.datetime(); parsing was fixed for the current
output format.KB and KiB, read() now returns
full multi-line file content, and exFAT / empty-label cards parse correctly
(fixes #21).NECext,
Kaseikyo, RCA, Pioneer, … are supported automatically (fixes #15). New
flipper.ir.protocols().debug → sysctl debug, subghz tx/rx gained the required
device argument, bt hci_info unchanged.scan, dump,
emulate, field, apdu, raw, mfu) with per-UID Mifare Classic key
cache helpers (import_nfc_keys, write_key_cache).ps (→ top), music_player, nfc detect.$ pip install pyflipper
unlshd-089e)from pyflipper import PyFlipper
# Local serial port
flipper = PyFlipper(com="/dev/ttyACM0")
# OR
# Remote serial2websocket server
flipper = PyFlipper(ws="ws://192.168.1.5:1337")
# TCP
flipper = PyFlipper(tcp='192.168.89.222:22170')
# Info (on current firmware this reads `info power` under the hood)
info = flipper.power.info()
# Poweroff
flipper.power.off()
# Reboot
flipper.power.reboot()
# Reboot in DFU mode
flipper.power.reboot2dfu()
# Toggle the 5V OTG pin on the GPIO header
flipper.power.otg_on()
flipper.power.otg_off()
# Install update from .fuf file
flipper.update.install(fuf_file="/ext/update.fuf")
# Backup Flipper to .tar file
flipper.update.backup(dest_tar_file="/ext/backup.tar")
# Restore Flipper from backup .tar file
flipper.update.restore(bak_tar_file="/ext/backup.tar")
# List installed apps
apps = flipper.loader.list()
# Open app
flipper.loader.open(app_name="Clock")
# Get flipper date (datetime object)
date = flipper.date.datetime()
# Get flipper timestamp
timestamp = flipper.date.timestamp()
# Get device info dict (current firmware `info device`, dot-separated keys)
device_info = flipper.info.device_info()
# Get power info dict (current firmware `info power`)
power_info = flipper.info.power_info()
# Extended power/gauge debug info
power_debug = flipper.info.power_debug_info()
# Legacy `device_info` command (underscore-separated keys, still supported)
legacy_info = flipper.device_info.info()
# Get heap info dict
heap = flipper.free.info()
# Get free_blocks string
free_blocks = flipper.free.blocks()
# Get bluetooth info
bt_info = flipper.bt.info()
Firmware compatibility. This library now targets the current Flipper Zero CLI (firmware 1.x, verified against Unleashed
unlshd-089e). A few legacy commands were removed from official firmware and are therefore no longer available:ps(replaced by the interactivetop),music_player, andnfc detect(NFC is now an interactive sub-shell).power infomoved toinfo power,debugmoved tosysctl debug, andstoragenow reports sizes inKiB— all handled transparently by the wrappers above.
# Get the storage filesystem info
ext_info = flipper.storage.info(fs="/ext")
# Get the storage /ext dict
ext_list = flipper.storage.list(path="/ext")
# Get the storage /ext tree dict
ext_tree = flipper.storage.tree(path="/ext")
# Get file info
file_info = flipper.storage.stat(file="/ext/foo/bar.txt")
# Make directory
flipper.storage.mkdir(new_dir="/ext/foo")
# Read file
plain_text = flipper.storage.read(file="/ext/foo/bar.txt")
# Remove file
flipper.storage.remove(file="/ext/foo/bar.txt")
# Copy file
flipper.storage.copy(src="/ext/foo/source.txt", dest="/ext/bar/destination.txt")
# Rename file
flipper.storage.rename(file="/ext/foo/bar.txt", new_file="/ext/foo/rab.txt")
# MD5 Hash file
md5_hash = flipper.storage.md5(file="/ext/foo/bar.txt")
# Write file in one chunk
file = "/ext/bar.txt"
text = """There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn't anything embarrassing hidden in the middle of text.
"""
flipper.storage.write.file(path=file, text=text)
# Write file using a listener
file = "/ext/foo.txt"
text_one = """There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn't anything embarrassing hidden in the middle of text.
"""
flipper.storage.write.start(file)
time.sleep(2)
flipper.storage.write.send(text_one)
text_two = """All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as
necessary, making this the first true generator on the Internet.
It uses a dictionary of over 200 Latin words, combined with a handful of
model sentence structures, to generate Lorem Ipsum which looks reasonable.
The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.
"""
flipper.storage.write.send(text_two)
time.sleep(3)
# Don't forget to stop
flipper.storage.write.stop()
# Set generic led on (r,b,g,bl)
flipper.led.set(led='r', value=255)
# Set blue led off
flipper.led.blue(value=0)
# Set green led value
flipper.led.green(value=175)
# Set backlight on
flipper.led.backlight_on()
# Set backlight off
flipper.led.backlight_off()
# Turn off led
flipper.led.off()
# Set vibro True or False
flipper.vibro.set(True)
# Set vibro on
flipper.vibro.on()
# Set vibro off
flipper.vibro.off()
# Set gpio mode: 0 - input, 1 - output
flipper.gpio.mode(pin_name=PIN_NAME, value=1)
# Set gpio pin value: 0 - off, 1 - on
flipper.gpio.set(pin_name=PIN_NAME, value=1)
# Read gpio pin value
flipper.gpio.read(pin_name=PIN_NAME)