Class: Ansible::Dimmer

Inherits:
Switch show all
Defined in:
lib/ansible/devices/ansible_dimmer.rb

Overview

a Dimmer is a Switch with additional capabilites (duh)

Instance Method Summary collapse

Methods inherited from Device

#initialize

Constructor Details

This class inherits a constructor from Ansible::Device

Instance Method Details



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ansible/devices/ansible_dimmer.rb', line 32

def link
    dimming = @hashmap[:dimming]
    status = @hashmap[:dimming_status]
    master = @hashmap[:master_control]
    unless dimming.is_a?AnsibleValue
        raise "#{self}.link: must supply AnsibleValues for :dimming!"
    end
    # map dimming value updates to master_control 
    dimming.add_callback(:onUpdate, self) { |sender, cb, args| 
        puts "   (#{sender.class}) #{sender} input value updated! args=#{args}"
        # convert value domains 
        cv = sender.as_canonical_value
        newval = master.to_protocol_value(cv)
        puts "   #{self} setting output #{output} +++ cv=#{cv} newval=#{newval}"
        target.set(newval)
        # also update status value, if defined
        status.set(newval) unless status.nil?                    
    }
    # also update dimming status value, if defined
    master.add_callback(:onUpdate, self) { |sender, cb, args|
        # convert value domains 
        cv = sender.as_canonical_value
        newval = master.to_protocol_value(cv)
        #
        status = @hashmap[:switch_status]
        puts "   updating dimming status value (#{status}) new val=#{newval}!"
        status.set(newval)
    } if status.is_a?AnsibleValue
    # call upstream linking method in Switch, if any
    super()
=begin
    knx_dimm_val.add_callback(:onUpdate) { |sender, cb, args| 
        puts "KNX value #{sender} updated! args=#{args} canonical=#{sender.as_canonical_value}"
        zwval = sender.current_value.data * 99 / 255 
        zwave_dimm_val.set(zwval.round) # FIXME convert value domains
    }
    if knx_dimmstatus_val then
        zwave_dimm_val.add_callback(:onUpdate) { | sender, cb, args|
            puts "ZWave value #{sender} HAS CHANGED #{args}"
            knxval = sender.current_value.data * 255 / 99
            knx_dimmstatus_val.set(knxval.round)
        }
    end
=end
end