Method: KNX::ObjectServer::Datagram#add_action

Defined in:
lib/knx/object_server/datagram.rb

#add_action(index, data: nil, **options) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/knx/object_server/datagram.rb', line 79

def add_action(index, data: nil, **options)
    req = RequestItem.new
    req.id = index.to_i
    req.command = Commands[options[:command]] || :set_value
    if not data.nil?
        if data == true || data == false
            data = data ? 1 : 0
        end

        if data.is_a? String
            req.value = data
        else
            req.value = String.new
            req.value << data
        end
    end
    @data << req
    self
end