Setting up some Crypto miner rules

Hi All,

I’m setting up some crypto miner rules which will reboot the units if they fall offline outside of peak energy prices. I’ve got a proxy switch which indicates peak energy period, 2pm to 8pm weekly and I have presence detection working using port 22 and the network binding - this presence detection is using a group (switch type), with both my miner PC’s as part of it.

What I’m trying to work out is using a rule, when the the group (gMiners) receives an update that is outside of my 2pm to 8pm window ie: the Miner has gone OFF in offpeak energy period, then switch off it’s associated Aeotec Smart Switch (called AeonSocket6Sw1 here)and switch it back on (effectively power cycling) by using a timer of 3 minutes

How can I some how tie the Smart Switch to the Miner state - I know I could use the follow profile, but I dont want to do that in all instances

Effectively making my rule generic is the goal

Current rule:

var Timer MinerA_Timer = null
val Integer MinerA_TimeOut = 3

rule "Check Miner Presence and reboot if needed"
when
        Member of gMiners received command OFF
then
        if(triggeringItem.state == OFF && PeakEnergyPeriod.state == OFF){
            AeonSocket6Sw1.sendCommand(OFF)
             MinerA_Timer = createTimer(now.plusMinutes(MinerA_TimeOut)) [|
            AeonSocket6Sw1.sendCommand(ON)
        MinerA_Timer = null // Reset the timer after 3 minutes
        ]
}
end

Socket Switch item

/*ZWave Power Socket*/
Switch AeonSocket6Sw1   "Socket 6"                                    (gAllZWaveSwitches,PubItems_CMD)                                          { alexa="PowerController.powerState" }

Thanks!

I’m rebooting miners with openhab, but in a slightly different context. More if I get errors or some something is not right I first restart the mining software, if that is not working I shutdown.in a controlled manner, then turn off power and reboot. If it’s completely hung, I just reboot by cutting power.

I would not recommend that you cut power to the miner, better to shut it down in a controlled manner with a script and then turn power off. Especially if you do this frequently.

Take a look at the exec binding, if you have ssh available and you are running Linux you can execute commands remotely via ssh.

Regards S

1 Like

Thanks Seaside, do you have a sample linux script? Im running HiveOS

It can be really simple. I use an expect script do everything, but
you use something like:

#!/bin/bash -
ssh -t username@host “sudo reboot”

You would then need to to have access to sudo for the user and set up your ssh key in
the ~/.ssh/authorized_keys on the target machine (the miner) in order to not be password prompted.

Ta, becomes a bit complex/cumbersome if you reboot, then wait for a few minutes, then if its still unreachable, power off etc.

I dont see why power off is an issue. I use USB keys for the software.

So basically something like this?



rule "Check Miner Presence and reboot if needed"
when
        Member of gMiners received command OFF
then
        if(triggeringItem.state == OFF && PeakEnergyPeriod.state == OFF){
          executeCommandLine("sudo -u openhab ssh user@192.168.0.8 sudo reboot")
             MinerA_Timer = createTimer(now.plusMinutes(MinerA_TimeOut)) [|
            if(triggeringItem.state == ON){
        MinerA_Timer = null // Reset the timer after 3 minutes
            }
        ]
        }

end


I’d need then further logic to say, if the triggeringItem is still OFF, then kill the power to the Socket Switch

Simply the yanking the power from almost any computer, but especially Unix based computers and most especially any computer that is using flash memory of any kind (SD cards, USB thumb drives, SSD to a lesser extent) runs the risk of corrupting the file system.

Depending on how it’s configured, it may also lose important information like errors in the logs and stuff like that which may destroy the information you need to diagnose and fix the original problem.

Simply dropping power like that in some cases can be hard on the physical hardware itself causing capacitors to wear out or burst if they were poorly manufactured.

There is a reason computers have a shutdown and reboot command.

I would move that into a bash-script and execute the script instead. That way you can test the script outside of openhab.

You also need the -t flag.
so:

          executeCommandLine("path/my_ssh_script.sh")

And

#!/bin/bash -
ssh -t user@ user@192.168.0.8  “sudo reboot”

In order to add logic to check it once more you can use a timer that you start and when it times out you check if it is still OFF, and if so then you cut power.

Regards, S

Thank you for reply

Hmm, I think you should do as you think is best. A lot of people invest in crypto today. But if we do an analysis, we see that there are also many failures. Cryptocurrencies are very volatile and very risky. There are much better alternatives than investing in crypto, such as stocks. Stocks are not the most stable either, as the S & P 500 lost more than one-third of its value after the pandemic. But if you know how to use an fx economic calendar, it is very simple to be successful in trading, much simpler than in crypto. So I recommend you analyze these options and choose the most suitable one.