pylab_ml.common.mqtt_client.mqtt_deviceattributes

class mqtt_deviceattributes[source]

Bases: object

Handle mqqt messages for the instrument (=devices is ‘transmitter’).

  • topic for the device:

    f’{TOPIC_PREFIX}/’Hostname’/{TOPIC_INSTRUMENT}

  • payload:

    {“instrumentname”: {“type”: “set/get”, “cmd”: “function/attributename”, “payload”: yourvalues}}

    mqtt_all will be overwriten, to uncover attributes for sending mqqt-messages

  • if you define the function ‘_mqtt2json(value, attributename)’ in your device, than this function will be call if a mqtt message should be send With this function you can translate the value, or it the result ‘nomqtt’ than the message will not be send.

__init__()[source]

Methods

__init__()

close()

mqtt_add(client, instrument[, liste, qos])

Add the instrument to mqtt.

mqtt_disconnect()

Remove the instrument from mqtt.

publish(topic, value)

Publish topic as type='cmd' with paylad=value.

publish_get(function_name, value)

Publish function_name as type='get' with paylad=value.

publish_set(function_name, value)

Publish function_name as type='set' with paylad=value.

Attributes

command

mqtt_enable

mqtt_list

mqtt_status

Getter for the mqtt_status.

json = <module 'json' from '/home/runner/miniconda3/envs/test/lib/python3.9/json/__init__.py'>
mqtt_add(client, instrument, liste='#', qos=0)[source]

Add the instrument to mqtt.

calling from base_instrument, after the instrument (device) has been create. Normally you have not to use this function, only base_instrument use it.

Returns:

None.

mqtt_disconnect()[source]

Remove the instrument from mqtt.

calling from base_instrument, if the instrument are closing. Normally you have not to use this function, only base_instrument use it.

Returns:

None.

property mqtt_status

Getter for the mqtt_status.

publish(topic, value)[source]

Publish topic as type=’cmd’ with paylad=value.

publish_get(function_name, value)[source]

Publish function_name as type=’get’ with paylad=value.

publish_set(function_name, value)[source]

Publish function_name as type=’set’ with paylad=value.