Skip to main content

Librería para la gestión de eventos

Project description

habcatev

Libreria python orientada a eventos para habcat.

Quick start

Ejemplo simple 1

import habcatev,time
import random 

class SimpleExample(habcatev.device.Device.Device):
    """Ejemplo simple en el que se produce y consume"""
    def __init__(self):
        super(SimpleExample, self).__init__()
        # El dispositivo se subscribe a todos los topics
        self.setSubscriptionArr(['#'])

    def on_event(self,topic,data):
        # Lanzamos este codigo cuando se produce un evento
        self.log.logger.info("Ha llegado: Topic:" + topic + "  Data: " + data)

    def loop(self):
        # Suponemos que leemos el valor de un sensor y lo escribimos 
        # en un topic
        self.log.logger.info('Enviando un mensaje a mqtt ...')
        self.send('mitopico1', random.uniform(10.5, 75.5))
        time.sleep(5)

SimpleExample().run()

Ejemplo con configuración externa del dispositivo.

import habcatev,time
import random 

class SimpleExample(habcatev.device.Device.Device):
    def __init__(self):
        super(SimpleExample, self).__init__(
            description='Ejemplo simple en el que se produce y consume')
        # Nos subscribimos a los topics del fichero de configuracion
        self.setSubscriptionArr(self.config['ejemplo2']['subscribe'])

    def on_event(self,topic,data):
        # Lanzamos este codigo cuando se produce un evento
        self.log.logger.info("Ha llegado: Topic:" + topic + "  Data: " + data)

    def loop(self):
        # Suponemos que leemos el valor de un sensor y lo escribimos en un topic
        self.log.logger.info('Enviando un mensaje a mqtt ...')
        self.send(self.config['ejemplo2']['publish'], random.uniform(10.5, 75.5))
        time.sleep(5)

SimpleExample()
python3 example2.py --help
python3 example2.py --config 'example2.yaml' --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

habcatev-0.0.4.tar.gz (4.4 kB view details)

Uploaded Source

Built Distributions

habcatev-0.0.4-py3.9.egg (10.2 kB view details)

Uploaded Source

habcatev-0.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file habcatev-0.0.4.tar.gz.

File metadata

  • Download URL: habcatev-0.0.4.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.1

File hashes

Hashes for habcatev-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b579ba92b674c74bb3915197a3f82f880f0d5db4d736685ac75631dcb55c7b5a
MD5 459f7883043df08e82bd9319ff974412
BLAKE2b-256 09aac447486e48bad2ce31dcba6e3c72fa56d59d185ff9ad62905e552c2c951c

See more details on using hashes here.

File details

Details for the file habcatev-0.0.4-py3.9.egg.

File metadata

  • Download URL: habcatev-0.0.4-py3.9.egg
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.1

File hashes

Hashes for habcatev-0.0.4-py3.9.egg
Algorithm Hash digest
SHA256 d1c7ecd6291e493dee60fadd1d27a3a688f9798030329d971d180d20522c2735
MD5 268b4f8135f69ccf5795528f9039850c
BLAKE2b-256 fd528a69cf1f0186d9a818fa38ff316f235f9d225e0447b164cfbae96860a23f

See more details on using hashes here.

File details

Details for the file habcatev-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: habcatev-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.1

File hashes

Hashes for habcatev-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa1a856ffe75825c8c388ce345e9e3ae3406790e27a0801fdda62ccaac915fd1
MD5 31eb01730d08a85d152cc0b5026cae84
BLAKE2b-256 87c0b2fe585bc27de25474f081f5aae7da46a69a4052f569f3e64291b97d9f03

See more details on using hashes here.

Supported by

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