从Victron Energy智能设备通过victron-ble发射MQTT事件
项目描述
victron_ble2mqtt
通过victron-ble从Victron Energy智能设备发射MQTT事件
测试与
- 太阳能充电器: SmartSolar MPPT 100/20
- 智能电池分流器
- Raspberry Pi Zero 2 W with Raspberry Pi OS Lite
- Mosquitto MQTT代理
- Home Assistant MQTT集成
Home Assistant屏幕截图
更多截图在此处: https://github.com/jedie/jedie.github.io/blob/master/screenshots/victron-ble2mqtt/README.md
用法
准备
victron_ble
使用 Bleak,Bleak的Linux后端通过DBus与BlueZ通信。因此,您需要安装此软件,例如。
~$ sudo apt install bluez
引导
克隆源代码,只需调用CLI创建Python虚拟环境,例如。
~$ git clone https://github.com/jedie/victron-ble2mqtt.git
~$ cd victron-ble2mqtt
~/victron-ble2mqtt$ ./cli.py --help
应用程序CLI
Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ debug-read Read data from devices and print them. Device keys are used from config file, if │
│ not given. │
│ discover Discover Victron devices with Instant Readout │
│ edit-settings Edit the settings file. On first call: Create the default one. │
│ print-settings Display (anonymized) MQTT server username and password │
│ publish-loop Publish MQTT messages in endless loop (Entrypoint from systemd) │
│ systemd-debug Print Systemd service template + context + rendered file content. │
│ systemd-remove Remove Systemd service file. (May need sudo) │
│ systemd-setup Write Systemd service file, enable it and (re-)start the service. (May need │
│ sudo) │
│ systemd-status Display status of systemd service. (May need sudo) │
│ systemd-stop Stops the systemd service. (May need sudo) │
│ version Print version and exit │
│ wifi-info Just display the WiFi info │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
开发CLI
Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
│ check-code-style Check code style by calling darker + flake8 │
│ coverage Run tests and show coverage report. │
│ fix-code-style Fix code style of all cli_base source code files via darker │
│ install Run pip-sync and install 'cli_base' via pip as editable. │
│ mypy Run Mypy (configured in pyproject.toml) │
│ pip-audit Run pip-audit check against current requirements files │
│ publish Build and upload this project to PyPi │
│ test Run unittests │
│ tox Run tox │
│ update Update "requirements*.txt" dependencies files │
│ update-test-snapshot-files Update all test snapshot files (by remove and recreate all snapshot │
│ files) │
│ version Print version and exit │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
设置设备
首先检测您的设备,例如。
~/victron-ble2mqtt$ ./cli.py discover
...
{
'name': 'SmartSolar HQ2248AM79D',
'address': 'E7:37:97:XX:XX:XX',
'details': {
'path': '/org/bluez/hci0/dev_E7_37_97_XX_XX_XX',
'props': {
'Address': 'E7:37:97:XX:XX:XX',
'AddressType': 'random',
'Name': 'SmartSolar HQ2248AM79D',
'Alias': 'SmartSolar HQ2248AM79D',
'Paired': False,
'Trusted': False,
'Blocked': False,
'LegacyPairing': False,
'RSSI': -89,
'Connected': False,
'UUIDs': [],
'Adapter': '/org/bluez/hci0',
'ManufacturerData': {737: bytearray(b'...')},
'ServicesResolved': False
}
}
}
...
(Hit Ctrl-C to abort)
设备密钥
您需要监控的所有Victron Energy智能设备的设备密钥。
获取密钥的最简单方法:安装官方Victron智能手机应用程序并复制粘贴密钥
- 点击您的设备
- 转到关于
SmartSolar蓝牙接口
的详细页面 - 在
通过蓝牙即时读取
/加密数据
处点击显示
- 通过点击密钥复制连接密钥
(我通过Signal作为“我的笔记”发送密钥,并使用桌面Signal应用程序在我的计算机上接收密钥)
另请参阅: https://community.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html
设置
只需调用edit-settings
命令,例如。
~/victron-ble2mqtt$ ./cli.py edit-settings
至少插入您的MQTT设置和所有设备密钥。
测试
启动发布MQTT无限查找,只需调用publish-loop
命令,例如。
~/victron-ble2mqtt$ ./cli.py publish-loop -vv
设置systemd服务
检查systemd设置
~/victron-ble2mqtt$ ./cli.py systemd-debug
设置服务
~/victron-ble2mqtt$ ./cli.py systemd-setup
在此之后,MQTT发布将运行,并在启动时启动。
检查服务
~/victron-ble2mqtt$ ./cli.py systemd-status
不兼容的更改
0.4.0
您必须编辑您的设置
device_address
(设备MAC地址)已被删除device_key
已被device_keys
(设备密钥列表)所替代
只需插入您想监控的所有Victron Energy智能设备的密钥。
项目详情
下载文件
下载您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
victron_ble2mqtt-0.5.0.tar.gz (75.6 kB 查看哈希值)
构建分布
victron_ble2mqtt-0.5.0-py3-none-any.whl (26.2 kB 查看哈希值)
关闭
victron_ble2mqtt-0.5.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7af8a45bb7e6d79ff16fcfc4726190d8d5425812d40bb4098ef86da5142bd324 |
|
MD5 | 6249294adc5c8f842d9922c4f9977a94 |
|
BLAKE2b-256 | c3e44f2f2b6a053cfabbbaff0f59823e1748879edd4614e14d04050da59cfd2e |
关闭
victron_ble2mqtt-0.5.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | daaebde4472f3841a85e8f163ca69d691af062a58f94c1c2bad9647d38de2d6d |
|
MD5 | cb161634fef71afeabf2e1a2c97a82cd |
|
BLAKE2b-256 | 1d9070dbd5d7fd8ef2b46b7c3ce5eac702347e19324e8086e7555ead7a1bf449 |