ph_mqttpub (MQTT Table syntax) PowerHome formula function
Description
Publishes an MQTT message to a topic that is currently defined and setup within the MQTT->MQTT Publish section of the PowerHome Explorer. For syntax for a more general version of MQTT publishing, please see this function: ph_mqttpub (General)
Syntax
ph_mqttpub ( as_id, as_message, ai_type )
Argument Description
as_id String. The ID of the MQTT Publish topic you wish to send a message to
as_message String. The message you wish to publish
ai_type Integer. Specifies how the message is to be published. A value of 0 will send the message to the controller queue where it is executed after other queued messages. Any other value causes the controller to send the message immediately with feedback if an error occurs 
Return value
Integer. Returns 0 if message was queued successfully when ai_type = 0. Returns 0 if message was published successfully when ai_type <> 0. Returns -100 if the ID specified in as_in is not found in the MQTTPUB table. Returns -1 if the controller associated with the MQTT Publish topic specified by as_id is not found. Returns -51 if the command is not supported by the controller. Returns -11 if an error occurs during publish when ai_type <> 0 
Usage
Use this function to publish MQTT messages to a previously defined MQTT topic in the MQTTPUB table. These definitions are maintained within the PowerHome Explorer under the MQTT->MQTT Publish screen. If you wish to publish a message to a topic not currently defined, then use the other syntax for this function under ph_mqttpub (General) . For more information concerning MQTT, the protocol, and how it is used, a very good reference can be found here: https://www.hivemq.com/mqtt-essentials/
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_mqttpub("FAMRMLIGHT","On, 75%",0) - Returns a 0 if the topic/message was successfully queued. This example will publish a message of "On, 75%" to the topic defined for the "FAMRMLIGHT" ID in the MQTTPUB table. The QOS and retain values will also be pulled from the "FAMRMLIGHT" table entry