Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fhempy

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fhempy

Python binding for FHEM to support Python modules

  • 0.1.743
  • PyPI
  • Socket score

Maintainers
1

Download python Version LastCommit BuyCoffee

Attention (12/2023)

Please make sure that you have python3-venv installed before you do an update!

sudo apt install python3-venv

fhempy

fhempy allows the usage of Python 3 (NOT 2!) language to write FHEM modules. Python 3.9 or higher is required, therefore I recommend using bullseye.

This repository includes following working modules:

ModuleDescription
aktionsfinderKeep informed about product promotions
alphaesscloudAlpha ESS inverter cloud integration
arp_presenceARP based presence detection, works also for iOS
ble_monitorSupports a lot of BLE devices
ble_presencePresence detection incl. RSSI for Bluetooth Low Energy
ble_resetResets all Bluetooth interfaces every X hours
bt_presencePresence detection incl. RSSI for Bluetooth
blue_connectBlue Connect
ddnssdeDynamic DNS updater for free ddnss.de service
discover_mdnsDiscover mDNS (e.g. googlecast) devices
discover_bleDiscover Bluetooth LE devices
discover_upnpDiscover UPnP devices
dlna_dmrControl DLNA MediaRenderer devices
energie_gv_atRetrieve current Austrian energy status
eq3btControl EQ3 Bluetooth thermostat
erelax_vaillantControl eRelax Vaillant
esphomeInstalls and starts the ESP Home dashboard for easy ESP Home device management
fusionsolarRetrieve data from FusionSolar
geizhalsRetrieve prices from geizhals
gfprobtControl GF Pro Bluetooth irrigation control
github_backupBackup FHEM config to github
github_restoreRestore FHEM config from github
goodweGet data from GoodWe inverters
googlecastControl Cast devices and stream Spotify
google_weatherRetrieve weather from Google
gree_climateControl gree HVAC devices
helloworldHello World example for developers to start writing their own module
homekitControl homekit devices
huawei_modbusRetrieve data from Huawei inverter, requires Python 3.10 or higher
ikosCheck prices for ikos resorts
kia_hyundaiControl your Kia/Hyundai car
merossControl Meross devices
miscaleXiaomi Mi Scale V1/2 support
mifloraXiaomi BLE Plant Sensor
miioControl Xiaomi WiFi devices
mitempXiaomi BLE Temperature/Humidity Sensor
mqtt_ha_discoverySupport HomeAssistant MQTT discovery
nefitControl nefit devices
nespresso_bleNespresso Bluetooth coffee machine
object_detectionTensorFlow Lite object detection
piclockCreate a LED clock with MAX7219
prusalinkPrusa 3D printer, requires Python 3.10 or higher
pyit600Control Salus iT600 devices
rct_powerRCT Power inverter
ringRing doorbell/chime/cam
tibberGet consumption data from tibber
seatconnectControl your Seat/Cupra car
spotifyControl Spotify Connect and use FHEM as Spotify Connect player
skodaconnectControl your skoda car
tuyaRecommended: Control tuya devices localy incl. real-time updates (only WiFi devices)
tuya_cloudControl tuya devices via cloud incl. real-time updates (WiFi & ZigBee)
tuya_smartlifeRecommended: Control tuya devices via cloud incl. real-time updates (WiFi & ZigBee)
waremaControl Warema devices
websitetestsDo some basic website checks
wienerlinienWiener Linien departure times
wienernetze_smartmeterRetrieve data from Wiener Netze smartmeter
xiaomi_gateway3Xiaomi Gateway V3 (only V3!)
xiaomi_tokensRetrieve all Xiaomi Tokens from Cloud
volvoRetrieve infos from your Volvo car (only new API)
volvo_software_updateGet notified about Volvo software updates
zappiZappi charger
zigbee2mqttInstall, update and run Zigbee2MQTT server

Installation

Python >=3.9 is required, Python 2 won't work! Python 3.11 or higher recommended.

Console

Debian 11/12 (Bullseye/Bookworm)

Copy & paste this command if you are running Debian Bullseye.

sudo apt install python3 python3-pip python3-dev python3-venv libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libglib2.0-dev libdbus-1-dev bluez libbluetooth-dev git libprotocol-websocket-perl
Others

Use the following 2 commands if you run Debian 10 (Buster) or older (e.g. stretch, jessie, ...).

