Skip to main content

A small framework for IOT xyz2mqtt daemons

Project description

iot-daemon

A daemon framework for handling different xyz2mqtt applications.

Usage

Using

import iot_daemonize
import iot_daemonize.configuration as configuration

it is possible to configure the framework.

The class configuration.Configuration uses command line arguments and a configuration file. The configuration file overrides the command line arguments.

A default configuration for MQTT services is provided as MqttDaemonConfiguration.

It can be used as follows:

config = configuration.MqttDaemonConfiguration(program ='example2mqtt', description ='Send data to MQTT broker')
# the following line will parse the command line arguments
config.parse_args()
# the following line will parse the configuration file provided as commmand line argument
config.parse_config(config.config)
# print the internal state of configuration values
print(config._config_values)

The framework services can be initialized based on the configuration:

# Initialize MQTT and multi-threading daemon
iot_daemonize.init(config, mqtt = True, daemonize = True)

# Add tasks to the daemon, must be declared as functions
iot_daemonize.daemon.add_task(task1)
iot_daemonize.daemon.add_task(task2)

# Run the framework, this will start the MQTT client and the daemon (for HTTP see below)
iot_daemonize.run()

To run an HTTP server, use the following code:

from bottle import run

def http_server(stop):
    run(server=iot_daemonize.http_server)

# Initialize HTTP and multi-threading daemon
iot_daemonize.init(config, http = True, daemonize = True)

# Add HTTP server task to the daemon
iot_daemonize.daemon.add_task(http_server)

# Run the framework, this will start the HTTP server and the daemon
iot_daemonize.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iot_daemonize-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iot_daemonize-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file iot_daemonize-0.1.0.tar.gz.

File metadata

  • Download URL: iot_daemonize-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for iot_daemonize-0.1.0.tar.gz
Algorithm Hash digest
SHA256 577d6cb60125dcb15ac45d136278307919570850616cf6a38f04dd634a8b4aa4
MD5 dc7fc863b68f7c271f5774510a343ed1
BLAKE2b-256 6321fd8e0ea5dd167942f1803e5c6b60f50a97ab6f29ab066b764bf8a4370423

See more details on using hashes here.

File details

Details for the file iot_daemonize-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iot_daemonize-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for iot_daemonize-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 282d3b4a866fb0fc4818b289abd7bd4a8e4e0ad26d0c57e26ec4d0f1331c1ead
MD5 c206c6f6a4e9b9d4bdc1cc4eb237d058
BLAKE2b-256 1e80a84bbc77a0262f8a596e107c6ad66d039d71ee7604849b2c7db8ed756e09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page