-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7b78219
Showing
20 changed files
with
1,690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[flake8] | ||
max-line-length = 216 | ||
exclude = | ||
./dbus-mqtt-temperature/ext | ||
extend-ignore: | ||
# E203 whitespace before ':' conflicts with black code formatting. Will be ignored in flake8 | ||
E203 | ||
# E402 module level import not at top of file | ||
E402 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Set default behaviour, in case users don't have core.autocrlf set. | ||
text eol=lf | ||
|
||
# Explicitly declare text files you want to always be normalized and converted | ||
# to native line endings on checkout. | ||
*.ini text | ||
*.md text | ||
*.py text | ||
*.sh text | ||
run text | ||
|
||
# Denote all files that are truly binary and should not be modified. | ||
*.gif binary | ||
*.jpg binary | ||
*.png binary | ||
*.zip binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
## v0.0.1 | ||
Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Manuel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# dbus-mqtt-temperature - Emulates a temperature sensor from MQTT data | ||
|
||
<small>GitHub repository: [mr-manuel/venus-os_dbus-mqtt-temperature](https://github.com/mr-manuel/venus-os_dbus-mqtt-temperature)</small> | ||
|
||
### Disclaimer | ||
|
||
I wrote this script for myself. I'm not responsible, if you damage something using my script. | ||
|
||
|
||
### Purpose | ||
|
||
The script emulates a temperature sensor in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service `com.victronenergy.temperature.mqtt_temperature` with the VRM instance `100`. | ||
|
||
|
||
### Config | ||
|
||
Copy or rename the `config.sample.ini` to `config.ini` in the `dbus-mqtt-temperature` folder and change it as you need it. | ||
|
||
|
||
### JSON structure | ||
|
||
<details><summary>Minimum required</summary> | ||
|
||
```json | ||
{ | ||
"temperature": 22.0 | ||
} | ||
``` | ||
|
||
OR | ||
|
||
```json | ||
{ | ||
"value": 22.0 | ||
} | ||
``` | ||
</details> | ||
|
||
<details><summary>Full</summary> | ||
|
||
```json | ||
{ | ||
"temperature": 22.0, | ||
"humidity": 62.927, | ||
"pressure": 102.104 | ||
} | ||
``` | ||
</details> | ||
|
||
|
||
### Install | ||
|
||
1. Copy the `dbus-mqtt-temperature` folder to `/data/etc` on your Venus OS device | ||
|
||
2. Run `bash /data/etc/dbus-mqtt-temperature/install.sh` as root | ||
|
||
The daemon-tools should start this service automatically within seconds. | ||
|
||
### Uninstall | ||
|
||
Run `/data/etc/dbus-mqtt-temperature/uninstall.sh` | ||
|
||
### Restart | ||
|
||
Run `/data/etc/dbus-mqtt-temperature/restart.sh` | ||
|
||
### Debugging | ||
|
||
The logs can be checked with `tail -n 100 -f /data/log/dbus-mqtt-temperature/current | tai64nlocal` | ||
|
||
The service status can be checked with svstat `svstat /service/dbus-mqtt-temperature` | ||
|
||
This will output somethink like `/service/dbus-mqtt-temperature: up (pid 5845) 185 seconds` | ||
|
||
If the seconds are under 5 then the service crashes and gets restarted all the time. If you do not see anything in the logs you can increase the log level in `/data/etc/dbus-mqtt-temperature/dbus-mqtt-temperature.py` by changing `level=logging.WARNING` to `level=logging.INFO` or `level=logging.DEBUG` | ||
|
||
If the script stops with the message `dbus.exceptions.NameExistsException: Bus name already exists: com.victronenergy.temperatureinverter.mqtt_temperature"` it means that the service is still running or another service is using that bus name. | ||
|
||
### Multiple instances | ||
|
||
It's possible to have multiple instances, but it's not automated. Follow these steps to achieve this: | ||
|
||
1. Save the new name to a variable `driverclone=dbus-mqtt-temperature-2` | ||
|
||
2. Copy current folder `cp -r /data/etc/dbus-mqtt-temperature/ /data/etc/$driverclone/` | ||
|
||
3. Rename the main script `mv /data/etc/$driverclone/dbus-mqtt-temperature.py /data/etc/$driverclone/$driverclone.py` | ||
|
||
4. Fix the script references for service and log | ||
``` | ||
sed -i 's:dbus-mqtt-temperature:'$driverclone':g' /data/etc/$driverclone/service/run | ||
sed -i 's:dbus-mqtt-temperature:'$driverclone':g' /data/etc/$driverclone/service/log/run | ||
``` | ||
5. Change the `device_name` and increase the `device_instance` in the `config.ini` | ||
Now you can install and run the cloned driver. Should you need another instance just increase the number in step 1 and repeat all steps. | ||
### Compatibility | ||
It was tested on Venus OS Large `v2.92` on the following devices: | ||
* RaspberryPi 4b | ||
* MultiPlus II (GX Version) | ||
### Screenshots | ||
<details><summary>MQTT Temperature</summary> | ||
![Temperature - device list](/screenshots/temperature_device-list.png) | ||
![Temperature - device list - mqtt temperature 1](/screenshots/temperature_device-list_mqtt-temperature-1.png) | ||
![Temperature - device list - mqtt temperature 2](/screenshots/temperature_device-list_mqtt-temperature-2.png) | ||
### GuiMods | ||
![Temperature - pages](/screenshots/temperature_pages_guimods.png) | ||
</details> | ||
## Supporting/Sponsoring this project | ||
You like the project and you want to support me? | ||
[<img src="https://github.md0.eu/uploads/donate-button.svg" height="50">](https://www.paypal.com/donate/?hosted_button_id=3NEVZBDM5KABW) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
; CONFIG FILE | ||
; GitHub reporitory: https://github.com/mr-manuel/venus-os_dbus-mqtt-temperature | ||
; remove semicolon ; to enable desired setting | ||
|
||
[DEFAULT] | ||
; Set logging level | ||
; ERROR = shows errors only | ||
; WARNING = shows ERROR and warnings | ||
; INFO = shows WARNING and running functions | ||
; DEBUG = shows INFO and data/values | ||
; default: WARNING | ||
logging = WARNING | ||
|
||
; Device name | ||
; default: MQTT Temperature | ||
device_name = MQTT Temperature | ||
|
||
; Device VRM instance | ||
; default: 100 | ||
device_instance = 100 | ||
|
||
; Specify after how many seconds the driver should exit (disconnect), if no new MQTT message was received | ||
; default: 60 | ||
; value to disable timeout: 0 | ||
timeout = 60 | ||
|
||
; Temperature type | ||
; 0 = battery | ||
; 1 = fridge | ||
; 2 = generic | ||
; default: 2 | ||
type = 2 | ||
|
||
|
||
[MQTT] | ||
; IP addess or FQDN from MQTT server | ||
broker_address = IP_ADDR_OR_FQDN | ||
|
||
; Port of the MQTT server | ||
; default plaintext: 1883 | ||
; default TLS port: 8883 | ||
broker_port = 1883 | ||
|
||
; Enables TLS | ||
; 0 = Disabled | ||
; 1 = Enabled | ||
;tls_enabled = 1 | ||
|
||
; Absolute path to the Certificate Authority certificate file that is to be treated as trusted by this client | ||
;tls_path_to_ca = /data/keys/mosquitto.crt | ||
|
||
; Disables verification of the server hostname in the server certificate | ||
; 0 = Disabled | ||
; 1 = Enabled | ||
;tls_insecure = 1 | ||
|
||
; Username used for connection | ||
;username = myuser | ||
|
||
; Password used for connection | ||
;password = mypassword | ||
|
||
; Topic where the temperature data as JSON string is published | ||
; minimum required JSON payload: {"temperature": 22.0 } or {"value": 22.0} | ||
topic = N/aa00aa00aa00/battery/1/System/Temperature2 |
Oops, something went wrong.