Skip to content

UnixMonky/Mqtt.Spoon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

MqttPub Spoon for HammerSpoon

What is it?

This Spoon will let you publish to MQTT. It's intention is a utility function to be used elsewhere; it doesn't do much by itself.

Largely based on hammerspoon-mqtt-sleepwatcher which showed me how to use mqtt and mosquitto. I wanted a separate mqtt spoon so I've borrowed the parts I needed heavily (Thank you!)

Requirements

  1. Hammerspoon
  2. mosquitto_pub from the Mosquitto installation.

Installing

  1. Install mosquitto with brew install mosquitto
  2. Copy this repo to ~/.hammerspoon/Spoons/Mqtt.Spoon directory
  3. Edit your main init.lua and set the startup variables appropriately.

Spoon Startup Code

Your init.lua file can remain largely unchanged. Just add the Spoon startup code and configuration to it.

hs.loadSpoon('SleepWatch')
spoon.Mqtt.host = 'YOUR MQTT HOST'
spoon.Mqtt.user = 'YOUR MQTT USERNAME'
spoon.Mqtt.pass = 'YOUR MQTT PASSWORD'
spoon.Mqtt.topic = 'MQTT TOPIC TO PUBLISH ON'
spoon.SleepWatch:start()

Port Selection

Change the port if you're not using the default port 1883 or 8883. Required for CloudMQTT.

spoon.Mqtt.port = 'YOUR MQTT PORT'

TLS support (add one of these lines to the above config example)

This will force a TLS connections and change the connection port to 8883. MacOS keeps certificates in the keychain. If you are using brew then the openssl makes these available in /usr/local/etc/openssl/cert.pem

spoon.Mqtt.certFile = 'CERT FILE'

or

spoon.Mqtt.certPath = 'CERT PATH'

About

My Hammerspoon configs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages