Author Topic: A bit of help with some code...  (Read 2022 times)


  • Regular Poster
  • **
  • Posts: 25
    • View Profile
A bit of help with some code...
« 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: [Select]
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'
@work += "\t\t4" # Set Template 4

any ideas??




  • Veteran
  • ***
  • Posts: 149
    • View Profile
Re: A bit of help with some code...
« Reply #1 on: November 17, 2011, 08:51:12 am »
Looking at it seems the "then" statement should be used.

So the code could look like:
Code: [Select]
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'

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