Sha256: fda23532d4b9072933df6f040d2dbcadfac787461261007b8629f195314fd94e
Contents?: true
Size: 860 Bytes
Versions: 1
Compression:
Stored size: 860 Bytes
Contents
module MQTT module Homie class Node < HomieObject attr_reader :name, :properties def initialize(options = {}) super(options) @name = set(options, :name, required: true) @type = set(options, :type, required: true) @properties = set(options, :properties, required: true, data_type: Array) end def property(id) @properties.find { |i| i.id == id } end def homie_attributes data = { "$name" => @name, "$type" => @type, "$properties" => @properties.collect { |i| i.id }.join(","), } @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.0 | lib/mqtt/homie/node.rb |