sudo apt install python3 python3-pip python3-dev libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libglib2.0-dev libdbus-1-dev bluez libbluetooth-dev git
sudo cpan Protocol::WebSocket

FHEM

update add https://raw.githubusercontent.com/fhempy/fhempy/master/controls_pythonbinding.txt
update
shutdown restart
define fhempy_local BindingsIo fhempy

Wait a few minutes until fhempy is installed. This might take up to 15 minutes! fhempy_local will show up with a green circle when finished. All further requirements are installed automatically via pip as soon as the specific module is used the first time.

Usage in FHEM (examples)

This are just a few examples for some modules, please see the modules readme linked in the table above for more details

  • define castdevice fhempy googlecast "Living Room"
  • define eq3bt fhempy eq3bt 00:11:22:33:44:66:77
  • define upnp fhempy discover_upnp

fhempy peers (e.g. extend Bluetooth range)

fhempy allows to run modules locally (same device as FHEM runs on) or on remote peers. Those remote peers only make sense if you want to extend the range of bluetooth or want to distribute the load of some modules to other more powerfull devices (e.g. video object detection).

Peer setup (short version)

Only on remote peers, do not run this commands on the FHEM instance. Run this commands with user "pi".

### WARNING: DO THIS COMMAND ONLY ON REMOTE PEER, NOT ON YOUR FHEM INSTANCE ###
# systemd service installation
curl -sL https://raw.githubusercontent.com/fhempy/fhempy/master/install_systemd_fhempy.sh | sudo -E bash -

Peer setup (long version)

Only needed if you didn't run Peer setup (short version). The following steps are only needed if you want to install fhempy on a remote peer, you should not run them on your FHEM installation.

  • Setup virtual environment for fhempy: python3 -m venv .fhempy/fhempy_venv
  • Activate venv: source .fhempy/fhempy_venv/bin/activate
  • Install fhempy with user pi: pip3 install --upgrade fhempy
  • Make sure your main fhempy instance (within FHEM) is running
  • Test fhempy by just running it with user pi, type fhempy and enter. Wait a few seconds until it gets discovered and you see the incoming FHEM connection.
  • Systemd configuration for autostart
    • curl -sL https://raw.githubusercontent.com/fhempy/fhempy/master/install_systemd_fhempy.sh | sudo -E bash -
    • fhempy is run with user pi, you can change that in the fhempy.service file in /etc/systemd/system/
  • FHEM configuration
    • The remote peer is autodiscovered and will show up in FHEM as device e.g. fhempy_peer_192_168_1_50
    • You can move any device to the remote peer by changing the IODev of the device.
    • If autodiscovery doesn't work (it's based on zeroconf), you can define it with define fhempy_peer_IP BindingsIo IP:15733 fhempy

Log file

journalctl -u fhempy.service -f

Update

Just do set remote_pybinding update and the remote peer will install the new package via pip and restart afterwads.

Functionality

10_BindingsIo

This module is a DevIo device which builds a language neutral communicaton bridge in JSON via websockets.

10_fhempyServer

This module just starts the fhempy server instance

10_fhempy

This module is used as the bridge to BindingsIo. It calls BindingsIo with IOWrite.

fhempy

This is the Python server instance which handles JSON websocket messages from BindingsIo. Based on the message it executes the proper function and replies to BindingsIo via websocket.

Call flow

This example shows how Define function is called from the Python module.

  1. define castdevice fhempy googlecast "Living Room"
  2. fhempy sends IOWrite to BindingsIo
  3. BindingsIo sends a JSON websocket message to fhempy
  4. fhempy loads the corresponding module (e.g. googlecast), creates an instance of the object (e.g. googlecast) and calls the Define function on that instance
  5. Define function is executed within the Python context, as long as the function is executed, FHEM waits for the answer the same way as it does for Perl modules
  6. Python Define returns the result via JSON via websocket to BindingsIo

At any time within the functions FHEM functons like readingsSingleUpdate(...) can be called by using the fhem.py module (fhem.readingsSingleUpdate(...)). There are just a few functions supported at the moment.

Flow Chart

Write your own module

Check helloworld example for writing an own module. Be aware that no function which is called from FHEM is allowed to run longer than 1s. In general no blocking code should be used with asyncio. If you want to call blocking code, use utils.run_blocking.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc