Skip to content

HAA Templates

José Antonio Jiménez edited this page Dec 26, 2019 · 93 revisions

EXAMPLE TO LEARN: HomeKit Switch with UART output, inverted status LED, relay on GPIO 12, button connected to GPIO 0 and toggle connected to GPIO 14:

  • {"c":{"o":1,"l":13,"i":1},"a":[{"t":1,"0":{"r":[{"g":12,"v":0}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0,"p":1,"t":1},{"g":14,"p":1,"t":1},{"g":14,"t":0}]}]}

  • Simplified version, removing all default values: {"c":{"o":1,"l":13},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0},{"g":14},{"g":14,"t":0}]}]}

{                 <- Start of JSON
  "c": {          <- General config section
    "o": 1,       <- Enable UART log output
    "l": 13,      <- Enable status LED at GPIO 13
    "i": 1        <- Set status LED to inverted mode
  },              <- End of general config section
  "a": [          <- Accessory section. Must be an array
    {             <- First accessory, and the only
      "t": 1,     <- Accessory type 1 (Switch)
      "0": {      <- Actions triggered when HomeKit switch is set to OFF
        "r": [    <- Digital outputs. Must be an array
          {       <- First digital output (a relay), and the only
            "g": 12, <- Relay connected to GPIO 12
            "v": 0   <- Value assigned to the relay
          }       <- End of first relay
        ]         <- End of relays array
      },
      "1": {      <- Actions triggered when HomeKit switch is set to ON
        "r": [    <- Digital outputs. Must be an array
          {       <- First digital output (a relay), and the only
            "g": 12, <- Relay connected to GPIO 12
            "v": 1   <- Value assigned to the relay
          }       <- End of first relay
        ]         <- End of relays array
      },
      "b": [      <- Buttons. Must be an array
        {         <- First button
          "g": 0, <- First button at GPIO 0
          "p": 1, <- Enable internal pull-up resistor
          "t": 1  <- Set button to single press type
        },        <- End of first button
        {         <- Second button
          "g": 14,<- Second button at GPIO 14
          "p": 1, <- Enable internal pull-up resistor
          "t": 1  <- Set button to single press type
        },        <- End of second button
        {         <- Third button
          "g": 14,<- Third button at GPIO 14, same as second button
          "t": 0  <- Set button to single press opposite to 1 type
        }         <- End of third button
      ]           <- End of buttons array
    }             <- End of first accessory
  ]               <- End of accessories array
}                 <- End of JSON

EXAMPLE TO LEARN: Dummy Switch and Dummy Outlet, and nothing more:

  • {"a":[{"t":1},{"t":2}]}
{                 <- Start of JSON
  "a": [          <- Accessory section. Must be an array
    {             <- First accessory
      "t": 1      <- Accessory type Switch
    },            <- End of first accessory
    {             <- Second accessory
      "t": 2      <- Accessory type Outlet
    }             <- End of second accessory
  ]               <- End of accessories array
}                 <- End of JSON

Sonoff Basic/SV/Mini/TH/POW Standard Switch:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]}]}

Sonoff Basic Switch with external toggle connected to GPIO 14:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0},{"g":14},{"g":14,"t":0}]}]}

Sonoff Mini with external toggle and built-in button configure to enter setup mode:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0},{"g":4},{"g":4,"t":0}]}]}

Sonoff 2CH. It creates 2 HomeKit switches, and built-in button can be used to enter in setup mode:

  • {"c":{"l":13,"b":[{"g":10,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]},{"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}]},"b":[{"g":9}]}]}

Sonoff 3CH. It creates 3 HomeKit switches, and built-in button can be used to enter setup mode:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]},{"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}]},"b":[{"g":9}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":10}]}]}

