Please provide the GPS data via MQTT. This would allow automations based on sunrise/sunset etc.
You could use the PV-voltage value of any mppt, that is quite reliable for sunrise/sunset ![]()
This is why I run Node Red inside Signal K. Then use a Signal K subscribe node for GPS and create sunrise and sunset timers. Very easy.
Why does Victron strip the time from gps data ? It would be handy to have the gps time over mqtt for when there is no internet
AI gives me this as a script to add to the cerbo to allow it to publish the gps time to mqtt without the cerbo paying any attention to the time data so it doesn’t have conflicting time sources. Because AI is unreliable and sometimes utterly wrong, I was wondering if anyone could cast their knowledgable eyes over this code to see if they think it might work or not, or even if it might actually be bad for the system in some way.
TIA
#!/usr/bin/env python3
import sys
import socket
import json
from gi.repository import GLib
# Inject Victron's native internal library path
sys.path.append('/opt/victronenergy/dbus-systemcalc-py/ext/velib_python')
from vedbus import VeDbusService
class GpsTimeToMqtt:
def __init__(self):
# Register an isolated service name.
# The Cerbo completely ignores this name for timekeeping,
# but the internal MQTT broker will automatically broadcast it.
self.dbus = VeDbusService('com.victronenergy.gpstime.offline0')
# Mandatory identity paths required by the Victron D-Bus architecture
self.dbus.add_path('/Mgmt/ProcessName', __file__)
self.dbus.add_path('/Mgmt/ProcessVersion', '1.0')
self.dbus.add_path('/Mgmt/Connection', 'Passive GPS Loop')
self.dbus.add_path('/DeviceInstance', 99)
self.dbus.add_path('/ProductId', 0xFFFF)
self.dbus.add_path('/ProductName', 'Isolated GPS Time Streamer')
self.dbus.add_path('/Connected', 1)
# The custom path that will appear in MQTT Explorer
self.dbus.add_path('/Time', '00:00:00')
# Poll the local GPS stream once every second
GLib.timeout_add(1000, self._poll_gps)
def _poll_gps(self):
try:
# Connect to the local gpsd instance already running on the Cerbo
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.5)
s.connect(('127.0.0.1', 2947))
# Request the standard JSON telemetry stream
s.sendall(b'?WATCH={"enable":true,"json":true};\n')
data = s.recv(4096).decode('utf-8', errors='ignore')
s.close()
# Parse the text lines looking for the Time-Position-Velocity (TPV) block
for line in data.split('\n'):
if 'class' in line and '"TPV"' in line:
tpv = json.loads(line)
if 'time' in tpv:
# Extract the atomic ISO UTC timestamp string from the satellite data
# Format: "2026-09-30T10:24:00.000Z"
# Write it directly to the D-Bus path so the MQTT broker mirrors it
self.dbus['/Time'] = str(tpv['time'])
break
except Exception:
pass
return True
if __name__ == "__main__":
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
GpsTimeToMqtt()
GLib.MainLoop().run()
I have gps utctime available on my system so maybe it’s a gps device specific thing?
Mine’s a Globalsat BU-353S4 which is apparently compatible with the cerbo and does show up in settings but no “time” which is the only thing I need. The lat., long., speed etc. are no use in my fixed building
I wish I was on the high seas but I’m stuck here.
Where exactly should I look for utctime ?