npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-platform-azure-servicebus

v1.2001.5

Published

Azure Service Bus plugin for homebridge: https://github.com/nfarina/homebridge

Downloads

4

Readme

homebridge-platform-azure-servicebus

An Azure Service Bus plugin for homebridge.

This plugin allows both incoming service bus messages from a queue. These messages will trigger a switch based on the name of the accessory defined in the config.json as described below.

This plugin also allows different switches to trigger the sending of messages to a queue. These messages will contain the source button name in the message. It is advised to make these switches to a timeout switch to make them act like a button.

My setup

I have a homebridge running on a Raspberry Pi 4. Controlling a Nest Thermostat and this plugin.

Why?

Why on earth would someone need a service bus queue to control home automation? Service Bus seems to be a very affordable solution for queueing messages. I selected Service Bus due to my familiarity with it. The Cloud Based Queues are significantly more reliable than public free eventing platforms such as If This Then That.

My primary use case was connecting my home automation kit to events from Office365 for notification of upcoming meetings.

Primary Workflow

  1. Meeting is created in Office 365.
  2. Microsoft Flow is triggered when an upcoming meeting (Authenticated)
    1. Microsoft Flow gets details of the meeting.
    2. Microsoft Flow checks to see if the categories include the category Critical
    3. If the category is contained, send a message using Service bus to my service bus queue (Authenticated);
  3. Queue receives Message
  4. Homebridge plugin receives message using AQMP listener (Authenticated).
  5. Homebridge plugin checks to see if the target accessory of the message, the ID of the accessory is simply the name.
    1. If the accessory is contained in the list, it will be toggled. This change is observable by HomeKit and can be used to trigger automation.
    2. if the accessory is not found, the message will be deleted.

Installation

Install the plugin at the global scope.

sudo npm install -g https://github.com/nicwise/homebridge-platform-sqs.git

Once the plugin is installed, it must be configured.

Config

This example is also contained within /sample-config.json.

{
			"platform": "AzureServiceBus",
			"name": "ServiceBusButtons",
			"incommingMessageConnectionString": "connectionStringFromAzurePortalOrCmd",
			"outgoingMessageConnectionString": "connectionStringFromAzurePortalOrCmd",
			"incomingQueueName": "The name of the queue. Also specified in the EntityPath",
			"outgoingQueueName": "The name of the queue. Also specified in the EntityPath",
			"incomingSwitches": [
				{
					"name": "TestButton1"
				},
				{
					"name": "TestButton2",
					"isTimeoutButton": true,
					"buttonTimeout": 1500
				}
			],
			"outgoingButtons": [
				{
					"name": "foo",
					"isTimeoutButton": true,
					"buttonTimeout": 500
				}
			]
		}

You must use a SharedAccessSignature to send or receive messages from a service bus queue. The two queues (incoming and outgoing) must be individually specified. In addition, the queue name for each must match.

Incoming Switches

Incoming switches are accessories that will respond to messages on the incoming queue. They are specified in an array in the incomingSwitches section of the config.

Example Message: This message will cause the switch to toggle, and due to its timeout property, its state will reset in 1500ms. Using the isTimeoutButton property will cause the switch to act like a sticky button.

{
  "target": "TestButton2"
}

Outgoing Buttons

Outgoing Buttons are accessories that will cause a service bus message to be sent to the outgoing queue. The message will simply contain the name of the accessory that was pushed. These accessories will always timeout after 500ms and will act like buttons. Unfortunately as of this version, buttons dont work as expected.

Sample Message: This is the sample message that will be generated.

{
  "source": "Foo"
}

Azure setup

This plugin expects a basic understanding of Azure and ServiceBus programming. This guide is not a comprehensive guide on how to use or setup servicebus.

Service Bus Overbiew

Please follow the Full Guide to creating a service bus queue for additional information.

  1. Create a Service Bus Namespace. This namespace is a container that can contain multiple queues.
  2. Create a Queue for Incoming Messages in the new Namespace.
  3. Create a SharedAccessSignature within the queue to for authorization. It is recommended to use the queue level Shared Access Signature, instead of the root SAS signature.
    1. The Connection string should be placed in the incommingMessageConnectionString element.
    2. The Queue Name should be placed in the incomingQueueName element. This can either be copied from the portal, or from the EntitiyPath=YOUR_QUEUE_NAME_HERE section of the connection string sourced from a queue level SAS.
  4. Create a Queue for Outgoing Messages in the new Namespace.
  5. Create a SharedAccessSignature within the outgoing queue for authorization.
    1. The Connection string should be placed in the outgoingMessageConnectionString element.
    2. The Queue Name should be placed in the outgoingQueueName element. This can either be copied from the portal, or from the EntitiyPath=YOUR_QUEUE_NAME_HERE section of the connection string sourced from a queue level SAS.

WARNING: The Connection String is a credential and should be treated as such. Any party with the SAS connection string can send or receive messages to and from the queue.