Ankündigung

Einklappen
Keine Ankündigung bisher.

Openhab2 + Global Cache Binding

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

    Openhab2 + Global Cache Binding

    Hallo zusammen,

    ich habe mit einen Global Cache itach Flex Serial Adapter + Kabel gekauft um damit meinen Multiroom Audioverstärker zu steuern.

    https://www.globalcache.com/products/flex/


    Leider bekomme ich das Binding nicht zum laufen.


    Hier die Konfig:

    Item:
    Code:
    String MonoPrice "MonoPrice" { channel="globalcache:itachFlex:000C45D530B9:sl-m1#c1-direct" }

    Code:
    rule "MonoPrice Zone 1 Power" when Item MonoPrice_Z1_PWR received command then if(receivedCommand==ON){ sendCommand(MonoPrice, "<11PR01\r") logInfo("MonoPrice", "Zone 1 Power ON") } else if(receivedCommand==OFF){ sendCommand(MonoPrice, "<11PR00\r") logInfo("MonoPrice", "Zone 1 Power OFF") } sendCommand(MonoPrice, "?11\r") Thread::sleep(1000) postUpdate(MonoPrice_Status, MonoPrice.state.toString.trim) end
    Der Hersteller stellt eine Test Software zur Verfügung mit der ich sehen kann welche Kommandos das Gerät empfängt. Dort habe ich gesehen das die Software die Befehle per TCP sendet und empfängt (192.168.X.X:4999)

    Könnte ich hierfür auch das TCP Binding nutzen?

    Wie müsste dann die Syntax lauten?

    Gruß

    Miki

    #2
    Bisschen schlauer bin ich schon


    Mit:

    Code:
    { tcp=">[ON:192.168.2.69:4999:<11PR01], >[OFF:192.168.2.69:4999:<11PR00]" }
    Kann ich das Gerät ein und ausschalten.

    Wie schicke ich aber Kommados per Rule?

    muss ich da mit 'REGEX((.*))']" arbeiten?

    udo1toni hast du nen Tipp für mich?

    Vielen Dank

    Kommentar


      #3
      wennDudas Iten definiert hast, musst Du ja nur per Item.sendComand() den Befehl schicken.

      Kommentar


        #4
        udo1toni

        Genau das ist mein Problem, wie definiere ich das item?

        Mit
        Code:
        Switch MonoPrice "Zone 1 Power" { tcp=">[ON:192.168.2.69:4999:<11PR01], >[OFF:192.168.2.69:4999:<11PR00]" }
        kann ich aus und einschalten. Aber wenn ich die Lautstärke dann per Rule schicke:

        Item ist ein String

        Code:
        String MonoPrice1 { tcp=">[192.168.2.69:4999]" }
        Code:
        MonoPrice1.sendCommand("<11VO0")
        kommt nix an.
        Zuletzt geändert von Miki84; 28.01.2017, 11:54.

        Kommentar


          #5
          Ach so, Du willst den Value des Items versenden, das sollte dann so aussehen:
          Code:
           
           String MonoPrice1 { tcp=">[192.168.2.69:4999]:%2$s" }

          Kommentar


            #6
            Hi udo1toni,

            geht leider auch nicht

            Im Anhang mal ein Screen von der Testsoftware.
            amp.JPG

            Kommentar


              #7
              Dann muss ich leider erstmal passen, aber vielleicht hat ja jemand anderes was erhellendes dazu beizutragen

              Kommentar


                #8
                Habe es mittlerweile hinbekommen.

                Der Vollständigkeit, sollte jemand seinen Monoprice über OpenHAB steuern wollen. So geht es:


                items:
                Code:
                /* MonoPrice */ //
                String MonoPrice "MonoPrice Amp [%s]" { channel="globalcache:itachFlex:dc98a65f:sl-m1#c1-direct" }
                String MonoPrice_Status "MonoPrice Status [%s]"
                String MonoPrice_Status_G1 "MP G1 (Zone) [%s]"
                String MonoPrice_Status_G2 "MP G2 (PA Status) [%s]"
                String MonoPrice_Status_G3 "MP G3 (Pwr Status) [%s]"
                String MonoPrice_Status_G4 "MP G4 (Mute Status) [%s]"
                String MonoPrice_Status_G5 "MP G5 (DT Status) [%s]"
                String MonoPrice_Status_G6 "MP G6 (Volume Status) [%s]"
                String MonoPrice_Status_G7 "MP G7 (Treble Status) [%s]"
                String MonoPrice_Status_G8 "MP G8 (Bass Status) [%s]"
                String MonoPrice_Status_G9 "MP G9 (Balance) [%s]"
                String MonoPrice_Status_G10 "MP G10 (Src Status) [%s]"
                String MonoPrice_Status_G11 "MP G11 (Keypad Status) [%s]"
                Switch MonoPrice_Z1_PWR "Zone 1 Power"
                Switch MonoPrice_Z2_PWR "Zone 2 Power"
                Switch MonoPrice_Z3_PWR "Zone 3 Power"
                Switch MonoPrice_Z4_PWR "Zone 4 Power"
                Switch MonoPrice_Z5_PWR "Zone 5 Power"
                Switch MonoPrice_Z6_PWR "Zone 6 Power"
                Switch MonoPrice_Z1_Mute "Zone 1 Mute"
                Switch MonoPrice_Z2_Mute "Zone 2 Mute"
                Switch MonoPrice_Z3_Mute "Zone 3 Mute"
                Switch MonoPrice_Z4_Mute "Zone 4 Mute"
                Switch MonoPrice_Z5_Mute "Zone 5 Mute"
                Switch MonoPrice_Z6_Mute "Zone 6 Mute"
                Dimmer MonoPrice_Z1_Volume "Zone 1 Volume [%02d %%]"
                Dimmer MonoPrice_Z2_Volume "Zone 2 Volume [%02d %%]"
                Dimmer MonoPrice_Z3_Volume "Zone 3 Volume [%02d %%]"
                Dimmer MonoPrice_Z4_Volume "Zone 4 Volume [%02d %%]"
                Dimmer MonoPrice_Z5_Volume "Zone 5 Volume [%02d %%]"
                Dimmer MonoPrice_Z6_Volume "Zone 6 Volume [%02d %%]"
                Number MonoPrice_Z1_Source "Zone 1 Source"
                Number MonoPrice_Z2_Source "Zone 2 Source"
                Number MonoPrice_Z3_Source "Zone 3 Source"
                Number MonoPrice_Z4_Source "Zone 4 Source"
                Number MonoPrice_Z5_Source "Zone 5 Source"
                Number MonoPrice_Z6_Source "Zone 6 Source"
                sitemap:

                Code:
                    Frame label="Audio"{
                        Text item=MonoPrice1 label="Monoprice" {
                            Frame {
                                                Text item=MonoPrice
                                                Text item=MonoPrice_Status
                                                Text item=MonoPrice_Status_G1
                                                Text item=MonoPrice_Status_G2
                                                Text item=MonoPrice_Status_G3
                                                Text item=MonoPrice_Status_G4
                                                Text item=MonoPrice_Status_G5
                                                Text item=MonoPrice_Status_G6
                                                Text item=MonoPrice_Status_G7
                                                Text item=MonoPrice_Status_G8
                                                Text item=MonoPrice_Status_G9
                                                Text item=MonoPrice_Status_G10
                                                Text item=MonoPrice_Status_G11
                                                Switch item=MonoPrice_Z1_PWR
                                                Switch item=MonoPrice_Z1_Source label="Zone 1 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z1_PWR==ON]
                                                Slider item=MonoPrice_Z1_Volume visibility=[MonoPrice_Z1_PWR==ON]
                                                Switch item=MonoPrice_Z1_Mute visibility=[MonoPrice_Z1_PWR==ON]
                                                Switch item=MonoPrice_Z2_PWR
                                                Switch item=MonoPrice_Z2_Source label="Zone 2 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z2_PWR==ON]
                                                Slider item=MonoPrice_Z2_Volume visibility=[MonoPrice_Z2_PWR==ON]
                                                Switch item=MonoPrice_Z2_Mute visibility=[MonoPrice_Z2_PWR==ON]
                                                Switch item=MonoPrice_Z3_PWR
                                                Switch item=MonoPrice_Z3_Source label="Zone 3 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z3_PWR==ON]
                                                Slider item=MonoPrice_Z3_Volume visibility=[MonoPrice_Z3_PWR==ON]
                                                Switch item=MonoPrice_Z3_Mute visibility=[MonoPrice_Z3_PWR==ON]
                                                Switch item=MonoPrice_Z4_PWR
                                                Switch item=MonoPrice_Z4_Source label="Zone 4 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z4_PWR==ON]
                                                Slider item=MonoPrice_Z4_Volume visibility=[MonoPrice_Z4_PWR==ON]
                                                Switch item=MonoPrice_Z4_Mute visibility=[MonoPrice_Z4_PWR==ON]
                                                Switch item=MonoPrice_Z5_PWR
                                                Switch item=MonoPrice_Z5_Source label="Zone 5 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z5_PWR==ON]
                                                Slider item=MonoPrice_Z5_Volume visibility=[MonoPrice_Z5_PWR==ON]
                                                Switch item=MonoPrice_Z5_Mute visibility=[MonoPrice_Z5_PWR==ON]
                                                Switch item=MonoPrice_Z6_PWR
                                                Switch item=MonoPrice_Z6_Source label="Zone 6 Source" mappings=[1=CH1,2=BT,3=CH3,4=CH4,5=CH5,6=CD] visibility=[MonoPrice_Z6_PWR==ON]
                                                Slider item=MonoPrice_Z6_Volume visibility=[MonoPrice_Z6_PWR==ON]
                                                Switch item=MonoPrice_Z6_Mute visibility=[MonoPrice_Z6_PWR==ON]

                rule nur für Zone1 andere natürlich Analog:

                Code:
                /**
                * These rules control MonoPrice 6-Zone Audio Amplifer
                */
                rule "MonoPrice Zone 1 Power"
                when
                        Item MonoPrice_Z1_PWR received command
                then
                        if(receivedCommand==ON){
                                sendCommand(MonoPrice, "<11PR01\r")
                                logInfo("MonoPrice", "Zone 1 Power ON")
                        }
                        else if(receivedCommand==OFF){
                                sendCommand(MonoPrice, "<11PR00\r")
                                logInfo("MonoPrice", "Zone 1 Power OFF")
                        }
                        sendCommand(MonoPrice, "?11\r")
                        Thread::sleep(1000)
                        postUpdate(MonoPrice_Status, MonoPrice.state.toString.trim)
                end
                
                rule "MonoPrice Zone 1 Source"
                when
                        Item MonoPrice_Z1_Source received update
                then
                        sendCommand(MonoPrice, "<11CH0" + MonoPrice_Z1_Source.state.toString + "\r")
                        sendCommand(MonoPrice, "?11\r")
                        Thread::sleep(1000)
                        postUpdate(MonoPrice_Status, MonoPrice.state.toString.trim)
                end
                
                rule "MonoPrice Zone 1 Volume"
                when
                        Item MonoPrice_Z1_Volume received command
                then
                        if(receivedCommand instanceof PercentType) {                    //We received a direct slider input value
                                volume_z1 = receivedCommand
                                volume_z1 = (volume_z1 * 38 / 100).intValue             //Scale percentage of volume to Monoprice scale (0 to 38)
                        } else {
                                        if(receivedCommand==INCREASE)                   //We received input from the UP/DOWN buttons
                                        {
                                                volume_z1 = volume_z1 + 1
                                        }
                                        if(receivedCommand==DECREASE)
                                        {
                                                volume_z1 = volume_z1 - 1
                                        }
                                }
                        if (volume_z1>9) {sendCommand(MonoPrice, "<11VO" + volume_z1.toString("%02d") + "\r") }         //Send out Volume command
                        else {sendCommand(MonoPrice, "<11VO0" + volume_z1.toString("%02d") + "\r") }
                        postUpdate(MonoPrice_Z1_Volume, (volume_z1 / 38 * 100).intValue)                                //Update Slider % value
                        sendCommand(MonoPrice, "?11\r")
                        Thread::sleep(1000)
                        postUpdate(MonoPrice_Status, MonoPrice.state.toString.trim)
                end
                
                rule "MonoPrice Zone 1 Mute"
                when
                        Item MonoPrice_Z1_Mute received command
                then
                        if(receivedCommand==ON)         sendCommand(MonoPrice, "<11MU01\r")
                        else if(receivedCommand==OFF)   sendCommand(MonoPrice, "<11MU00\r")
                        sendCommand(MonoPrice, "?11\r")
                        Thread::sleep(1000)
                        postUpdate(MonoPrice_Status, MonoPrice.state.toString.trim)
                end

                udo1toni

                Wie bekomme ich es bei den rules hin, das nach einem System Neustart der aktuelle Wert ausgelesen wird? Hast du ne Idee wie ich die Abfragen bauen könnte?

                Reicht es aus einem:

                Code:
                when
                        Item MonoPrice_Z1_Mute received command
                ein:

                Code:
                when
                        Item MonoPrice_Z1_Mute received command or system started
                zu machen?

                Gruß Miki

                Kommentar

                Lädt...
                X