UBIQUITI mPower Steckdosenleiste Wlan

Begonnen von pipp37, 27 März 2015, 01:56:15

Vorheriges Thema - Nächstes Thema

pipp37

Hallo.
Hat schon jemand die Steckdosenleiste in Fhem eingebunden bzw. wie könnte ich die Leisten schalten und den Verbrauch in Fhem auslesen?
Ich habe  die 3 Port EU Version und habe bereits anderwertig in der Bash die Steuerung hinbekommen.
Weiters wird auch der Verbauch gemessen.
Das ganze hat eine Weboberfläche.

https://www.ubnt.com/mfi/mpower/
(https://ubcdn.co/media/images/product/mpower-eu/mpower-eu-product-model-small.png)



#AUTH
curl -X POST -d "username=admin&password=xxx" -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.71/login.cgi

# Check
curl -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.71/sensors/1

# Ausgabe check
{"sensors":[{"port":1,"output":1,"power":162.143707752,"enabled":0,"current":0.827338695,"voltage":225.050592422,"powerfactor":0.870836456,"relay":1,"lock":0,"prevmonth":0,"thismonth":0}],"status":"success"}

# Plug 1 off
curl -X PUT -d output=0 -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.71/sensors/1

# Plug 1 on
curl -X PUT -d output=1 -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.71/sensors/1



Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

rudolfkoenig

Bash Skripte kann man auch aus FHEM Aufrufen.
Die naechste Stufe ist eine richtig konfigurierte HTTPMOD Instanz, das wuerde auch das regelmaessige Melden der Messwerte ermoeglichen.
Die "richtige" Loesung waere ein FHEM Modul, das z.Bsp die FHEM Funktion HttpUtils_NonblockingGet verwendet.

Wzut

@pipp37 , obwohl du das Thema auch im EDIMAX / EDIPLUG Thread angesprochen hast schlage ich vor wir bleiben mit diesen Dosen hier
Da du schon Vorarbeit geleistet hast und bestimmt noch weitere Doku verfügbar ist sollte das kein unüberwindliches Hinderniss sein auf Basis des 98_EDIPLUG.pm Moduls auch diese Dosen fit für fhem zu machen. Z.Z. gibt es schon einen anderen Bruder davon -> http://forum.fhem.de/index.php/topic,34131.0.html
Was mir aber jetzt noch unklar ist, welche Art von Hilfe / Unterstützung möchtest du bei deinem Versuch mein Modul für die Dosen anzupassen ?   

Nachdem ich deinen Links gefolgt bin habe ich für Deutschland diesen Vertrieb gefunden : http://varia-store.com/Wireless-Systeme/UBIQUITI-mFi/Ubiquiti-Networks-mFI-mPower-3-Port-Power-EU-Wifi::1733.html ist das der Einzige oder gibt es jemand der die Dinger noch günstiger als 55 € verkauft ?



 
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

pipp37

#3
Hallo Wzut.
Ich habe mir den Thread zu dem Infratec auch duchgelesen und so wie ich das sehe, ist es für dich sicher einfacher, ein Ubiquiti Modul zu machen.
Das ist schon  sehr ähnlich mit dem Infratec und dem Ediplug. Speziell die Session-IDs  gibt es auch bei UBIQUITI.
Wärst du bereit dazu?

Ich könnte dir konkret wir folgt helfen.
Ich stelle dir eine neue  3fach Steckdosenleiste in meinem Netz mit einer Last am Port1 zur Verfügung und mache an meinem Mikrotik Router ein Portforwarding auf den Port 80 und auf den SSH port 22 der Dose. Die Zugangsdaten  sende ich dir  dann per PM.
Dann kannst du damit arbeiten. Weiters spiele ich die aktuelle Firmware auf.
https://community.ubnt.com/t5/mFi/mFi-release-2-1-8/m-p/1188368#U1188368

API:
https://community.ubnt.com/t5/mFi/mPower-mFi-Switch-and-mFi-In-Wall-Outlet-HTTP-API/m-p/1076449#U1076449



Da ich diese Dosen selbst in meinen 19" Rack nutze, kann ich auch die Funktionen testen. Die Verbrauchsmessung  einzubauen wäre dabei super.
Auch diese on-force & off-force Funktionen, die du im  Infratec  Thread erwähnt hast, wären perfekt.

Ich beziehe diese Produkte, da ich aus Österreich  und auch EDV-Händler bin, bei Assmann.
http://shop.assmann24.at/category.aspx?id=10000682
Dort kosten die 3fach Dosen rund 52,-- exkl. Ust. Du hast in Deutschland ja einen günstigen Händler gefunden.

Danke im Vorraus.
LG
PS: Wenn ich deine Antworten in den beiden Threads (Ediplug und Infratec) lese, habe ich den Eindruck, dass du auch  so ein "Freak" wie ich bist.
Wir machen diese Dinge ja nicht wegen dem Profit sondern   because we can.






Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

Wzut

Also gegen den Attribut "Freak" möchte ich schon mal Einspruch einlegen eher ein "hoffentlich" bald Rentner der in fast 40 Berufsjahren noch nie für Geld gearbeitet hat sondern stets nur für Ruhm und Ehre ....
Um von Anfang an eines gleich klarzustellen : Ich schraube an fhem bzw. seinen Modulen in meiner Freizeit, von der es mal mehr mal weniger gibt bzw. an manchen Tagen zieht es mich nach der Arbeit überhaupt nicht an den PC :) 

