mFI mPower Pro: how to set relays ON or OFF
Posted: Saturday 13 February 2016 14:43
For those willing to control relays of mFI mPowerPro (6 outlets), I thought it might be interesting to have in one place everything that needs to be done in order to have Domoticz able to trigger the relays. Everything has been done using a Windows PC
Step 1: set a static IP address. There is no provision in the Web GUI to do that.
• Get the unit directly connected to your PC with an Ethernet cable.
• Set the PC Ethernet static address to 192.168.1.10
• WinSCP to mPowerPro using 192.168.1.20. User = ubnt, password = ubnt
• Edit /tmp/sytem.cfg, and modify it according the following instructions• Quit
• Log to the unit using SSH
• Hit Save, then Reboot. The unit shall have now a definitive static address. Connect mPowerPro and the PC to the regular network. Set the PC network interface to what it was before this step.
Step 2: update mPowerPro to the latest firmware as per these instructions: https://help.ubnt.com/hc/en-us/articles ... s-manually. I did it using SSH.
Step 3 (optional): you may wish to get the relays OFF when the unit boots (default behavior is ON).
• Log to the unit using WinSCP
• Edit /etc/persistent/vpower_cfg
• Add the following lines (if you wish to have all relays off at boot time)
• Save it, then enter cfgmtd -w -p /etc
Please bear in mind that at next boot time those 6 lines will be deleted, but the unit will behave as expected until the configuration of the unit is modified with the Web GUI.
Step 4: automate SSH login from Raspberry to mPowerPro.
Domoticz runs the script under root, so it is critical to get the public/private key created under root.
• Log to Raspberry using your preferred software (I’m using putty).
• Go to SU (you may need to activate this account the first time. Instructions are easily found on the Web)
• Private and public keys are in /root/.ssh. Copy id_rsa.pub to mPowerPro /var/etc/persistent/.ssh/authorized_keys
This is it, Domoticz will be able to send a script to mPowerPro without being asked a password.
Step 5: it is time to write the script. Mine stored in /home/pi/domoticz/scripts
First parameter sets the relay to be controlled (1 to 6), the second parameter (0 or 1) sets the relay OFF or ON.
Step 6: Create a virtual switch, then edit the ON and OFF action as per following for relay 1:
• ON - script:///home/pi/domoticz/scripts/switchOnOff.sh 1 1
• OFF - script:///home/pi/domoticz/scripts/switchOnOff.sh 1 0
Step 1: set a static IP address. There is no provision in the Web GUI to do that.
• Get the unit directly connected to your PC with an Ethernet cable.
• Set the PC Ethernet static address to 192.168.1.10
• WinSCP to mPowerPro using 192.168.1.20. User = ubnt, password = ubnt
• Edit /tmp/sytem.cfg, and modify it according the following instructions
Code: Select all
dhcpc.2.status=disabled
netconf.2.ip=staticIPAddress
netconf.2.netmask=netmask
route.1.status=enabled
Add the following lines
route.1.devname=eth1
route.1.gateway=(Put your gateway address here)
route.1.ip=0.0.0.0
route.1.netmask=0
• Log to the unit using SSH
• Hit Save, then Reboot. The unit shall have now a definitive static address. Connect mPowerPro and the PC to the regular network. Set the PC network interface to what it was before this step.
Step 2: update mPowerPro to the latest firmware as per these instructions: https://help.ubnt.com/hc/en-us/articles ... s-manually. I did it using SSH.
Step 3 (optional): you may wish to get the relays OFF when the unit boots (default behavior is ON).
• Log to the unit using WinSCP
• Edit /etc/persistent/vpower_cfg
• Add the following lines (if you wish to have all relays off at boot time)
Code: Select all
vpower.1.relay=off
vpower.2.relay=off
vpower.3.relay=off
vpower.4.relay=off
vpower.5.relay=off
vpower.6.relay=off
Please bear in mind that at next boot time those 6 lines will be deleted, but the unit will behave as expected until the configuration of the unit is modified with the Web GUI.
Step 4: automate SSH login from Raspberry to mPowerPro.
Domoticz runs the script under root, so it is critical to get the public/private key created under root.
• Log to Raspberry using your preferred software (I’m using putty).
• Go to SU (you may need to activate this account the first time. Instructions are easily found on the Web)
Code: Select all
ssh-keygen –t rsa <return>
Hit 3 times return
This is it, Domoticz will be able to send a script to mPowerPro without being asked a password.
Step 5: it is time to write the script. Mine stored in /home/pi/domoticz/scripts
Code: Select all
#! /bin/bash
ssh ubnt@mPowerProIPAddress "\$(echo $2 > /proc/power/relay$1)"
Step 6: Create a virtual switch, then edit the ON and OFF action as per following for relay 1:
• ON - script:///home/pi/domoticz/scripts/switchOnOff.sh 1 1
• OFF - script:///home/pi/domoticz/scripts/switchOnOff.sh 1 0