Sonoff 4CH. It creates 4 HomeKit switches, and built-in button can be used to enter setup mode):

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":15}]},"1":{"r":[{"g":15,"v":1}]},"b":[{"g":14}]},{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]},{"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}]},"b":[{"g":9}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":10}]}]}

Shelly1 Switch with external toggle switch. Note that "t":1 is not present because is the default option:

  • {"a":[{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":5,"p":0},{"g":5,"t":0}]}]}

Shelly1 Switch with external push button.

  • {"c":{"b":[{"g":5,"p":0,"i":1,"t":5}]},"a":[{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":5}]}]}

Shelly1PM Switch with external toggle switch.

  • {"c":{"l":0},"a":[{"0":{"r":[{"g":15}]},"1":{"r":[{"g":15,"v":1}]},"b":[{"g":4,"p":0},{"g":4,"t":0}]}]}

Shelly2.5 Switch with external switches and status LED:

  • {"c":{"l":0,"b":[{"g":2,"t":5}]},"a":[{"0":{"r":[{"g":15}]},"1":{"r":[{"g":15,"v":1}]},"b":[{"g":5,"p":0},{"g":5,"t":0}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":13,"p":0},{"g":13,"t":0}]}]}

Shelly2.5 Switch with external push buttons and status LED:

  • {"c":{"l":0,"b":[{"g":2,"t":5}]},"a":[{"0":{"r":[{"g":15}]},"1":{"r":[{"g":15,"v":1}]},"b":[{"g":5,"p":0,"i":1}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":13,"p":0,"i":1}]}]}

Sonoff S20/S26 with status LED and working button:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"t":2,"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]}]}

Tuya SWA1 with esp8266 Smart plug:

  • {"c":{"l":4,"b":[{"g":13,"t":5}]},"a":[{"t":2,"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}]},"b":[{"g":13}]}]}

A standard Stateless Button using GPIO0:

  • {"c":{"b":[{"g":0,"t":5}]},"a":[{"t":3,"f0":[{"g":0}],"f1":[{"g":0,"t":2}],"f2":[{"g":0,"t":3}]}]}

Two Stateless Buttons using GPIO0 and GPIO2, and a dummy switch, ideal for ESP01:

  • {"c":{"b":[{"g":0,"t":5}]},"a":[{"t":3,"f0":[{"g":0}],"f1":[{"g":0,"t":2}],"f2":[{"g":0,"t":3}]},{"t":3,"f0":[{"g":2}],"f1":[{"g":2,"t":2}],"f2":[{"g":2,"t":3}]},{"t":1}]}

Sonoff Basic with Switch and Motion Sensor connected to GPIO 14, with status LED, and button to enter setup mode:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]},{"t":12,"i":10,"f1":[{"g":14}]}]}

Sonoff T2 EU 3 gangs:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]},{"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}]},"b":[{"g":9}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}]},"b":[{"g":10}]}]}

Sonoff T2 EU 3 gangs with interlocks (only one can be ON at same time):

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}],"m":[{"g":2},{"g":3}]},"b":[{"g":0}]},{"0":{"r":[{"g":5}]},"1":{"r":[{"g":5,"v":1}],"m":[{"g":1},{"g":3}]},"b":[{"g":9}]},{"0":{"r":[{"g":4}]},"1":{"r":[{"g":4,"v":1}],"m":[{"g":1},{"g":2}]},"b":[{"g":10}]}]}

Sonoff Basic/SV/TH10/TH16 Heater Thermostat with DHT22 sensor at GPIO 14:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"t":21,"s":5,"g":14,"0":{"r":[{"g":12}]},"1":{"a":0},"3":{"r":[{"g":12,"v":1}]},"5":{"a":0}}]}

Sonoff Basic/SV/TH10/TH16 HomeKit Switch and Temperature with DS18B20 sensor at GPIO 14:

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"t":22,"g":14,"n":3},{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]}]}

Gosund SP111 V2:

  • {"c":{"l":2,"b":[{"g":13,"t":5}]},"a":[{"t":2,"0":{"r":[{"g":15},{"g":0,"v":1}]},"1":{"r":[{"g":15,"v":1},{"g":0}]},"b":[{"g":13}]}]}

