Sha256: 1ea83af60ff994dbd68d6be36dace13f1099ecf31aeb66e7467432021d817c29

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

module MQTT
  module Homie
    class Node < HomieObject
      homie_id
      homie_attr :name, required: true
      homie_attr :type, required: true
      homie_attr :properties, datatype: Array, required: true, immutable: true

      def property(id)
        @properties.find { |i| i.id == id }
      end

      def homie_attributes
        data = super

        @properties.each do |p|
          p.homie_attributes.each do |k, v|
            data[p.topic + "/" + k] = v
          end
          data[p.topic] = p.value
        end
        data
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mqtt-homie-0.1.1 lib/mqtt/homie/node.rb