Module: Ansible::ZWave::ValueType_Byte

Defined in:
lib/ansible/zwave/openzwave/types/valuetype_byte.rb

Overview

byte value type for OpenZWave (0-255)

Instance Method Summary collapse

Instance Method Details

#as_canonical_valueObject

ZWave 1-byte values canonical form is a Fixnum between 0 and 255



42
43
44
45
46
47
48
# File 'lib/ansible/zwave/openzwave/types/valuetype_byte.rb', line 42

def as_canonical_value()
    return( case current_value
    when 0..255 then current_value
        else raise "#{self}: value #{current value} out of bounds 0..255"
        end
    )
end

#explainObject

return a human-readable representation of a ZWave frame



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ansible/zwave/openzwave/types/valuetype_byte.rb', line 62

def explain
    result = case @_commandClassId
    when 38 then 
        case @current_value
        when 0..99 then "#{@current_value} %"
        else "Off"
        end
    else "#{@current_value}"
    end    
    return(result)
end

#read_operationObject

define type-specific OZW::Manager API calls



33
34
35
# File 'lib/ansible/zwave/openzwave/types/valuetype_byte.rb', line 33

def read_operation 
    return :GetValueAsByte 
end

#to_protocol_value(new_val) ⇒ Object

ZWave 1-byte values protocol form is a Fixnum between 0 and 255



51
52
53
54
55
56
57
58
59
# File 'lib/ansible/zwave/openzwave/types/valuetype_byte.rb', line 51

def to_protocol_value(new_val)
    return( case new_val
        when TrueClass then 255
        when FalseClass then 0
        when 0..255 then new_val
        else raise "#{self}: value #{current value} out of bounds 0..255"
        end
    )
end

#write_operationObject



37
38
39
# File 'lib/ansible/zwave/openzwave/types/valuetype_byte.rb', line 37

def write_operation 
    return :SetValue_UInt8 
end