Shelly RGBW2 with external switch:

  • {"c":{"l":2,"b":[{"g":13,"t":5}]},"a":[{"t":30,"r":15,"g":12,"v":14,"w":4,"b":[{"g":5,"p":0},{"g":5,"t":0},{"g":13}]}]}

Bawoo RGBW Lightbulb:

  • {"c":{"b":[{"g":0}]},"a":[{"t":30,"r":14,"g":12,"v":13,"w":4,"fr":4,"fg":4,"fv":4}]}

MagicHome RGBW LED Strip Controller (R pin 15, G pin 13, B pin 12, W pin 14):

  • {"c":{"b":[{"g":0,"t":5}]},"a":[{"t":30,"r":15,"g":13,"v":12,"w":14,"b":[{"g":0}]}]}

MagicHome RGB LED Strip Controller (R pin 15, G pin 13, B pin 12):

  • {"c":{"b":[{"g":0,"t":5}]},"a":[{"t":30,"r":15,"g":13,"v":12,"b":[{"g":0}]}]}

Sonoff with HomeKit Garage Door adaptation (Working time: 18 seconds. Only close sensor connected to GPIO 14 and stop-step. Dry relay connected to action garage door button):

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"t":40,"d":18,"f3":[{"g":14,"t":0}],"f4":[{"g":14}],"0":{"r":[{"g":12,"v":1,"i":0.5}]},"1":{"a":0},"2":{"r":[{"g":12,"i":1.5},{"g":12,"v":1,"i":0.5},{"g":12,"v":1,"i":2}]},"3":{"a":2}}]}

Sonoff SV with HomeKit Garage Door adaptation and additional switch to emergency stop (Working time: 18 seconds. Close and open sensor connected to GPIO 14 and 4. With stop-step. Dry relay connected to action garage door button):

  • {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"t":40,"d":18,"f3":[{"g":14,"t":0}],"f4":[{"g":14}],"f2":[{"g":4,"t":0}],"f5":[{"g":4}],"0":{"r":[{"g":12,"v":1,"i":0.5}]},"1":{"a":0},"2":{"r":[{"g":12,"i":1.5},{"g":12,"v":1,"i":0.5},{"g":12,"v":1,"i":2}]},"3":{"a":2},"10":{"a":0}},{"i":1,"1":{"m":[{"g":1,"v":2}]}}]}

Sonoff Dual Window Covering driver with external push buttons, status LED and built-in setup button (Opening time: 18 seconds. Closing time: 14 seconds. Non-lineal correction: 70%):

  • {"c":{"l":13,"b":[{"g":10,"t":5}]},"a":[{"t":45,"o":18,"c":14,"f":70,"0":{"r":[{"g":12,"v":1},{"g":5}]},"1":{"r":[{"g":12},{"g":5,"v":1}]},"2":{"r":[{"g":12},{"g":5}]},"3":{"r":[{"g":12,"i":1},{"g":5}]},"4":{"r":[{"g":12},{"g":5,"i":1}]},"f0":[{"g":0}],"f1":[{"g":9}]}]}

Shelly2.5 Window Covering driver with external switches, status LED and built-in setup button (Opening time: 18 seconds. Closing time: 14 seconds. Non-lineal correction: 70%):

  • {"c":{"l":0,"b":[{"g":2,"t":5}]},"a":[{"t":45,"o":18,"c":14,"f":70,"0":{"r":[{"g":15,"v":1},{"g":4}]},"1":{"r":[{"g":15},{"g":4,"v":1}]},"2":{"r":[{"g":15},{"g":4}]},"3":{"r":[{"g":15,"i":1},{"g":4}]},"4":{"r":[{"g":15},{"g":4,"i":1}]},"f0":[{"g":5,"p":0}],"f1":[{"g":13,"p":0}],"f2":[{"g":5,"t":0},{"g":13,"t":0}]}]}
Clone this wiki locally