Git Product home page Git Product logo

indi-mqtt's Introduction

indi-mqtt

indi-mqtt is MQTT publisher for INDI server. It reads properties of INDI devices and publishes them using MQTT topics.

[NOTE] Due to the recent changes in pyindi-client and annouced end of life of pyindi-client library, this project is not maintained anymore. It will be replaced by native c++ driver soon.

Installation

Use git to clone source files or download and install indi-mqtt debian package from https://www.astroberry.io/repo/pool/main/i/indi-mqtt/

sudo apt update
sudo apt install python-setuptools python-dev libindi-dev swig libcfitsio-dev libnova-dev
sudo dpkg - i indi-mqtt_1.0.x_all.deb

Configuration

Default configuration file for indi-mqtt is located in /etc/indi-mqtt.conf

MQTT tree

MQTT messages published by indi-mqtt are organized in the following hierarchy:
observatory/#
observatory/status - observatory status (ON|OFF) - equals INDI server status
observatory/json - all INDI properties in a single JSON message
observatory/general/#
observatory/telescope/#
observatory/ccd/#
observatory/guider/#
observatory/focuser/#
observatory/filter/#
observatory/dome/#
observatory/gps/#
observatory/weather/#
observatory/ao/#
observatory/dustcap/#
observatory/lighbox/#
observatory/detector/#
observatory/rotator/#
observatory/spectrograph/#
observatory/aux/#

You can change 'observatory' by setting MQTT_ROOT in /etc/indi-mqtt.conf or invoking command with --mqtt_root argument.
# is a wildcard selector, which returns all properties subsequent to path. If you want to access specific property, use full topic path e.g. observatory/telescope/telescope_simulator/telescope_info/telescope_focal_length will give you info about focal length of telescope simulator.
You can list all available INDI properties by invoking python3 indi-mqtt.py --list_topics or python3 indi-mqtt.py -l for short. JSON output is available if you set MQTT_JSON=True or by invoking python3 indi-mqtt.py --mqtt_json or python3 indi-mqtt.py -j for short. If you have multiple device of a type, they will be listed as a type's subtopics e.g. observatory/focuser/indi_simulator_focus/# and observatory/focuser/indi_moonlite_focus/#

INDI properties polling

INDI properties can be refreshed in two modes:

  • Auto refresh with time configurable by MQTT_POLLING variable in /etc/indi-mqtt.conf or invoking command with --mqtt_polling argument
  • Manual refresh by publishing numeric value to MQTT_ROOT/poll topic (by default it is observatory/poll). Any positive value sets refresh time in seconds. 0 means manual polling

In both modes all INDI properties are returned on poll. If you want to get a specific INDI property, subscribe to it using full topic path e.g. observatory/telescope/telescope_simulator/telescope_info/telescope_focal_length

Help

To get help run python3 /usr/bin/indi-mqtt.py --help or python3 /usr/bin/indi-mqtt.py -h for short

Issues

File any issues on https://github.com/rkaczorek/indi-mqtt/issues

indi-mqtt's People

Contributors

rkaczorek avatar skolarianer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

indi-mqtt's Issues

TypeError: 'SwigPyObject' object is not iterable

Latest Astroberry, I've tried to run python3 /usr/bin/indi-mqtt.py --list_topics and got this:

`
➜ python3 /usr/bin/indi-mqtt.py --list_topics
indi-mqtt: Using configuration from /etc/indi-mqtt.conf
indi-mqtt: Starting in auto refresh mode in every 10 seconds.
indi-mqtt: Creating an instance of INDI client
indi-mqtt: Connected to MQTT server localhost:1883
indi-mqtt: Subscribed to observatory/poll topic at MQTT server localhost:1883
INDI::BaseClient::connectServer: creating new connection...
INDI::BaseClient::connectServer: Already connected.
--- Logging error ---
Traceback (most recent call last):
File "/usr/bin/indi-mqtt.py", line 461, in
observatory_json = getJSON(devices)
File "/usr/bin/indi-mqtt.py", line 265, in getJSON
for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.7/logging/init.py", line 1034, in emit
msg = self.format(record)
File "/usr/lib/python3.7/logging/init.py", line 880, in format
return fmt.format(record)
File "/usr/lib/python3.7/logging/init.py", line 619, in format
record.message = record.getMessage()
File "/usr/lib/python3.7/logging/init.py", line 380, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/usr/bin/indi-mqtt.py", line 471, in
logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
--- Logging error ---
Traceback (most recent call last):
File "/usr/bin/indi-mqtt.py", line 461, in
observatory_json = getJSON(devices)
File "/usr/bin/indi-mqtt.py", line 265, in getJSON
for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.7/logging/init.py", line 1034, in emit
msg = self.format(record)
File "/usr/lib/python3.7/logging/init.py", line 880, in format
return fmt.format(record)
File "/usr/lib/python3.7/logging/init.py", line 619, in format
`

Feature request - Poll on demand

I know it would mean adding a subscribe to your python code but could we have a method to demand a poll at "root" and "devices" level. This would allow the polling to be set off(poll=0) or very long intervals.

e.g. Observatory/poll/ 0 or 1 (yes or no) mean produce data as at present - all

Observatory/telescope/poll just telescope data

When your publisher gets a request to poll it then resets the poll flag.

