mqspeak 0.2.1

Creator: bradpython12

Last updated:

Add to Cart

Description:

mqspeak 0.2.1

# mqspeak - MQTT bridgemqspeak is [MQTT](http://mqtt.org/) client which collect data and transformsthem into [ThingSpeak](https://thingspeak.com/) channel updates or [Phant](http://phant.io/)data streams. It is able to handle multiple MQTT connections and independetly updatemultiple channels.This is part of my IoT project. You canread more about it on my [blog](http://buben19.blogspot.com/).## InstallApplication can be installed with following command: $ sudo pip3 install mqspeak## Configurationmqspeak is configured using configuration file specified with `-c` or `--config`option (default `/etc/mqspeak.conf`). This is sample configuration file: [Brokers] Enabled = temperature-broker humidity-broker door-broker [temperature-broker] Host = temperatureBrokerHostname Port = 1883 User = brokerUser Password = brokerPass Topic = sensors/temperature sensors/something [humidity-broker] Host = humidityBrokerHostname Port = 1883 User = brokerUser Password = brokerPass Topic = sensors/humidity [door-broker] Host = doorBrokerHostname Port = 1883 User = brokerUser Password = brokerPass Topic = # [Channels] Enabled = channel1 channel2 channel3 channel4 [channel1] Id = CHANNELID Key = CHANNELKEY Type = thingspeak UpdateRate = 15 UpdateType = blackout UpdateFields = dht-update [channel2] Id = CHANNELID Key = CHANNELKEY Type = thingspeak UpdateRate = 15 UpdateType = buffered UpdateFields = dht-update [channel3] Id = CHANNELID Key = CHANNELKEY Type = thingspeak UpdateRate = 15 UpdateType = average UpdateFields = dht-update [channel4] Id = CHANNELID Key = CHANNELKEY Type = phant UpdateRate = 15 UpdateType = onchange UpdateFields = door-update [dht-update] field1 = humidity-broker sensors/humidity field2 = temperature-broker sensors/temperature [door-update] state = door-broker sensors/doorConfiguration file has two mandatory sections: `[Brokers]` and `[Channels]`, each withone `Enabled` option. These options contains space separated broker and channelsection names.### Broker sectionBroker section has to define one mandatory `[Topic]` option, which is space separatedlist of MQTT topic subscriptions. Full list of possible options in broker section: - `Host` - Broker IP address or hostname (default 127.0.0.1). - `Port` - Broker port (default 1883). - `User` - Username. - `Password` - Password. - `Topic` - Space separated list of topic subscriptions. Mandatory option.### Channel sectionEach channel section has to define `Key`, `UpdateRate` and `UpdateType` options. - `Id` - Channel ID. This field is mandatory for Phant channels. - `Key` - Channel API write key. Mandatory option. - `Type` - Specify channel type. Mandatory option. Following types are supported: - `thingspeak` - [ThinkSpeak](https://thingspeak.com/) channel. - `phant` - [Phant](http://phant.io/) channel. - `UpdateRate` - Channel update interval in seconds. Currently, ThinkSpeak allows interval 15 seconds or greater. Mandatory option. - `WaitInterval` - Maximum interval to wait for remaining data to arrive. When set to zero, wait forever (default). See **Update waiting** for more details. - `UpdateType` - Channel update type. Possible values are `blackout`, `buffered`, `average` and `onchange`. Mandatory option. - `blackout` - Until `UpdateRate` interval is expired, any incoming data are ignored. First data received after interval expiration are sent to ThingSpeak. - `buffered` - Incoming data are buffered during `UpdateRate` interval. After this interval expires, most recent values are immediately sent. - `average` - Similar to `buffered` but mqspeak calculates average value of these data. Any data which cannot be converted into real numbers are ignored. Channel is immediately updated after `UpdateRate` interval is expired. - `onchange` - Data are marked with timestamp and stored in queue. Each item is sent after `UpdateRate` interval expires. **_Not implemented yet._** - `UpdateFields` - Specify section which defines updates for this channel. Mandatory option.#### Update waitingWhen channel update consists of data from multiple sensors, it may happen that onesensor die. By default channel never will be updated until data from all sensors arrives.Inactive sensor causes channel update will be stalled.When update waiting enabled, mqspeak will wait defined amount of seconds and then sendsout even incomplete channel update.Waiting scenario can be divided into following cases: - **`UpdateRate` condition is met but there are no data.** Wait mechanism is not activated until some data arrives. After it received first part of channel update, mqspeak will wait defined time and tries collect remaining data. After `WaitInterval` expires, data will be send. - **Partial data arrives before `UpdateRate` condition is met.** Waiting is delayed until `UpdateRate` condition is met. After it expires and there are still not all required data, waiting is triggered. After `WaitInterval` expires, data will be send. - **All required data are collected before `UpdateRate` condition is met.** There is no need to activate update waiting. Simply send data.### UpdateFields sectionUpdateFields section consists of any number of options. Each option key specifiesfield name. Its value must be space separated name of broker section and topic.For ThinkSpeak channel, only option keys `Field1` ... `Field8` are valid.## Questions - **mqspeak runs in foreground only.** - Yes, there is no double fork combo to run mqspeak in background. I use systemd init and I prefer to run all services as simple systemd units, which runs in foreground. Sorry about that. - **It uses python3. Is python 2.x supported?** - No, I don't plan to support python 2.x.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.