Was mir beim lesen der API aufgefallen ist der  folgende Satz :
ZitatHTTP basic auth isn't supported.  The script must login first by providing a username/password and a random cookie.
Bei der Infratec lies sich genau das umgehen. D.h. um mit der Leiste überhaupt reden zu können wird wohl zwingen ein weiter Schritt erforderlich sein.
Mach die Leiste mal starklar und schicke mir die Zugangsdaten als PM, ich schau dann mal in wie weit ich damit klar komme.
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

pipp37

#5
Hallo Wzut.
Per PM habe ich dir die Zugansdaten gesendet. Die Leiste ist mit einer Last am Port 1 Online.
Vielen Dank, dass du dir das ansehen willst.
LG



Der Telnet Zugang  ist standardmäßig auf Port 23  aktiviert.
Webpage: http://IP-mPower
Standardbenutzer/Passwort Web/Telnet ist ubnt/ubnt

Nach dem Telnet kommt man auf das Embedded Linux.
Webseiten in /usr/www
Dort befinden sich noch andere CGI Seiten.

API DOC:
http://community.ubnt.com/t5/mFi/mPower-mFi-Switch-and-mFi-In-Wall-Outlet-HTTP-API/m-p/1076449#U1076449


Diverse Infos
http://blog.vucica.net/2014/08/mfi-mpower-basic-use-without-cloud-and-controller.html
http://community.ubnt.com/t5/mFi/mPower-API/m-p/751666/highlight/true#M6783

Port1 in der Console  ein/aus

echo 1 >/proc/power/relay1 
echo 0 >/proc/power/relay1 





So läuft das alles schon.
Zuerst das Login mit einem Random Sessionkey dann mit dem Sessionkey die Befehle absetzen.

login
curl -X POST -d "username=ubnt&password=xxx" -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.211/login.cgi

info port1
curl -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.211/sensors/1

Port 1 aus
curl -X PUT -d output=0 -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.211/sensors/1

Port1 ein
curl -X PUT -d output=1 -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.211/sensors/1

logout
curl -b "AIROS_SESSIONID=01234567890123456789012345678901" 192.168.27.211/logout.cgi



REST API

MF.v2.1.8# cat README
REST API

Note: this is an unsupported interface, and might change or be removed in the future without warning.

