Skip to main content

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

Metadata

Release files for mycroft-messagebus-client 0.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mycroft-messagebus-client 0.10.1
File Size Uploaded
mycroft-messagebus-client-0.10.1.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mycroft-messagebus-client 0.10.1
File Interpreter ABI Platform
mycroft_messagebus_client-0.10.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.8 kB

Release files / mycroft-messagebus-client-0.10.1.tar.gz

Download URL mycroft-messagebus-client-0.10.1.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
db7d2d08050d37112ccbf07381a7145f69e2a2cdb5d18d9b4322450e66c4f51b
BLAKE2b-256 checksum
How to use checksums
75da3840283b54522c5fdf65d0c76a22a6194e0a03266399c9794cb861f06455
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / mycroft_messagebus_client-0.10.1-py3-none-any.whl

Download URL mycroft_messagebus_client-0.10.1-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffb6a09c171586eb2bd07de3d5221d26725ce73a2dcbb418d2b8a2e4a7f59494
BLAKE2b-256 checksum
How to use checksums
b3a45cd6333bf3ebd700abb8be59540f97dbb7bdf703195f9beb130a601c5867
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.10.1 This release

2 release files

0.10.0

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

1 release file

0.8.2

2 release files

0.8.1

1 release file

0.8

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page