This Switch King plugin enables Switch King to send and receive MQTT messages.

The plugin even allows Switch King to subscribe to MQTT topics and update datasource values from messages in these topics. Look at the MQTT Topics paragraph for more information.

Installation

  1. Stop all Switch King services.
  2. Place the two DLL files and the .CONFIG file from the downloaded archive into the Plugins folder located in your Switch King Server folder (usually in C:\Program Files (x86)\Switch King\Switch King Server).
  3. Edit Net.Bluewalk.MQTT.SwitchKingPlugin.dll.config to reflect your settings, see next paragraph for more information about the config file.
  4. Start the Switch King services.

Configuration

There are several settings you need to change in the config file in order to be able to use this plugin:

SettingDescription
MQTTTopicPrefix This is the prefix that the plugin will add to the beginning of the topic this plugin uses
MQTTBrokerAddress The address of your MQTT broker
MQTTQOSLevel The QOS level of the messages this plugin will send and receive
MQTTRetain Specifies if the published messages from this plugin will retain on the broker
PublishDeviceEvents Enables/disables device events being published
PublishDatasourceUpdates Enables/disables datasource updates being published
PublishSystemModeChanges Enabled/disables systemmode changes being published
PublishScenarioChanges Enables/disables scenario changes being published

MQTT Topics

The plugin will use the following topics for receiving and publishing messages (note that you have to add your prefix).

TopicDescription
switchking/datasource/{ID} Updates to datasources will be published to this topic, {ID} will be replaced with the datasource ID.
switchking/datasource/{ID}/value Messages published to this topic will update the datasource identified by the ID with the data from the message (replace {ID} with the actual datasource ID).
switchking/devicecommand/{ID} Device commands will be published to this topic, {ID} will be replaced with the device ID.
switchking/devicecommand/{ID}/{COMMAND}

Messages published to this topic will perform the given command to the supplied device (replace {ID} with the actual device ID).

Available commands are:

  • turnon
  • turnoff
  • dim, where the content of the message is the percentage to dim
  • synchronize
  • cancelsemiauto
switchking/scenario Scenario changes will be published to this topic
switchking/scenario/set The Scenario ID published to this topic will trigger a scenario change in Switch King
switchking/systemmode SystemMode changes will be published to this topic
switchking/systemmode/set The SystemMode ID published to this topic will trigger a system mode change in Switch King
switchking/mqttplugin Any information from this plugin (for example update messages) will be published to this topic

Of course you can also let Switch King subscribe to any topic available to automatically update a datasource. To do so, all you have to do is to add the text MQTT: (note the double column) followed by the topic which message should be used to update the datasource. For example MQTT:otgw/status/room_temperature (see screenshot).
The plugin will automatically search for datasources with the MQTT description every minute and subscribes to that topic if it hasn't already done that. A.K.A. it takes about a minute to start/stop receiving data.

Q&A

Are you affiliated with the Switch King team?

Nope.

Contacting/Support

Go to the Switch King forum thread for contacting us or for support: http://www.switchking.se/forum/viewtopic.php?f=23&t=1714

Screenshots

Switch King Datasource

Changelog

1.2.0.0
31/05/2015

- Added ability to control devices through MQTT (same commands as used in the REST service are available)
- Added update check for future updates (updates will appear in the logfile and will be published to the switchking/mqttplugin topic)

1.1.0.0
09/05/2015

- Fixed error in Device Command JSON
- Added support for receiving scenario changes
- Added support for controlling scenario's
- Added support for receiving system mode changes
- Added support for controlling system modes

1.0.0.0
07/05/2015

Initial release