TO DO:
- API key support (currently it's just cookie based)
- Add more sensor info (name, ...) to individual resource accesses (port, id, label, and model aren't currently returned)
- Add converted sensor value (not just voltage)
- Array or Object for multiple sensors
- success/failure indication on each resource, instead of per transcaction (since some might fail)
- add sensorId support as resource ID


USAGE:

url = /sensors[/<port>][/<resource>]

<port> = 1-based port (mPort = 1, 2, 3)
  PUT without a port (/sensors/relay) is used to set all ports

Note: must be logged in to use.  Persistent API keys are not currently supported.


EXAMPLES:

Get:

/sensors

/sensors/<port>
        Ex: /sensors/1

/sensors/<index>/<resource>
        Ex: /sensors/1/output1

Set (example uses jQuery):

// Turn on M2M port 3, digital out 1 (12v)
$.ajax({url:"/sensors/3",type:"PUT", data:{output1:12}})
// Turn off M2M port 3, digital out 1
$.ajax({url:"/sensors/3",type:"PUT", data:{output1:0}})

// Turn on M2M port 2, digital out 2
$.ajax({url:"/sensors/2",type:"PUT", data:{output2:12}})
// Turn off M2M port 2, digital out 2
$.ajax({url:"/sensors/2",type:"PUT", data:{output2:0}})



Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

Wzut

Ich habe heute etwas mit der Leiste "gespielt" , bisheriges Fazit :
Das Webinterface sieht schön aus , ist aber elend langsam
Die http Ochsentour mit Session Login , Antwort  abwarten , Befehl senden , Antwort ist irgendwie umständlich ....

Aber, das Teil hat ja auch  ein Telnet Interface. Da ist wie es scheint alles verfügbar und es geht schön schnell :)
Hier mal ein simples Perl Script zur Status Abfrage der drei Ports :

#!/usr/bin/perl
use Net::Telnet;
$sock = new Net::Telnet();
$sock->open(     
           Host => "ip",
           Port => 23
          );
$sock->login(   
        Name => "ubnt",
        Password => "pass"
       );
@lines = $sock->cmd("cat /proc/power/relay1 /proc/power/relay2 /proc/power/relay3");
$sock->close;
pop @lines;
print @lines;
exit

ergibt beim ausführen :
pi@ras2 ~ $ ./telnet_test.pl
1
0
1
pi@ras2 ~ $

also was will man mehr ? die aktuellen Verbrauchswerte lassen sich genau so einfach abfragen.
Allerdings würde ich das später im fhem Modul nicht so direkt ausgeführen sondern mit Blocking_Call (http://www.fhemwiki.de/wiki/Blocking_Call)
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

pipp37

Die Leiste hat noch einiges mehr zu bieten.

http://IP-mPower/upgrade.cgi
http://IP-mPower/advanced.cgi
http://IP-mPower/services.cgi   (SSH einschalten - habe ich gemacht und per Portforwarding für Wzut freigeschaltet)




ls -l /usr/www

lrwxrwxrwx    1 ubnt     admin           1 Feb  9 23:48 150209.1448 -> .
-rwxr-x---    1 ubnt     admin          46 Feb  9 23:48 404.cgi
-rw-r--r--    1 ubnt     admin       22253 Feb  9 23:48 English.txt
-rwxr-x---    1 ubnt     admin        7952 Feb  9 23:48 advanced.cgi
lrwxrwxrwx    1 ubnt     admin          10 Feb  9 23:47 airmax.cgi -> status.cgi
drwxr-xr-x    2 ubnt     admin         118 Mar 26  2014 airos
-rw-r--r--    1 ubnt     admin        1313 Feb  9 23:48 ajax.js
-rwx------    1 ubnt     admin        3268 Feb  9 23:48 apply.cgi
-rwxr-xr-x    1 ubnt     admin         838 Feb  9 23:48 arp.cgi
drwxr-xr-x    2 ubnt     admin        1345 Feb  9 23:48 bin
-rw-r--r--    1 ubnt     admin          89 Feb  9 23:48 blank.html
-rw-r--r--    1 ubnt     admin        1607 Feb  9 23:48 bluecurve.css
-rwxr-x---    1 ubnt     admin         192 Feb  9 23:48 bounce.cgi
-rw-r--r--    1 ubnt     admin        4262 Feb  9 23:48 boxsizing.htc
-rwxr-xr-x    1 ubnt     admin         766 Feb  9 23:48 brmacs.cgi
-rwxr-x---    1 ubnt     admin       15846 Feb  9 23:48 captive.cgi
-rwxr-x---    1 ubnt     admin         383 Feb  9 23:48 captivepoll.cgi
-rwxr-x---    1 ubnt     admin         454 Feb  9 23:48 cfg.cgi
-rwxr-x---    1 ubnt     admin         548 Feb  9 23:48 config.cgi
drwxr-xr-x    3 ubnt     admin         100 Feb  9 23:48 css
-rwxr-xr-x    1 ubnt     admin        2282 Feb  9 23:48 dhcp.cgi
-rwx------    1 ubnt     admin         488 Feb  9 23:48 discard.cgi
-rw-r--r--    1 ubnt     admin        1406 Feb  9 23:48 favicon.ico
-rwxr-x---    1 ubnt     admin       12371 Feb  9 23:48 firewall.cgi
-rwxr-xr-x    1 ubnt     admin         477 Feb  9 23:48 fw.cgi
-rwx------    1 ubnt     admin        1819 Feb  9 23:48 fwflash.cgi
drwxr-xr-x    3 ubnt     admin          28 Mar 19  2013 help
-rw-r--r--    1 ubnt     admin        1144 Feb  9 23:48 help.css
-rw-r--r--    1 ubnt     admin         415 Feb  9 23:48 help.js
drwxr-xr-x    2 ubnt     admin        2316 Feb  9 23:48 images
-rwxr-x---    1 ubnt     admin       26013 Feb  9 23:48 index-content.cgi
-rwxr-xr-x    1 ubnt     admin        1050 Feb  9 23:48 index.cgi
-rw-r--r--    1 ubnt     admin         297 Feb  9 23:48 index.html
-rwxr-xr-x    1 ubnt     admin         350 Feb  9 23:48 info.cgi
-rwxr-x---    1 ubnt     admin        5697 Feb  9 23:48 ipalias.cgi
drwxr-xr-x    3 ubnt     admin          31 Feb  9 23:48 ipkg
lrwxrwxrwx    1 ubnt     admin          10 Feb  9 23:47 ipscan.cgi -> status.cgi
drwxr-xr-x    2 ubnt     admin         367 Feb  9 23:48 js
-rwxr-xr-x    1 ubnt     admin        3142 Feb  9 23:48 jsl10n.cgi
-rw-r--r--    1 ubnt     admin       10578 Feb  9 23:48 jsval.js
-rwxr-x---    1 ubnt     admin        4806 Feb  9 23:48 language.cgi
-rwxr-xr-x    1 ubnt     admin        1493 Feb  9 23:48 leases.cgi
-rwxr-x---    1 ubnt     admin         198 Feb  9 23:48 leaveap.cgi
drwxr-xr-x    3 ubnt     admin        1373 Feb  9 23:48 lib
-rwxr-x---    1 ubnt     admin        7838 Feb  9 23:48 link.cgi
-rwxr-xr-x    1 ubnt     admin         529 Feb  9 23:48 log.cgi
-rwxr-xr-x    1 ubnt     admin        3515 Feb  9 23:48 login.cgi
-rw-r--r--    1 ubnt     admin         682 Feb  9 23:48 login.css
-rwxr-xr-x    1 ubnt     admin         383 Feb  9 23:48 logo.cgi
-rwxr-xr-x    1 ubnt     admin         179 Feb  9 23:48 logout.cgi
-rwxr-x---    1 ubnt     admin       32543 Feb  9 23:48 m2m.cgi
-rwxr-x---    1 ubnt     admin         206 Feb  9 23:48 main.cgi
drwxr-xr-x    2 ubnt     admin         292 Feb  9 23:48 mfi
-rwxr-x---    1 ubnt     admin       10116 Feb  9 23:48 mfi.cgi
-rwxr-x---    1 ubnt     admin        2437 Feb  9 23:48 network.cgi
-rw-r--r--    1 ubnt     admin        4575 Feb  9 23:48 network.js
-rwxr-xr-x    1 ubnt     admin         410 Feb  9 23:48 pfw.cgi
-rwxr-x---    1 ubnt     admin         246 Feb  9 23:48 ping.cgi
-rwxr-xr-x    1 ubnt     admin        5547 Feb  9 23:48 pingtest.cgi
-rw-r--r--    1 ubnt     admin         537 Feb  9 23:48 pingtest.css
-rw-r--r--    1 ubnt     admin        6483 Feb  9 23:48 pingtest.js
-rwxr-xr-x    1 ubnt     admin         765 Feb  9 23:48 pingtest_action.cgi
-rwxr-xr-x    1 ubnt     admin         111 Feb  9 23:48 poll.cgi
-rwxr-x---    1 ubnt     admin        7147 Feb  9 23:48 port_forward.cgi
-rwxr-x---    1 ubnt     admin        7623 Feb  9 23:48 power.cgi
-rw-r--r--    1 ubnt     admin        2491 Feb  9 23:48 progress.js
-rw-r--r--    1 ubnt     admin        6075 Feb  9 23:48 range.js
-rwx------    1 ubnt     admin        1585 Feb  9 23:48 reboot.cgi
-rwx------    1 ubnt     admin        1738 Feb  9 23:48 reset.cgi
-rwxr-x---    1 ubnt     admin          73 Feb  9 23:48 restore-default.cgi
-rwxr-x---    1 ubnt     admin        4287 Feb  9 23:48 scan_channels.cgi
-rwxr-xr-x    1 ubnt     admin          46 Feb  9 23:48 sensors
-rwxr-x---    1 ubnt     admin        7154 Feb  9 23:48 services.cgi
-rwxr-x---    1 ubnt     admin         483 Feb  9 23:48 setup.cgi
lrwxrwxrwx    1 ubnt     admin          10 Feb  9 23:47 signal.cgi -> status.cgi
-rw-r--r--    1 ubnt     admin        1847 Feb  9 23:48 signal.js
-rwxr-xr-x    1 ubnt     admin        4584 Feb  9 23:48 signal_gui.cgi
-rw-r--r--    1 ubnt     admin       16426 Feb  9 23:48 slider.js
-rw-r--r--    1 ubnt     admin       20522 Feb  9 23:48 slink.js
-rw-r--r--    1 ubnt     admin         278 Feb  9 23:48 small.css
-rw-r--r--    1 ubnt     admin        5129 Feb  9 23:48 sorttable.js
-rwxr-xr-x    1 ubnt     admin         310 Feb  9 23:48 speedlaunch.cgi
-rwxr-xr-x    1 ubnt     admin        7239 Feb  9 23:48 speedtest.cgi
-rw-r--r--    1 ubnt     admin         805 Feb  9 23:48 speedtest.css
-rw-r--r--    1 ubnt     admin        6205 Feb  9 23:48 speedtest.js
-rwxr-xr-x    1 ubnt     admin        3816 Feb  9 23:48 speedtest_action.cgi
-rwxr-xr-x    1 ubnt     admin        1223 Feb  9 23:48 sroutes.cgi
-rwxr-xr-x    1 ubnt     admin        1861 Feb  9 23:48 stainfo.cgi
-rwxr-xr-x    1 ubnt     admin        2361 Feb  9 23:48 stalist.cgi
-rw-r--r--    1 ubnt     admin        1056 Feb  9 23:48 status-403.html
-rw-r--r--    1 ubnt     admin        1049 Feb  9 23:48 status-404.html
-rw-r--r--    1 ubnt     admin        1119 Feb  9 23:48 status-500.html
-rwxr-xr-x    1 ubnt     admin       44432 Feb  9 23:47 status.cgi
-rw-r--r--    1 ubnt     admin       27689 Feb  9 23:48 style.css
-rwxr-x---    1 ubnt     admin        2607 Feb  9 23:48 support.cgi
-rwxr-x---    1 ubnt     admin         630 Feb  9 23:48 survey.cgi
-rw-r--r--    1 ubnt     admin         133 Feb  9 23:48 survey.css
-rwxr-x---    1 ubnt     admin         172 Feb  9 23:48 survey.json.cgi
-rwxr-x---    1 ubnt     admin       12928 Feb  9 23:48 system.cgi
-rw-r--r--    1 ubnt     admin        5524 Feb  9 23:48 system.js
-rwx------    1 ubnt     admin       12817 Feb  9 23:48 test.cgi
-rwx------    1 ubnt     admin         163 Feb  9 23:48 testdone.cgi
-rwxr-xr-x    1 ubnt     admin         132 Feb  9 23:48 throughput.cgi
-rw-r--r--    1 ubnt     admin        6407 Feb  9 23:48 throughput.js
-rwxr-x---    1 ubnt     admin        3053 Feb  9 23:48 ticket.cgi
-rw-r--r--    1 ubnt     admin        4232 Feb  9 23:48 timer.js
-rwxr-xr-x    1 ubnt     admin        9652 Feb  9 23:48 toggle-switch.css
-rw-r--r--    1 ubnt     admin        1928 Feb  9 23:48 tools.js
-rwxr-xr-x    1 ubnt     admin        3017 Feb  9 23:48 traceroute.cgi
-rw-r--r--    1 ubnt     admin         523 Feb  9 23:48 traceroute.css
-rw-r--r--    1 ubnt     admin        4515 Feb  9 23:48 traceroute.js
-rwxr-xr-x    1 ubnt     admin        3314 Feb  9 23:48 traceroute_action.cgi
-rwx------    1 ubnt     admin         932 Feb  9 23:48 upgrade.cgi
-rw-r--r--    1 ubnt     admin       13176 Feb  9 23:48 util.js
-rw-r--r--    1 ubnt     admin        6981 Feb  9 23:48 ws.html

Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

pipp37

#8
Hallo Wzut.
Über Telnet oder SSH (nun enabled) kann alles gesteuert werden. Das WebIf ist im lokalen Netz mit annehmbarer Geschwindigkeit schon zu gebrauchen.
Besser ist es allerdings so wie du es mit dem Telnet Interface machen möchtest. Da hast du wirklich alle Möglichkeiten.



Hintergrundinfos:
Jede volle Stunde werden die Verbrauchdaten mit einem cronjob (crontab -e) nach /etc//etc/persistent/data geschrieben.
/etc/persistent ist der nichtflüchtige Speicher der Leiste.

crontab -e
45 23 * * * echo 0 > /dev/output1
0 * * * * /usr/etc/mfi/hourly_cf_count.sh


In diesen Files werden die Werte gespeichert und können dann von deinem Fhem Modul ausgewertet werden.
MF.v2.1.8#  ls -l /etc/persistent/data
-rw-r--r--    1 ubnt     admin          95 Mar 28 23:00 2015-03-28
-rw-r--r--    1 ubnt     admin         724 Mar 29 23:00 2015-03-29
-rw-r--r--    1 ubnt     admin         728 Mar 30 17:28 2015-03-30
-rw-r--r--    1 ubnt     admin           4 Mar 30 17:28 2015-03:1
-rw-r--r--    1 ubnt     admin           5 Mar 30 17:28 2015-03:2
-rw-r--r--    1 ubnt     admin           4 Mar 30 17:28 2015-03:3





Diverse Infos zum Board der Leiste


MF.v2.1.8# cat  /etc/board.info
board.sysid=0xe653
board.cpurevision=0x00000111
board.revision=13-00000-00
board.name=mPower
board.shortname=P3E
board.subtype=
board.hwaddr=24A43C8A1112
board.reboot=30
board.upgrade=150
board.phycount=0
radio.1.name=
radio.1.shortname=
radio.1.bus=ahb
radio.1.subsystemid=0xe653
radio.1.subvendorid=0x0777
radio.1.txpower.max=23
radio.1.txpower.offset=5
radio.1.antennas=1
radio.1.def_antenna=4
radio.1.antenna.1.id=4
radio.1.antenna.1.name=Combined
radio.1.antenna.1.gain=0
MF.v2.1.8#





In /proc/power gibt es noch mehrere interessante Werte.

Anzeige des aktuellen Energiezählerstandes:

cat cf_count*
cat energy_sum*




Ich habe diese Befehle samt Infos aus diesem Thread genommen.


http://community.ubnt.com/t5/mFi/mPower-API/m-p/751666/highlight/true#M6783


In case it escaped your attention, the current mPower firmware has added a "Controls" tab to the web admin page. From this page you can read the parameter values and turn the outlets ON or OFF.

But if you still want CLI access, what follows should get you started.  I'm unaware of any documentation for this interface.  I can only tell you what I have learned by exploration.

Connect to the mPower with SSH or telnet.

Position to /proc/power.

Issue this command:

ls -l

You will see a long list of interesting files. This is a virtual file system that provides access to the hardware components.

The outlets 1, 2, and 3 are represented by files "relay1", "relay2", and "relay3" respectively. You can read each of these to determine its ON/OFF status; "0" is OFF, "1" is ON.

cat relay1

Or you can read the whole trio with a single command.

cat relay*



To switch an outlet to ON or OFF, simply write a "1" or "0" respectively to the relay number of interest.

echo 1 > relay1



You can read values from some of these virtual files, but first you must confirm that values are being measured.  They probably are if the mFi controller is managing things, but if not you can make it so anyway.  First check:

cat enabled*

returns the "enabled" status of all three outlets.  "0" is disabled, so you must change this to "1" if you expect to get values.

echo 1 > enabled1
echo 1 > enables2
echo 1 > enabled3


or whatever pattern is needed for the outlets of interest.  Now you can fetch some values.

cat active_pwr1

returns the power factor corrected power demand on outlet 1.

cat v_rms1

returns the RMS voltage at outlet 1.  This will be zero if the outlet is off.

cat i_rms1

returns the RMS current delivered via outlet 1.

cat pf1

returns the power factor associated with the load on outlet 1.

cat energy_sum1

returns the totalized energy in Watt-hours delivered via outlet1.  I think this total starts at boot-up but haven't confirmed this.

There are plenty of other virtual files whose purpose has escaped me.



Here's another interesting place:

cd /proc/led



Here you will find two more virtual files to tamper with. "freq" controls the pilot LED flash rate (steady on is "0") while "status" controls the LED color.


Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

pipp37

#9
http://IP-Mpower/mfi/sensors.cgi

{

    "sensors":

[

{

    "port": 1,
    "output": 1,
    "power": 2.488473057,
    "enabled": 0,
    "current": 0.03180027,
    "voltage": 214.948433876,
    "powerfactor": 0.364055711,
    "relay": 1,
    "lock": 0,
    "thismonth": 650

},
{

    "port": 2,
    "output": 1,
    "power": 1246.514841258,
    "enabled": 0,
    "current": 5.812564373,
    "voltage": 214.898181438,
    "powerfactor": 0.997922782,
    "relay": 1,
    "lock": 0,
    "thismonth": 7937

},

        {
            "port": 3,
            "output": 1,
            "power": 34.419511079,
            "enabled": 0,
            "current": 0.16068238,
            "voltage": 214.774460792,
            "powerfactor": 0.997364264,
            "relay": 1,
            "lock": 0,
            "thismonth": 288
        }
    ],
    "status": "success"

}


WEB-UI - power.cgi.
Am Port 2 wurde mal kurzerhand ein Heizlüfter angeschlossen um ein paar Werte zu generieren.

(http://s2.postimg.org/wmotfg46h/ubi_ui1.jpg)

Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

Wzut

#10
Hier mal eine auf die Ubi Leiste angepasste Version des 98_InftratecPM Moduls -> 98_UbiquitiMP.pm
Ist noch Beta und noch nicht auf Blocking_Call angepasst, verwendet 98_InftratecOut.pm als Subdevice für jeden Port. Port Anzahl wird beim ersten Status Update autom. ermittelt ( z.B. 2,3 & 6) , danach stehen erst die set Kommandos on/off zur Verfügung.
Benötigt zwingend das Perl Net::Telnet Modul , also entweder via CPAN installieren oder auf einem Debian System mit  apt-get install libnet-telnet-perl


Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

pipp37

Hallo Wzut.
Super, das ging ja schnell. Danke.
Ich habe deine PMs installiert und kann schon die Leisten normal schalten.

Ich checke mal deinen Source und hoffe, dass ich durchblicke.
Weiters schreibe ich gerade in paar Fhem Shell Scripts für die Ubiquiti Leiste - dann werden Funktionen wie on-for-timer oder off-for-timer (Für Serverreboots).
Diese Dinge bauen wir dann so  ein, damit dein Ubiquiti Fhem Modul einfach für jedermann benutzbar wird.

/proc/power/energy_sum[1-3] gibt nur den aktuellen Zählerstand nach einem Neustart/Stromausfall der Leiste an.
Ob das Wattstunden sind oder nicht muß ich noch überprüfen.

Am besten lösen wir das wie in der Steckdosenleiste von Homematic HM-ES-PMSw1-Pl. Dort wird ein Reading energyOffset  erstellt, welches mit dem letzten Wert vor einem Stromausfall gefüllt wird.
Auch das eState Reading wäre super.



Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

pipp37

Hallo.
Ich konnte mich etwas einlesen und habe einige Änderungen gemacht.
Alles noch sehr Beta aber es funktioniert.

Nachdem ich alle erforderlichen Readings definiert habe, darf ich dich Wzut bitten, diese in das finale Modul zu integrieren. Danke.

Anbei ein Auszug:

Vmware-ESX-VM-Ubuntu 16.04 Docker Main-FHEM -> Raspberry Pi-B ser2net
HMLAN mit HomeMatic, Busware SCC433 stacked SCC868 (culfw), Jeelink, MAX Heizkörperthermostate, Enigma2 (Vudo2/DM800SE), Philips 55" Ambilight PHTV - WMBUS EnergyCam+Engelmann FAW, Intertechno-Komponenten, Ubiquiti mPower

Wzut

Zitat von: pipp37 am 30 März 2015, 23:56:49
dann werden Funktionen wie on-for-timer oder off-for-timer (Für Serverreboots).
Auch das eState Reading wäre super.

Ähh drei  Dinge verstehe ich nun nicht ,
wozu benötigt man fhem shell scripte ?
on-for-timer und alle Varianten dazu wird von den Set Extensions abgedeckt welche im 98_InfratecOut.pm eingebunden sind.
was ist das eState anderres als eine nochmalige Anzeige  von schon vorhandenen Readings ?

axo und dann verrate doch auch bitte welche /proc/power Datei sich hinter welchem gewünschtem Reading versteckt ... :)
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

carlos

Hallo,
Bei Amazon gibt's die Teile auch, auch in einer 6 port version.
http://www.amazon.de/Ubiquiti-mPower-Pro-UbiQuiti-6-port-Power/dp/B00CUFH47A/ref=sr_1_1?ie=UTF8&qid=1427781310&sr=8-1&keywords=Ubiquiti+Networks+mFI%2C
Ich nehme an, dass diese gleich gebaut ist nur mit 6 ports.
Wäre nett, wenn ihr darauf achtet, dass das module auch das 6 port modell mit abdeckt.
Das Teil und eure Arbeit gefällt mir, mal schauen ob ich es mir besorge, dann kann ich mich als Tester anbieten.
Gruß
Carlso
FHEM svn auf Intel NUC mit proxmox, 3 Raspberry Pi, signalduino, nanoCUL,  toom Baumarkt Funksteckdosen, einige sonoffs, hue, shelly