Hier noch eine Variante um die POE Ports zu schalten, etwas unschön bzgl. Passwort im Klartext im Skript, aber bei der Variante über einen SSH Key gabs (bei mir) Probleme im Zusammenspiel mit den Unifi Switchen. Das muss ich mir in einer ruhigen Minute nochmal anschauen.
Ihr benötigt /usr/bin/plink (alternativ würde auch /usr/bin/sshpass gehen):
sudo apt install putty-toolsFolgende Dateien liegen bei mir unter /opt/iobroker/my-assets/unifi-switch
telnet Befehle für den Switch/opt/iobroker/my-assets/unifi-switch/unifi-switch-poe-port-8-off
conf
interface 0/8
shutdown
exit
/opt/iobroker/my-assets/unifi-switch/unifi-switch-poe-port-8-on
en
conf
interface 0/8
no shutdown
exit
Das Skript dazu - den Trigger DP müsst ihr euch selbst anlegen 🙂
Blockly <xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="%g/ANJxNOs5Cicx-gOSb">log_info_text</variable> <variable id="27F.R1Z-z#dt9y!]HCI?">user</variable> <variable id="]5sS^f/;5~_X{[qJ(FYE">pass</variable> <variable id=",W^G}X63.I8(oB$2R5LN">switch_ip</variable> <variable id="~;w%BJ+Dfcj?tZ^fn?j8">switch_port</variable> <variable id="Hb~d6EqId4z}cn3|S8;t">switch_poe_status</variable> <variable id="VOiR$*N3m0]#z3=8[W.j">exec_cmd</variable> </variables> <block type="procedures_defnoreturn" id="#Zi/$jvI[?9PNg/b0k:." x="-12" y="138"> <mutation> <arg name="log_info_text" varid="%g/ANJxNOs5Cicx-gOSb"></arg> </mutation> <field name="NAME">log_info</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"> <block type="debug" id="tv!r|@tv45}[[V$gBHdO" inline="true"> <field name="Severity">log</field> <value name="TEXT"> <shadow xmlns="http://www.w3.org/1999/xhtml" type="text"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="cW6gAbluGo@d)J*#L{wc"> <mutation items="4"></mutation> <value name="ADD0"> <block type="text" id="k@7d@dQu#zu?^FZ!n=i,"> <field name="TEXT">+++ </field> </block> </value> <value name="ADD1"> <block type="text" id="CxOUVO`Xtmj1Y:)cwwz!"> <field name="TEXT">switch poe: </field> </block> </value> <value name="ADD2"> <block type="variables_get" id="tAFuc5MD6IpErxMNOy%!"> <field name="VAR" id="%g/ANJxNOs5Cicx-gOSb">log_info_text</field> </block> </value> <value name="ADD3"> <block type="text" id="T{W,KRi6k$Se*--LVQNu"> <field name="TEXT"> +++</field> </block> </value> </block> </value> </block> </statement> </block> <block type="procedures_defnoreturn" id="+oqtTq6O-;eiS}Sj~6#Q" x="-12" y="363"> <mutation> <arg name="user" varid="27F.R1Z-z#dt9y!]HCI?"></arg> <arg name="pass" varid="]5sS^f/;5~_X{[qJ(FYE"></arg> <arg name="switch_ip" varid=",W^G}X63.I8(oB$2R5LN"></arg> <arg name="switch_port" varid="~;w%BJ+Dfcj?tZ^fn?j8"></arg> <arg name="switch_poe_status" varid="Hb~d6EqId4z}cn3|S8;t"></arg> </mutation> <field name="NAME">switch_poe</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"> <block type="variables_set" id="IU{JZhU0s#v:256Xp8?n"> <field name="VAR" id="VOiR$*N3m0]#z3=8[W.j">exec_cmd</field> <value name="VALUE"> <block type="text_join" id="h,%4/10E%,u)yT$%wB-h"> <mutation items="7"></mutation> <value name="ADD0"> <block type="text" id="sl$c^pl%uv$,DAw1m=j*"> <field name="TEXT">/usr/bin/plink</field> </block> </value> <value name="ADD1"> <block type="text" id="yCCq#+vAAnKZw$ysJGnq"> <field name="TEXT"> </field> </block> </value> <value name="ADD2"> <block type="text_join" id="qV,rtBh{N1D/CwzEJT)H" inline="true"> <mutation items="3"></mutation> <value name="ADD0"> <block type="variables_get" id="v7D^~-q]0+;B;LkOjr`T"> <field name="VAR" id="27F.R1Z-z#dt9y!]HCI?">user</field> </block> </value> <value name="ADD1"> <block type="text" id="G_)61Rk!)9YAJdO#Cb;g"> <field name="TEXT">@</field> </block> </value> <value name="ADD2"> <block type="variables_get" id="NQOYYEc,gZhThFshU#dP"> <field name="VAR" id=",W^G}X63.I8(oB$2R5LN">switch_ip</field> </block> </value> </block> </value> <value name="ADD3"> <block type="text" id="GI%FJFdK6tDwDaAV(GR}"> <field name="TEXT"> </field> </block> </value> <value name="ADD4"> <block type="text_join" id="w/}+A4)bW`bPU%aLp_s0" inline="true"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="HFn9=.|LOuW]@EtR~-z!"> <field name="TEXT">-pw </field> </block> </value> <value name="ADD1"> <block type="variables_get" id="_YE4H@jy@T5PLv#|pZy4"> <field name="VAR" id="]5sS^f/;5~_X{[qJ(FYE">pass</field> </block> </value> </block> </value> <value name="ADD5"> <block type="text" id="vcngU=$a@sU.KFJV(M]Z"> <field name="TEXT"> </field> </block> </value> <value name="ADD6"> <block type="text_join" id="8ZVCgZ`49GVa9FTSh+T]" inline="true"> <mutation items="6"></mutation> <value name="ADD0"> <block type="text" id="@MKQ]pE3nAdKG_!MGHh;"> <field name="TEXT">telnet localhost < </field> </block> </value> <value name="ADD1"> <block type="text" id="m2dW(p,Jz#rHJUX9qy0O"> <field name="TEXT">/opt/iobroker/my-assets/unifi-switch/</field> </block> </value> <value name="ADD2"> <block type="text" id="TFd)l7KmteD?MJD9PgP_"> <field name="TEXT">unifi-switch-poe-port-</field> </block> </value> <value name="ADD3"> <block type="variables_get" id="XHh~`ZL1Cv:-!g]{VC/5"> <field name="VAR" id="~;w%BJ+Dfcj?tZ^fn?j8">switch_port</field> </block> </value> <value name="ADD4"> <block type="text" id="iyE}^dII0oex`iee`tvv"> <field name="TEXT">-</field> </block> </value> <value name="ADD5"> <block type="variables_get" id="wFOKk(TAs7wBw].dG^Mf"> <field name="VAR" id="Hb~d6EqId4z}cn3|S8;t">switch_poe_status</field> </block> </value> </block> </value> </block> </value> <next> <block type="exec" id="xH1gguE:gcRGt|{B_w:0" inline="true"> <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG">log</field> <value name="COMMAND"> <shadow type="text" id="6,RZIj1g[D4Zp~@aH@D4"> <field name="TEXT"></field> </shadow> <block type="variables_get" id="p%,Qcf1{XBrX0j3bNHll"> <field name="VAR" id="VOiR$*N3m0]#z3=8[W.j">exec_cmd</field> </block> </value> </block> </next> </block> </statement> </block> <block type="comment" id="gVr2c[tbzaIXb6rrJX`d" x="-12" y="713"> <field name="COMMENT">switch-hwr port 8</field> <next> <block type="on_ext" id="{]p[ZUC,-3?/wl.J`1iM"> <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <value name="OID0"> <shadow type="field_oid" id="FuZ}IorQE69AV.k+tZv^"> <field name="oid">default</field> </shadow> <block type="text" id="?*ld,pFs;[m5nq$JravZ"> <field name="TEXT">javascript.0.System.Netzwerk.Unifi.switch-hwr-port-8-poe</field> </block> </value> <statement name="STATEMENT"> <block type="controls_if" id="K+;IX1I%$L`e}{IxACmT"> <mutation else="1"></mutation> <value name="IF0"> <block type="on_source" id="O}M+F1+QSKu%T1IZk[u$"> <field name="ATTR">state.val</field> </block> </value> <statement name="DO0"> <block type="procedures_callnoreturn" id="m(w,O:KnK|H9^V(AEcFZ" inline="false"> <mutation name="switch_poe"> <arg name="user"></arg> <arg name="pass"></arg> <arg name="switch_ip"></arg> <arg name="switch_port"></arg> <arg name="switch_poe_status"></arg> </mutation> <value name="ARG0"> <block type="text" id="R5)H|sVvP?jjgK$a?O?A"> <field name="TEXT">darkiop</field> </block> </value> <value name="ARG1"> <block type="text" id="+YOA%q^h5,VjLf1*t:UN"> <field name="TEXT">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</field> </block> </value> <value name="ARG2"> <block type="text" id="ZlVqO*HweXQ~4K{UFbSz"> <field name="TEXT">192.168.1.11</field> </block> </value> <value name="ARG3"> <block type="text" id="yFr8m{Wa1+9|0xh%*Q79"> <field name="TEXT">8</field> </block> </value> <value name="ARG4"> <block type="text" id="^}2j3D3}UJj9A`#|=|6A"> <field name="TEXT">on</field> </block> </value> </block> </statement> <statement name="ELSE"> <block type="procedures_callnoreturn" id="Iy.3els1$05vLNCeFA3X" inline="false"> <mutation name="switch_poe"> <arg name="user"></arg> <arg name="pass"></arg> <arg name="switch_ip"></arg> <arg name="switch_port"></arg> <arg name="switch_poe_status"></arg> </mutation> <value name="ARG0"> <block type="text" id="OewgXnT!x39J{zO)[I2t"> <field name="TEXT">darkiop</field> </block> </value> <value name="ARG1"> <block type="text" id="EQ]gZb/KoY.N)8wq4oMZ"> <field name="TEXT">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</field> </block> </value> <value name="ARG2"> <block type="text" id="~LC?zr-S*MYc}u_b5x/1"> <field name="TEXT">192.168.1.11</field> </block> </value> <value name="ARG3"> <block type="text" id="nUY}q7tE#-y:W8ezciJo"> <field name="TEXT">8</field> </block> </value> <value name="ARG4"> <block type="text" id="a8BT{4w8nB:FQ{2:nI8J"> <field name="TEXT">off</field> </block> </value> </block> </statement> </block> </statement> <next> <block type="comment" id="LcN$z9lIebQ7u3f+1G4D"> <field name="COMMENT">switch-hwr port 9</field> <next> <block type="on_ext" id="P*l;u,Kzo;n6/Q!!*Dz8"> <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <value name="OID0"> <shadow type="field_oid"> <field name="oid">default</field> </shadow> <block type="text" id="b$$l4RLR|UyfY5w*TCAc"> <field name="TEXT">javascript.0.System.Netzwerk.Unifi.switch-hwr-port-9-poe</field> </block> </value> <statement name="STATEMENT"> <block type="controls_if" id="-[qKVSc@_x.Y6cPIo7d1"> <mutation else="1"></mutation> <value name="IF0"> <block type="on_source" id="-eQMowHnRf1]kVF2ulLF"> <field name="ATTR">state.val</field> </block> </value> <statement name="DO0"> <block type="procedures_callnoreturn" id="EXdmTEZnYp`t!(^+[MA(" inline="false"> <mutation name="switch_poe"> <arg name="user"></arg> <arg name="pass"></arg> <arg name="switch_ip"></arg> <arg name="switch_port"></arg> <arg name="switch_poe_status"></arg> </mutation> <value name="ARG0"> <block type="text" id="-e:oK]omzxrhADb)BTF#"> <field name="TEXT">darkiop</field> </block> </value> <value name="ARG1"> <block type="text" id="-y7cg!7v1KXp9((_%M]8"> <field name="TEXT">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</field> </block> </value> <value name="ARG2"> <block type="text" id="wk52#7}JF2THaDz8%goR"> <field name="TEXT">192.168.1.11</field> </block> </value> <value name="ARG3"> <block type="text" id="2Ue582hF|[$ePC}/p1,A"> <field name="TEXT">9</field> </block> </value> <value name="ARG4"> <block type="text" id="[b^.Q5~{(OnymKrC^1^d"> <field name="TEXT">on</field> </block> </value> </block> </statement> <statement name="ELSE"> <block type="procedures_callnoreturn" id="9)%]}jS~Da3#_p@P,+!_" inline="false"> <mutation name="switch_poe"> <arg name="user"></arg> <arg name="pass"></arg> <arg name="switch_ip"></arg> <arg name="switch_port"></arg> <arg name="switch_poe_status"></arg> </mutation> <value name="ARG0"> <block type="text" id="sL]%7XUzgon_$*nxmZYD"> <field name="TEXT">darkiop</field> </block> </value> <value name="ARG1"> <block type="text" id="c*D@Lj0QgRC$Lv9Cc]?X"> <field name="TEXT">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</field> </block> </value> <value name="ARG2"> <block type="text" id="Ai+8%6Kz6`550V,]dr5r"> <field name="TEXT">192.168.1.11</field> </block> </value> <value name="ARG3"> <block type="text" id=".4YmA-LT^#EcOTjdr$F1"> <field name="TEXT">9</field> </block> </value> <value name="ARG4"> <block type="text" id="F:`=IVts7P_$97jlabb("> <field name="TEXT">off</field> </block> </value> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </xml>