Files
venus/axiom-nmea/raymarine_nmea/venus_dbus/navigation.py
dev 9756538f16 Initial commit: Venus OS boat addons monorepo
Organizes 11 projects for Cerbo GX/Venus OS into a single repository:
- axiom-nmea: Raymarine LightHouse protocol decoder
- dbus-generator-ramp: Generator current ramp controller
- dbus-lightning: Blitzortung lightning monitor
- dbus-meteoblue-forecast: Meteoblue weather forecast
- dbus-no-foreign-land: noforeignland.com tracking
- dbus-tides: Tide prediction from depth + harmonics
- dbus-vrm-history: VRM cloud history proxy
- dbus-windy-station: Windy.com weather upload
- mfd-custom-app: MFD app deployment package
- venus-html5-app: Custom Victron HTML5 app fork
- watermaker: Watermaker PLC control UI

Adds root README, .gitignore, project template, and per-project
.gitignore files. Sensitive config files excluded via .gitignore
with .example templates provided.

Made-with: Cursor
2026-03-16 17:04:16 +00:00

103 lines
3.2 KiB
Python

"""
Navigation D-Bus service for Venus OS.
Publishes navigation data not covered by the standard GPS or Meteo
services to the Venus OS D-Bus, making it available to custom addons
via D-Bus and MQTT.
D-Bus paths:
/Heading - True heading in degrees (0-360)
/Depth - Depth below transducer in meters
/WaterTemperature - Water temperature in Celsius
"""
import logging
from typing import Any, Dict, Optional
from .service import VeDbusServiceBase
from ..data.store import SensorData
logger = logging.getLogger(__name__)
class NavigationService(VeDbusServiceBase):
"""Navigation D-Bus service for Venus OS.
Publishes heading, depth, and water temperature from Raymarine
sensors to the Venus OS D-Bus. These values are decoded from the
Raymarine protocol but don't map to standard Venus OS service types,
so they are grouped under a custom 'navigation' service.
Example:
sensor_data = SensorData()
nav_service = NavigationService(sensor_data)
nav_service.register()
# In update loop:
nav_service.update()
"""
service_type = "navigation"
product_name = "Raymarine Navigation"
product_id = 0xA143
MAX_DATA_AGE = 10.0
def __init__(
self,
sensor_data: SensorData,
device_instance: int = 0,
custom_name: Optional[str] = None,
):
"""Initialize Navigation service.
Args:
sensor_data: SensorData instance to read values from
device_instance: Unique instance number (default: 0)
custom_name: Optional custom display name
"""
super().__init__(
device_instance=device_instance,
connection="Raymarine LightHouse Navigation",
custom_name=custom_name,
)
self._sensor_data = sensor_data
def _get_paths(self) -> Dict[str, Dict[str, Any]]:
"""Return navigation-specific D-Bus paths."""
return {
'/Heading': {'initial': None},
'/Depth': {'initial': None},
'/WaterTemperature': {'initial': None},
}
def _update(self) -> None:
"""Update navigation values from sensor data."""
data = self._sensor_data
heading_stale = data.is_stale('heading', self.MAX_DATA_AGE)
depth_stale = data.is_stale('depth', self.MAX_DATA_AGE)
temp_stale = data.is_stale('temp', self.MAX_DATA_AGE)
if not heading_stale and data.heading_deg is not None:
self._set_value('/Heading', round(data.heading_deg, 1))
else:
self._set_value('/Heading', None)
if not depth_stale and data.depth_m is not None:
self._set_value('/Depth', round(data.depth_m, 2))
else:
self._set_value('/Depth', None)
if not temp_stale and data.water_temp_c is not None:
self._set_value('/WaterTemperature', round(data.water_temp_c, 1))
else:
self._set_value('/WaterTemperature', None)
has_any_data = (
(not heading_stale and data.heading_deg is not None) or
(not depth_stale and data.depth_m is not None) or
(not temp_stale and data.water_temp_c is not None)
)
self.set_connected(has_any_data)