Skip to main content

Librería para la gestión de eventos

Project description

habcatev

Libreria python orientada a eventos para habcat.

Quick run

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()

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.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distributions

habcatev-0.0.1-py3.9.egg (8.9 kB view hashes)

Uploaded Source

habcatev-0.0.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

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