Skip to content

HAA Templates

José Antonio Jiménez Campos edited this page May 8, 2020 · 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 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}]}}]}
Clone this wiki locally