Have indi-mqtt.py report client name to mqtt broker

Another feature request for you. Hope I'm not too annoying.

When I connect to the MQTT Broker (Eclipse MQTT) from MQTT Explorer, it passes its client name to the broker so when I look in the logs, I can tell what client was connecting:

1590812963: New client connected from 192.168.1.86 as mqtt-explorer-7ec6fbe1 (p2, c1, k60).
1590812979: New connection from 192.168.1.86 on port 1883.
1590812979: New client connected from 192.168.1.86 as auto-8095885E-916F-4FC8-28BB-C6C43779BB78 (p2, c1, k60).
1590812979: Client auto-8095885E-916F-4FC8-28BB-C6C43779BB78 disconnected.

The connection "192.168.1.86 as auto-8095..." is from indi-mqtt.py, would it be possible for it to identify itself in the same way that mqtt-explorer does in the first log entry?

broker connection being reset ?????

Really for information at this stage:-
But when I connect via MQTTFX it connects ok and starts display info as expected I guess. But hen it disconnects - might be a time out issue with MQTTFX

dump from MQTTFX

instructions fail

  1. the tar create different directory - so did a mv to pyindi-client

  2. sudo python etc fails

cd pyindi-client
astroberry@astroberry:~/pyindi-client $ sudo python3 setup.py install
Unable to find libindiclient.a in ['/usr/lib/arm-linux-gnueabihf', '/usr/lib', '/usr/lib64', '/lib', '/lib64', '/usr/local/lib']
Please specify a path where to find libindiclient.a in the setup.py script
Exiting

dont think i missed anything

indi-mqtt fails because of s

Hi all,
I think the project is a very good, idea, unfortunately, I haven't been able to run the main script, because of the weird behaviour, potentially related to swig bindings:

Here is an excerpt in case someone can read through those cryptics error messages;

 /usr/bin/python3 /usr/bin/indi-mqtt.py
indi-mqtt: Using configuration from /etc/indi-mqtt.conf
indi-mqtt: Starting in auto refresh mode in every 10 seconds.
indi-mqtt: Creating an instance of INDI client
INDI::BaseClient::connectServer: creating new connection...
indi-mqtt: Connected to MQTT server 192.168.0.48:1883
indi-mqtt: Subscribed to observatory/poll topic at MQTT server 192.168.0.48:1883
INDI::BaseClient::connectServer: Already connected.
indi-mqtt: Connected to INDI server localhost:7624
--- Logging error ---
Traceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 461, in <module>
    observatory_json = getJSON(devices)
  File "/usr/bin/indi-mqtt.py", line 265, in getJSON
    for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/bin/indi-mqtt.py", line 471, in <module>
    logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
--- Logging error ---
Traceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 461, in <module>
    observatory_json = getJSON(devices)
  File "/usr/bin/indi-mqtt.py", line 265, in getJSON
    for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/bin/indi-mqtt.py", line 471, in <module>
    logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
--- Logging error ---
Traceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 461, in <module>
    observatory_json = getJSON(devices)
  File "/usr/bin/indi-mqtt.py", line 265, in getJSON
    for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/bin/indi-mqtt.py", line 471, in <module>
    logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
--- Logging error ---
Traceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 461, in <module>
    observatory_json = getJSON(devices)
  File "/usr/bin/indi-mqtt.py", line 265, in getJSON
    for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/bin/indi-mqtt.py", line 471, in <module>
    logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
--- Logging error ---
Traceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 461, in <module>
    observatory_json = getJSON(devices)
  File "/usr/bin/indi-mqtt.py", line 265, in getJSON
    for property in properties:
TypeError: 'SwigPyObject' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/bin/indi-mqtt.py", line 471, in <module>
    logger.error("Unexpected error timed polling INDI server", err)
Message: 'Unexpected error timed polling INDI server'
Arguments: (TypeError("'SwigPyObject' object is not iterable"),)
swig/python detected a memory leak of type 'INDI::BaseDevice::Properties *', no destructor found.
^CTraceback (most recent call last):
  File "/usr/bin/indi-mqtt.py", line 450, in <module>
    time.sleep(1)
KeyboardInterrupt

pip freeze | grep pyindi
pyindi-client==0.2.8

indiserver --version
2022-01-07T20:52:01: startup: indiserver --version
Usage: indiserver [options] driver [driver ...]
Purpose: server for local and remote INDI drivers
INDI Library: 1.9.3
Code v1.9.3-39-gce7416338. Protocol 1.7.

Thank you in advance for your help

FR: Support of two or more devices per category

It seems that only the values of one device per category are published. If I use e.g. Pegasus PPB – which is recognized as a weather device – and OpenWeatherMap simultaneously only the data of the PPB is published.
It'd be great if the values of all connected devices were published.

ability to provide mqtt username/password

I'm using indi-mqtt in in conjunction with my home automation system, Home Assistant. Within Home Assistant I have Eclipse-MQTT running and configured for specific usernames and passwords. I don't see a way to specify them either on the command line or from within the config file. Is this something you can add?

Question :- Changes to Indi properties

Are you supposed to be able to change (set) properties - e.g. ISO via MQTT ?
Tried it and it changed for 1 sec then reverts back to original setting nothing changes in CCD!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.