Skip to main content

pyBROTlib

Python interface to BROT telescopes, talking to the telescope's TwinCAT/PLC control system over MQTT.

Installation

uv add pybrotlib

Usage

Connect a transport (currently MQTT) to a named telescope and drive it through the BROT object:

import asyncio

from pybrotlib import BROT
from pybrotlib.transport import MQTTTransport


async def main() -> None:
    transport = MQTTTransport(host="localhost", port=1883)
    brot = BROT(transport, "MyTelescope")

    # the transport needs its own task to receive telemetry/publish commands
    asyncio.create_task(transport.run())
    await asyncio.sleep(2)  # give it a moment to connect and receive first telemetry

    await brot.telescope.track(ra=10.5, dec=41.2)
    print(brot.telescope.status)


asyncio.run(main())

transport.telemetry holds the live telemetry tree (see pybrotlib/telemetry.py), which is kept up to date by messages received on <telescope>/.../Telemetry topics and read by the component properties below.

Units

All angles in the telemetry and in the BROTTelescope properties are degrees, including right ascension, and track() takes degrees too. Legacy PLCs (before BROTLib#37) publish RA telemetry in hours; for those, pass MQTTTransport(..., ra_in_hours=True) and pybrotlib converts on receipt. The default (ra_in_hours=False) is for PLCs that already publish degrees. The unit cannot be detected from the message, so set this per telescope, together with the PLC update.

Components

Each BROT instance exposes one component per subsystem, all constructed from the same transport and telescope name:

  • telescope (BROTTelescope) — pointing (track, move), offsets (set_offset_ha, set_offset_dec, set_offset_alt, set_offset_az), power/park/stop/reset, and status (status, motion_state, global_status).
  • focus (BROTFocus) — position, set(focus), powered, referenced.
  • dome (BROTDome) — shutter/tracking state, open, close, start_tracking, stop_tracking, park, reset.
  • roof (BROTRoof) — roll-off roof state, open, close, stop, reset.
  • mirrorcovers (BROTMirrorCovers) — status, open, close.

All commands are fire-and-forget MQTT publishes; callers are expected to poll telemetry (directly, or via the component's status properties) to observe the result.

Weather

pybrotlib.weather publishes live temperature/humidity/pressure onto a telescope's {site}/Telescope/SET topic, for sites where a Python process has access to a weather source. Pick a WeatherSource and hand it to a WeatherPublisher alongside your transport:

from pybrotlib.weather import PyobsWeatherSource, WeatherPublisher
# or: from pybrotlib.weather import FileWeatherSource

source = PyobsWeatherSource("https://weather.example.org")
weather = WeatherPublisher(transport, "MyTelescope", source, interval=60, max_age=300)

asyncio.create_task(weather.run())

max_age (seconds) guards against publishing a stale reading: BROTLib has no way to tell a fresh value from a stale one once it's received, so a source that's alive but returning an old cached reading is caught here instead. A reading missing one field (e.g. a broken pressure sensor) still publishes the fields it does have.

Development

uv sync --group dev
uv run pytest

Telescope readiness

brot.telescope.status maps TELESCOPE.READY_STATE: 0 parked, 0.3 parking, 0.7 initializing, 0.8 calibrating, 1 online, and -1 error. Calibration includes automatic startup positioning; updated PLC controllers publish 1 only once the whole startup has finished. Normal subsequent movement remains online and has its own motion state. Older firmware that publishes 1 early still needs updating.

Metadata

Release files for pyBROTlib 1.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyBROTlib 1.7.1
File Size Uploaded
pybrotlib-1.7.1.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyBROTlib 1.7.1
File Interpreter ABI Platform
pybrotlib-1.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / pybrotlib-1.7.1.tar.gz

Download URL pybrotlib-1.7.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b42ad84b7d2823cb30606b5440b6845bca3a322d3d1de5114c39bd115f3868e2
BLAKE2b-256 checksum
How to use checksums
efa9742562321ac72b50b7b472096a5db977cc936f4b8c84610364a5d7864200
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pybrotlib-1.7.1-py3-none-any.whl

Download URL pybrotlib-1.7.1-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d4ffab2aef77978833c2414c4d200c2062dbe42842d1868b41deb31045b2f80
BLAKE2b-256 checksum
How to use checksums
118e3d434e2a0cc109ad456f26998e934ea7d8419e46a924b7a77b0fb9f4b3cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.7.1 This release

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page