magcode / mpower-tools

Tools for operating Ubiquiti Networks mPower devices
Apache License 2.0
60 stars 46 forks source link

Clarification on the guide /mqtt/client #19

Open spyrito79 opened 3 years ago

spyrito79 commented 3 years ago

I openend a new topic to better explain my problem. I haven't given you all the information on my real problems and I'm sorry.

For instance: What is the command to have output on your guide?

homie/mpower-1/port1/relay=0 homie/mpower-1/port2/relay=1 homie/mpower-1/port3/relay=0 homie/mpower-1/port1/power=0.0 homie/mpower-1/port2/power=7.2 homie/mpower-1/port3/power=0.0 homie/mpower-1/port1/energy=0 homie/mpower-1/port2/energy=4 homie/mpower-1/port3/energy=8 homie/mpower-1/port1/voltage=0.0 homie/mpower-1/port2/voltage=234.9 homie/mpower-1/port3/voltage=0.0

And this below:

homie/mpower-1/$homie=2.1.0 homie/mpower-1/$name=mpower-1 homie/mpower-1/$fw/version=MF.v2.1.11-mq-0.2 homie/mpower-1/$fw/name=mPower=MQTT homie/mpower-1/$localip=192.168.1.26 homie/mpower-1/$nodes=port1,port2,port3 homie/mpower-1/$stats/uptime=2589629.67 homie/mpower-1/port1/relay/$settable=true homie/mpower-1/port2/relay/$settable=true homie/mpower-1/port3/relay/$settable=true homie/mpower-1/port1/lock/$settable=true homie/mpower-1/port2/lock/$settable=true homie/mpower-1/port3/lock/$settable=true

Control socket via MQTT

1 - You can control the sockets by sending 0 or 1 to the topic /port/relay/set

2 - You can lock the sockets by sending 0 or 1 to the topic /port/lock/set

Can you better explain these two point above? Also with referral links if you want

And then your last point in your guide: Integration in openHAB Where should I write this example of the script below?

Switch switchmp "My mpower switch" { mqtt=">[mosquitto:homie/mpower1/port1/relay/set:command:ON:1],>[mosquitto:homie/mpower1/port1/relay/set:command:OFF:0],<[mosquitto:homie/mpower1/port1/relay:state:MAP(mpowerrelay.map)]"} Number energymp "Energy consumption [%d Wh]" { mqtt="<[mosquitto:homie/mpower1/port1/energy:state:default]" } Number powermp "Current power [%.1f W]" { mqtt="<[mosquitto:homie/mpower1/port1/power:state:default]" }

I have installed openhab 2.5.4 on Ubuntu 18.04 server and I created mqtt binding and mqtt broker by web browser but i 'm not able to get openhab to communicate with mpower pro. What are my issue?

udo1toni commented 3 years ago

If you are using openHAB2.5.4, you're probably using the mqtt2 binding. My complete mfi thing (6ch):

     Thing topic mFi "mFi" @ "mqtt" {
          Type number : ch1Power "Leistung" [ stateTopic="homie/Steckdosen/port1/power" ]
          Type number : ch1Volt  "Spannung" [ stateTopic="homie/Steckdosen/port1/voltage" ]
          Type number : ch1Energy  "Energy" [ stateTopic="homie/Steckdosen/port1/energy" ]

          Type number : ch2Power "Leistung" [ stateTopic="homie/Steckdosen/port2/power" ]
          Type number : ch2Volt  "Spannung" [ stateTopic="homie/Steckdosen/port2/voltage" ]
          Type number : ch2Energy  "Energy" [ stateTopic="homie/Steckdosen/port2/energy" ]

          Type number : ch3Power "Leistung" [ stateTopic="homie/Steckdosen/port3/power" ]
          Type number : ch3Volt  "Spannung" [ stateTopic="homie/Steckdosen/port3/voltage" ]
          Type number : ch3Energy  "Energy" [ stateTopic="homie/Steckdosen/port3/energy" ]

          Type number : ch4Power "Leistung" [ stateTopic="homie/Steckdosen/port4/power" ]
          Type number : ch4Volt  "Spannung" [ stateTopic="homie/Steckdosen/port4/voltage" ]
          Type number : ch4Energy  "Energy" [ stateTopic="homie/Steckdosen/port4/energy" ]

          Type number : ch5Power "Leistung" [ stateTopic="homie/Steckdosen/port5/power" ]
          Type number : ch5Volt  "Spannung" [ stateTopic="homie/Steckdosen/port5/voltage" ]
          Type number : ch5Energy  "Energy" [ stateTopic="homie/Steckdosen/port5/energy" ]

          Type number : ch6Power "Leistung" [ stateTopic="homie/Steckdosen/port6/power" ]
          Type number : ch6Volt  "Spannung" [ stateTopic="homie/Steckdosen/port6/voltage" ]
          Type number : ch6Energy  "Energy" [ stateTopic="homie/Steckdosen/port6/energy" ]
      }

As I don't want to switch the sockets at all, I' did'nt create switch channels, but that would be

Type switch : ch1Switch "Schalter" [ commandTopic="homie/Steckdosen/port1/relay/set", stateTopic="homie/Steckdosen/port1/relay",on="1",off="0" ]
Type switch : ch1Lock "Sperre" [ commandTopic="homie/Steckdosen/port1/lock/set", stateTopic="homie/Steckdosen/port1/lock",on="1",off="0" ]

The lock is to disable switching at all. I have set this to ON to prevent unwanted poweroff for connected devices (as these are my servers... I'm using the mfi only for measurement)

spyrito79 commented 3 years ago

Hi thanks for your reply. I tried to copy your configuration on the folder things of openhab 2.5.4 but when i have entered in openhab GUI via web browser i didn't found your configuration. Anyway I set the mqtt binding and mqtt broker first but i don't know how to go on because , as I told you, the folder of your "things" didn't appear. In the end I also installed openhab 3.0 but the result is the same. May you help me with Openhab and mpower configurations with a teamwiever session? Obviously I'm going to pay for your disturb. If you are interest send me an email on gianpaolo.angelini79@gmail.com or write me via telegram looking for @root_toor

udo1toni commented 3 years ago

Maybe better to change to the official openHAB community: https://community.openhab.org/ mpower is not that special ;) in the end it's just another mqtt device.