LinuxMCE Forums
May 23, 2013, 07:12:32 pm GMT-1 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Rule #1 - Be Patient - Rule #2 - Don't ask when, if you don't contribute - Rule #3 - You have coding skills - LinuxMCE's small brother is available: http://www.agocontrol.com
 
   Home   Help Search Chat Login Register  
Pages: [1]
  Print  
Author Topic: A bit of help with some code...  (Read 294 times)
trippleg
Regular Poster
**
Posts: 25


View Profile
« on: November 17, 2011, 12:57:52 am »

I am trying to log an event and assign a template id once a string is found.  I am modifying existing code, but I can not figure it out.  Right now it assigns all devices to template 4, but I only want to assign 0x6B to template 4.  Below is the code.

Code:
when 0x05 # Climate Control
case $childdatabases[insteonID][0][2..3].hex
when 0x00; @work += 'Broan SMSC080 Exhaust Fan'
when 0x01; @work += 'Simplehomenet EZTherm'
when 0x02; @work += 'Broan SMSC110 Exhaust Fan'
when 0x03; @work += 'Venstar RF Thermostat Module'
when 0x04; @work += 'Simplehomenet EZStat Thermostat'
when 0x6B; @work += 'Venstar RF Thermostat Module'
end
@work += "\t\t4" # Set Template 4

any ideas??

Thanks.

-Gregg
Logged
JoakimL
Veteran
***
Posts: 149



View Profile
« Reply #1 on: November 17, 2011, 08:51:12 am »

Looking at http://www.techotopia.com/index.php/The_Ruby_case_Statement it seems the "then" statement should be used.

So the code could look like:
Code:
case $childdatabases[insteonID][0][2..3].hex @work +=
  when 0x00 then 'Broan SMSC080 Exhaust Fan'
  when 0x01 then 'Simplehomenet EZTherm'
  when 0x02 then 'Broan SMSC110 Exhaust Fan'
  when 0x03 then 'Venstar RF Thermostat Module'
  when 0x04 then 'Simplehomenet EZStat Thermostat'
  when 0x6B then 'Venstar RF Thermostat Module'
end

I'm not a Ruby expert in any way, just a hint... ;-)

/Joakim
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!