Author Topic: How hard would it be to integrate a UPS system into LinuxMCE  (Read 12512 times)

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
I  was wondering if i could integrate my UPS into the core, so if i have a power out the core would send shutdown commands over ssh to over systems and shutdown its self.

I might be able to create some sort of script but i have no idea how to make it work with the core.
If you have any pointers on scripting like this then please help
« Last Edit: June 07, 2010, 11:25:37 pm by Riggs »
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

tkmedia

  • wants to work for LinuxMCE
  • **
  • Posts: 937
    • View Profile
    • LMCECompatible
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #1 on: June 07, 2010, 11:32:47 pm »
I would imagine you could make a device template especially if it's rs232 .  and you could fire events based on power outages and send the core a halt message.


I am sure Thom could expand on this.



Tim
My Setup http://wiki.linuxmce.org/index.php/User:Tkmedia

For LinuxMce compatible  systems and accessories
http://lmcecompatible.com/

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #2 on: June 07, 2010, 11:45:16 pm »
I forgot about the template system, im still learning, my ups is USB Rocketfish 1025VA similar to the cyberpower powerpannel brand.

I'm just this minute reading up on NUT, there are three config files to edit http://www.linux.com/archive/feature/128099
the next thing after that is to work out how to send the command through ssh, that way you can shutdown windows to using Cygwin
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #3 on: June 07, 2010, 11:58:40 pm »
Or in case of not having a smart UPS (with RS-232 interface), you can build your own sensor.... using a resistor, relay and make the RS-232 interface. See http://www.linuxjunkies.org/html/UPS-HOWTO.html
In my early days as sysadmin, i had one of this self-build sensor and the daemon... and it worked for years....  just adjusting times when the UPS battery banks changed.

« Last Edit: June 08, 2010, 12:01:24 am by pw44 »

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #4 on: June 08, 2010, 12:18:12 am »
well i don't need to build that but good info though.

I guess at some point I'm gonna have to buy an rs232 card, but then my question is why do i need to go back in time when we have USB it's like the TV card linux will support the old one and not the new ones.
Anyway, I'm guessing i would need to install NUT as it does have the drivers for the unit but i cant find how i can get nut to run a bash script on events or even integrate NUT with the core,
Remember I'm new so thing don't look easy to me
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #5 on: June 08, 2010, 12:31:36 am »
An USB to RS232 converter will be cheaper than buying a card.
« Last Edit: June 08, 2010, 01:20:35 am by pw44 »

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #6 on: June 08, 2010, 12:38:19 am »
thanks i will look into that
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

skeptic

  • Addicted
  • *
  • Posts: 615
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #7 on: June 08, 2010, 12:49:28 am »
Maybe I'm missing something, but if you lose power then either the other computers are on a UPS of their own (or are a laptop) or they are already down.  Unless of course it's just local to the core, knocked power cord out or tripped a breaker, in which case the other systems will continue to have power.  If the other computers have their own UPS it makes sense for each of them to monitor their own.

The ups/controlled shutdown on power loss is a good idea, I'm just a bit confused as to the benefit of trying to shutdown other systems when you lose power on the core.  
« Last Edit: June 08, 2010, 12:52:23 am by skeptic »

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #8 on: June 08, 2010, 12:59:26 am »
Not every system is gonna be PXE booted i look at LinuxMCE as a brain for the house, that controls everything possible.
In having the core communicate with the UPS it can a lot more function like for alarm systems etc.
My system can keep power to three PC's for around 30 minutes and I tested it with just the core and it kept it up for 64 minutes.
All my PC's are connected to the UPS power source but only one PC can communicate with the UPS unit.
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #9 on: June 08, 2010, 01:18:25 am »
So, all the 3 pcs and the core can get an USB to RS-232 adapter (around US$ 2,50 on ebay) and run the powerd or upsd daemon.
When there's a power outage, they will shutdown in 20 minutes.
The relay power feed will be done by the normal electrical line (not connected to the UPS).
Cheap, simple, clean.
Check which ones are supported by the linux kernel (google will help).

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #10 on: June 08, 2010, 01:29:29 am »
Any DCE device can emit events, that the rest of the system can respond to. If you can communicate with the UPS, and get status data, then you can write a DCE device with DCEGen (for C++), or GSD (using Ruby). Events can be added by the Web Admin, into the database, and from that point, referenced by the code.

-Thom

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #11 on: June 08, 2010, 01:31:26 am »
What would be the easy rout for a none programmer
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #12 on: June 08, 2010, 01:34:00 am »
*hmm*

This is how it is...

I just laid it out what you needed to do...so... either you have two options:

(1) you do it.
(2) you pay someone else to do it.

There is no way to DUCT TAPE IT.

Cold hard facts.

If you want it bad enough, code it. All the tools are available to do so.

-Thom

Riggs

  • Guru
  • ****
  • Posts: 185
    • View Profile
    • Kotonix LLC
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #13 on: June 08, 2010, 01:59:16 am »
 i am willing to code it other wise i would not of ask "What would be the easy rout for a none programmer" in the terms of what language would be easiest to get it going and maybe some pointers as to how i would integrate with MCE, yes i can read all the wiki's and faq's out there if i want to create it next year or i could get a point in the right direction and getting it done with in a month or so. not every one is lazy in the forum that asks for help.
Sorry but I don't mean to write like this but i did not mean to get a response like that as if to imply that i'm lazy or in fact dumb.
Dell XPS Gen5 P4 3.2Ghz 64 x2, 3Gbs Ram, GeForce 8600GT 1Gb VRam, Creative Audigy 2 ZS, LinuxMCE 10.04 32bit,, 2 Eth Cards, Comcast business 25Mbs/5Mbs. Zwave, X10, Vera 3.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: How hard would it be to integrate a UPS system into LinuxMCE
« Reply #14 on: June 08, 2010, 02:17:02 am »
You can write DCE devices in one of two languages.

C++, which means you use DCEGen.
Ruby, which means you use GSD.

You specify which one you wish to use, when you create the new device template.

The purpose of the device template, is to define what it is, what commands and events the device can emit and accept, and any information the plug and play plugin can use to determine how to detect the device. There are plenty of links to allow the creation of new Manufacturers, device categories, command and event categories, and new events and commands, as needed..but please, only do this if an appropriate group does not exist.

Once this device template has been created, it can be checked into sqlCVS. Once it has been checked in and approved in sqlCVS, you can run DCEGen (if it is C++), or start writing the Device Template in the Edit Ruby Codes section of the device template. If you choose the latter, you should check in your code changes via sqlCVS.

If it is a C++ device, then DCEGen should be run from src/DCEGen of your source code checkout, followed by sql2cpp from src/sql2cpp to generate the needed constants. These packages can be installed via apt as pluto-dcegen and pluto-sql2cpp respectively, and since they are installed in /usr/pluto/bin, you'll need to use the full path to refer to them.

DCEgen will create a full C++ project, with all the scaffolding needed, you fill in the blanks of each command method with code to deal with the commands. For events, you'd have to spawn a thread, and emit events within it.

There are plenty of example devices in both the Ruby and C++ realm, that can help you. Hopefully this should give you enough to start digging for info.

-Thom