Skip to content

Commit

Permalink
added timeout on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Dec 18, 2023
1 parent 7b78219 commit f6a21d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog

## v0.0.2
* Added: Timeout on driver startup. Prevents problems, if the MQTT broker is not reachable on driver startup

## v0.0.1
Initial release
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
I wrote this script for myself. I'm not responsible, if you damage something using my script.


## 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)


### 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`.
Expand Down Expand Up @@ -116,10 +123,3 @@ It was tested on Venus OS Large `v2.92` on the following devices:
![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)
11 changes: 10 additions & 1 deletion dbus-mqtt-temperature/dbus-mqtt-temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(
self._dbusservice.add_path("/ProductId", 0xFFFF)
self._dbusservice.add_path("/ProductName", productname)
self._dbusservice.add_path("/CustomName", customname)
self._dbusservice.add_path("/FirmwareVersion", "0.0.1 (20230721)")
self._dbusservice.add_path("/FirmwareVersion", "0.0.2 (20231218)")
# self._dbusservice.add_path('/HardwareVersion', '')
self._dbusservice.add_path("/Connected", 1)

Expand Down Expand Up @@ -338,6 +338,15 @@ def main():
logging.warning(
"Waiting since %s seconds for receiving first data..." % str(i * 5)
)

# check if timeout was exceeded
if timeout <= (i * 5):
logging.error(
"Driver stopped. Timeout of %i seconds exceeded, since no new MQTT message was received in this time."
% timeout
)
sys.exit()

sleep(5)
i += 1

Expand Down

0 comments on commit f6a21d7

Please sign in to comment.