class documentation

class Power(MQTTAgent):

Constructor: Power(topic_filter, qos, pub_topic)

View In Hierarchy

Layout Power Agent

This manages the power subscription and publication.

There is only one of these, but singularity is not enforced.

Method __init__ Initialise the power manager
Method handle_publication Handle a publication
Constant ON_OFF On Off decode for power and decoder function commands
Method _create_pub_check Overrides version in base class
Async Method _pub_check Check for publication.
Instance Variable _dcc Undocumented
Instance Variable _publish_topic Undocumented
def __init__(self, topic_filter, qos, pub_topic):

Initialise the power manager

This initialises the power manager with the topic filter and QoS for the subscription and the topic for publishing the power state.

This will publish the power state when the power state changes or on the first call to check_power. It will also publish the power state if a retained message is received.

Parameters
topic_filterthe topic filter to match against received topics
qosthe Quality of Service for the subscription. Must be either MQTTClient.QOS0 or MQTTClient.QOS1
pub_topicthe topic used for publishing the power state
def handle_publication(self, topic, dup_flag, ret_flag, payload):

Handle a publication

This method is called by the MQTT client when a publication is received. It will turn the DCC power on or off according to the payload.

Parameters
topicthe topic of the publication
dup_flagTrue if this is a duplicate publication
ret_flagTrue if this is a retained publication
payloadthe payload of the publication as a string
ON_OFF =

On Off decode for power and decoder function commands

Value
{'ON': DCCCommand.ON, 'OFF': DCCCommand.OFF}
def _create_pub_check(self):

Overrides version in base class

async def _pub_check(self):

Check for publication.

Publish the power state on notification of change

_dcc =

Undocumented

_publish_topic =

Undocumented