Socket
Socket
Sign inDemoInstall

homebridge-multiswitcheroo

Package Overview
Dependencies
3
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    homebridge-multiswitcheroo

User defined switches for http GET requests. Simple on/off or multiswitch on/off. Useful for lights, A/V systems, home automation, and includes live status polling!


Version published
Maintainers
1
Created

Changelog

Source

[1.0.3] - 2023-07-29

Changed

  • Changed default manufacturer and model (If you do not like them change them in your config).
  • Added ChatGPT note to README.md file

Fixed

  • Errors in README.md

Readme

Source

MultiSwitcheroo

homebridge-multiswitcheroo

User defined switches for http requests. Simple on/off (Switcheroo) or multi-switch (MultiSwitcheroo) accessories.

Useful for lights, A/V systems, home automation, and includes live status polling & parsing custom responses!

Switch Types

Multi-Switch (MultiSwitcheroo)

Ideally, you would use this to set a characteristic, like volume. For example, our config below outlines a single accessory with a mute, high, medium & low switch for a Yamaha receiver's volume.

Define your MultiSwitcheroo with whatever name you want to appear as the main switch title in the home app. This is what is visible if left displayed as a single tile (default). The name for each switch is what the individual switches should show. Sometimes these transfer to the home app, and sometimes not, so you may have to rename them all once in the home app, but only once.

Then, set the appropriate statusUrl to call for the status at the set pollingInterval (default 3000).

The statusPattern is a regular expression string (regexp) sought in the response from the server to get an accurate status for each switch (see the Mute switch in the MultiSwitcheroo config example below for a really good example of a complex pattern where an unknown number is present in the string).

Set the onUrl & offUrl as appropriate. Must be the full URL, including http:// & port.

The manufacturer, model, and serialNumber are all optional, but it is best to set them. Controller for HomeKit will throw errors about duplicate serial numbers if you have multiple devices using DEFAULT-SERIAL. Plus, it's fun to set these with your name!

Currently only built to support the GET http method.

  {
        "accessory": "MultiSwitcheroo",   // remember this *must* be 'MultiSwitcheroo' for multi
        "name": "Volume Switch",
        "manufacturer": "Manufacturer",
        "model": "Model",
        "serialNumber": "VOLUMESW01",   // best to specify a SN to avoid conflicts
        "statusUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/getStatus",
        "pollingInterval": 5000,
        "switches": [
            {
                "name": "Mute",
                "onUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/setMute?enable=true",
                "offUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/setMute?enable=false",
                "statusPattern": "{\"response_code\":0,\"power\":\"on\",\"sleep\":0,\"volume\":[0-9]+,\"mute\":true"
            },
            {
                "name": "Low",
                "onUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/setVolume?volume=51",
                "offUrl": "http://192.168.1.91/YamahaExtendedControl/v1/system/getFuncStatus",
                "statusPattern": "{\"response_code\":0,\"power\":\"on\",\"sleep\":0,\"volume\":51,\"mute\":false"
            },
            {
                "name": "Medium",
                "onUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/setVolume?volume=81",
                "offUrl": "http://192.168.1.91/YamahaExtendedControl/v1/system/getFuncStatus",
                "statusPattern": "{\"response_code\":0,\"power\":\"on\",\"sleep\":0,\"volume\":81,\"mute\":false"
            },
            {
                "name": "High",
                "onUrl": "http://192.168.1.91/YamahaExtendedControl/v1/main/setVolume?volume=111",
                "offUrl": "http://192.168.1.91/YamahaExtendedControl/v1/system/getFuncStatus",
                "statusPattern": "{\"response_code\":0,\"power\":\"on\",\"sleep\":0,\"volume\":111,\"mute\":false"
            }
        ]
  }

Standard Switch (Switcheroo)

Meant to be used as a simple on/off switch. For example, an api accessible light, outlet, fan, etc.

Define your Switcheroo with whatever name you want to appear in the home app.

Then, set the appropriate statusUrl to call for the status at the set pollingInterval (default 3000).

The statusPattern is a regular expression string (regexp) sought in the response from the server to get an accurate status for each switch (see the Mute switch in the MultiSwitcheroo config example above for a really good example of a complex pattern where an unknown number is present in the string).

Set the onUrl & offUrl as appropriate. Must be the full URL, including http:// & port.

The manufacturer, model, and serialNumber are all optional, but it is best to set them. Controller for HomeKit will throw errors about duplicate serial numbers if you have multiple devices using DEFAULT-SERIAL. Plus, it's fun to set these with your name!

Currently only built to support the GET http method.

{
        "accessory": "Switcheroo",   // remember this *must* be 'Switcheroo' for single
        "name": "My Switch",
        "model": "Model",
        "manufacturer": "Manufacturer",
        "serialNumber": "SWITCH01",   // best to specify a SN to avoid conflicts
        "statusUrl": "http://192.168.0.XXX/myswitch/status",
        "statusPattern": /1/,
        "pollingInterval": 3000,
        "onUrl"  : "http://192.168.0.XXX/myswitch/1",
        "offUrl" : "http://192.168.0.XXX/myswitch/0"
}

Configuration Params

ParameterDescriptionRequired
namename of the switch or switches
accessorySwitcheroo or MultiSwitcheroo
statusUrlurl for status requests
statusPatternregexp sought in statusUrl response body
onUrlendpoint paths for the on state
offUrlendpoint paths for the off state
pollingIntervalinterval to poll for status updates in milliseconds (default 3000ms or 3 seconds)
switchesarray of switches required for MultiSwitcheroo devices (see axample config)
manufacturerwill show in Home app description of this Homekit accessory, ex. 'Yamaha'
modelwill show in Home app description of this Homekit accessory, ex. 'Default Model'
serialNumberwill show in Home app description of this Homekit accessory, ex. 'SERIALNUMBER1'

Tips

  • Make sure specify the full URL in the statusURL. (i.e. "statusUrl" : "http://192.168.0.XXX:2000").
  • Must prepend 'http://' to all URLs.
  • Verify your server only uses GET. This plugin only does GET requests.
  • Use this plugin in a child bridge. It's just better.
  • You can expose multiple switches on the same child bridge, just use the same _bridge username & port in the config.

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install homebridge-http using: npm install -g homebridge-multiswitcheroo
  3. Update your config file

This plugin was generated by ChatGPT.

Keywords

FAQs

Last updated on 29 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc