Skip to main content

Mycroft Messagebus Client

Project description

Mycroft Bus Client

This module is a simple interface for the mycroft messagebus and can be used to connect to mycroft, send messages and react to messages sent by the Mycroft system.

MycroftBusClient()

The MycroftBusClient() object can be setup to connect to any host and port as well as any endpont on that host. this makes it quite versitile and will work on the main bus as well as on a gui bus. If no arguments are provided it will try to connect to a local instance of mycroftr core on the default endpoint and port.

Message()

The Message object is a representation of the messagebus message, this will always contain a message type but can also contain data and context. Data is usually real information while the context typically contain information on where the message originated or who the intended recipient is.

Message('MESSAGE_TYPE', data={'meaning': 42}, context={'origin': 'A.Dent'})

Examples

Below are some a couple of simple cases for sending a message on the bus as well as reacting to messages on the bus

Sending a message on the bus.

from mycroft_bus_client import MessageBusClient, Message

print('Setting up client to connect to a local mycroft instance')
client = MessageBusClient()
client.run_in_thread()

print('Sending speak message...')
client.emit(Message('speak', data={'utterance': 'Hello World'}))

Catching a message on the messagebus

from mycroft_bus_client import MessageBusClient, Message

print('Setting up client to connect to a local mycroft instance')
client = MessageBusClient()

def print_utterance(message):
    print('Mycroft said "{}"'.format(message.data.get('utterance')))


print('Registering handler for speak message...')
client.on('speak', print_utterance)

client.run_forever()

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

mycroft-messagebus-client-0.9.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

mycroft_messagebus_client-0.9.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file mycroft-messagebus-client-0.9.1.tar.gz.

File metadata

  • Download URL: mycroft-messagebus-client-0.9.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 importlib_metadata/3.7.3 pkginfo/1.6.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3

File hashes

Hashes for mycroft-messagebus-client-0.9.1.tar.gz
Algorithm Hash digest
SHA256 308612aeedf007f4d71ab43dd738ca5912be5d39a2dc96fe5f08bd6b73c07f37
MD5 836703645ac79fb80111cc7ffe75ca08
BLAKE2b-256 cf6f1ba7f9db76509e650b9e1b4042318d8e662e7b12e3f6e1a3725339f152f8

See more details on using hashes here.

File details

Details for the file mycroft_messagebus_client-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: mycroft_messagebus_client-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 importlib_metadata/3.7.3 pkginfo/1.6.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3

File hashes

Hashes for mycroft_messagebus_client-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e04d14c805a365bb10231eb0e651ed85699b1e07d18f2da4e955c5d1d3fe6fa7
MD5 8f284d6d09537d72884227ce0ea5c55b
BLAKE2b-256 e3a3fa4abb898560699d10d718ed948a9442ed1244aaf01502ab477a7fb07260

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