Siri Homekit integration with homecontrol

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Gast

    #1

    Siri Homekit integration with homecontrol

    I found a great project on github to control your loxone with Siri!



    I was wondering if other people are using this aswel?

    My code for a single switch is attached..
    Angehängte Dateien
    Zuletzt geändert von Gast; 09.10.2015, 07:14.
  • Gast

    #2
    Hello,

    can you give some more info plz? dont you need to add things to loxone config?

    Kommentar

    • Gast

      #3
      On the blog you can find how it works on the server side http://selfcoded.com/blog/2015/07/31...accessory.html
      You can use any input or create a virtual input that you can then control thru homekit..

      my script with some explanation:

      package main

      import (
      "github.com/brutella/hc/hap"
      "github.com/brutella/hc/model"
      "github.com/brutella/hc/model/accessory"
      "net/http"
      "log"
      "io/ioutil"
      "encoding/xml"
      )


      type MyResp struct {
      XMLName xml.Name
      Value Value
      }

      type Value struct {
      XMLName xml.Name `xml"LL"`
      Value string `xml:"value,attr"`
      Control string `xml:"control,attr"`
      Code string `xml:"Code,attr"`
      }

      func main() {
      // define a new accessory
      TVInfo := model.Info{
      Name: "TV Scene",
      }
      tv := accessory.NewSwitch(TVInfo)
      //Create a new accessory
      t, err := hap.NewIPTransport("03887210", tv.Accessory)

      if err != nil {
      log.Fatal(err)
      }
      //whenever the state changes via homecontrol the following is called
      tv.OnStateChanged(func(on bool) {
      //first check the current status of what you want to control (this is optional) if there is no output you can create a virtual status
      // change you values below
      status, err := http.Get("http://Username:Password@Loxone.DNS.OR.IP/dev/sps/io/VirtualStatus/state")
      log.Println("[INFO] Client changed flipped switch - Check status")
      log.Println(status)
      if err != nil {
      log.Fatal(err)
      }
      defer status.Body.Close()
      //Code to read response from loxone my status is connected to the output of a room light controller
      body, err := ioutil.ReadAll(status.Body)
      log.Printf("body %v", string(body))
      var c Value
      xml.Unmarshal(body, &c)
      log.Println(c.Value)
      if on == true {
      log.Println("[INFO] Client changed switch to on")
      switch c.Value {
      case "1.0":
      //when response is 1 the scene is allready on, so nothing to do
      log.Println("[INFO] Tv Scene allready set")
      default:
      // for everything else send pulse to VirtualInput
      log.Println("[INFO] Client changed switch to on - Send Pulse")
      resp, err := http.Get("http://Username:Password@Loxone.DNS.OR.IP/dev/sps/io/VirtualInput/Pulse")
      log.Println(resp)
      if err != nil {
      log.Fatal(err)
      }
      defer resp.Body.Close()
      }
      } else {
      // when homcontrol is used to turn off
      log.Println("[INFO] Client changed switch to off")
      switch c.Value {
      case "0.0":
      //when response is 0 the scene is allready off, so nothing to do
      log.Println("[INFO] Tv Scene allready off")
      case "-1.0":
      log.Println("[INFO] Other Scene Set")
      //when response is -1 a diffrent scene is set, you can choose to add a pulse here to
      case "1.0":
      //scene is on, turn off py sending a pulse
      log.Println("[INFO] Send Pulse to turn off scene")
      resp, err := http.Get("http://Username:Password@Loxone.DNS.OR.IP/dev/sps/io/VirtualInput/Pulse")
      log.Println(resp)
      if err != nil {
      log.Fatal(err)
      }
      defer resp.Body.Close()
      default:
      //scene is on, turn off py sending a pulse
      log.Println("[INFO] Other scene set turn off - Send Pulse")
      resp, err := http.Get("http://Username:Password@Loxone.DNS.OR.IP/dev/sps/io/VirtualInputForOff/Pulse")
      log.Println(resp)
      if err != nil {
      log.Fatal(err)
      }
      defer resp.Body.Close()
      }
      }
      })


      hap.OnTermination(func() {
      t.Stop()
      })

      t.Start()
      }

      Kommentar

      • Gast

        #4
        So al you need is the homecontrol app and an iOS device to controle loxone with Siri. What is the reaction time wehen you give the voice Command

        Is iT possible to make à video of the action?

        Kommentar

        • Gast

          #5
          You need an IOS device with a homekit compatible app, can be anyone, there are free apps like insteon+
          I did find that the developer of homecontrol his own app, which is called home, had the best functionality (it is a little steep..)
          And next to that you also need a computer of device to run the code/server, this can be raspberry pi, synology or any computer that keeps running.

          The reaction time is really fast, I cannot differentiate any difference in timing between the Loxone app or controlled via voice..

          Kommentar

          • Gast

            #6
            so i have a server running ubuntu and installed Go on it but i have no idea what i should do now...

            Kommentar

            • Gast

              #7
              1 : Create a virtual input and status you want to control in loxone config.
              2 : Modify the code attached with your miniserver info and input and status parameters :
              --> these lines :
              http://[Your Username]:[Your Loxone Password]@[Loxone DNS or IP address]/dev/sps/io/[name of identifier of VirtualInput]/Pulse
              http://[Your Username]:[Your Loxone Password]@[Loxone DNS or IP address]/dev/sps/io/[name of identifier of Virtual Status]/state
              3 : Save the file to home.go
              4 : Make sure you have a working go installation by testing it : https://golang.org/doc/install#testing
              5 : compile the file by entering in the "go build home.go"
              6 : Run the file by entering "go run home.go"
              7 : You can keep it running by running a daemon explained here at deployment : http://selfcoded.com/blog/2015/07/31...accessory.html



              Kommentar

              • mantal
                Azubi
                • 30.09.2023
                • 1

                #8
                This is exactly I was looking for. Is there a way to use this method with Arduino, ESP8266 chip?

                Kommentar

                Lädt...