homie-mqtt 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df54d2ae01eb1d1972e4d0f5fb40d05286969feff5ad83547476be6d11db05e2
4
- data.tar.gz: 719a2c270af518fd2ee7d7da4941a211da1f4af90d1e5f0daae2a0c50fd1616f
3
+ metadata.gz: fe33f7f3d3d6588a385857dfad083584df0de5af3e66e540732dc3307b7d8a0f
4
+ data.tar.gz: ba032b7b5760ac2a71915ebbbc4e3671cceff13bcf3b75bba3181b86a0b3c015
5
5
  SHA512:
6
- metadata.gz: 19fdcadf299dbe73d3bafca37e32d65b27edb006569ae80f27ecae036e6da17370c9e1b0af405f0517fd6649f5cc0c5bcb75912f00ec2560971d17385502408f
7
- data.tar.gz: b92d4b4cb05cc96b1a4b0d7e0254476f05db8be89f48d969277bbb09ae56cfcc7e597f5f9ccede42f5279d034bda7a85fe36ad1d652155cf3e38aac961c02667
6
+ metadata.gz: f7dabb99327ba052edef139511680ab1a9c5c90e21ce0c3229585e238846f5a2f6abd42365bb2f73cf43767b55e41ad091d45d1c5003fd86d91599d52e73347f
7
+ data.tar.gz: a302d00a71bcde1495604da147e2d0e200a0dc686a074cd285e95d1861bc334007cd94a45d79d206c19c80dc5bd93dcec504c07488ae362cc94d592986663a8f
@@ -6,6 +6,8 @@ module MQTT
6
6
  module Homie
7
7
  class Device < Base
8
8
  attr_reader :root_topic, :state, :mqtt
9
+ attr_accessor :logger
10
+ attr_accessor :out_of_band_topic_proc
9
11
 
10
12
  def initialize(id, name, root_topic: nil, mqtt: nil, clear_topics: true, &block)
11
13
  super(id, name)
@@ -13,7 +15,7 @@ module MQTT
13
15
  @state = :init
14
16
  @nodes = {}
15
17
  @published = false
16
- @block = block
18
+ @out_of_band_topic_proc = block
17
19
  mqtt = MQTT::Client.new(mqtt) if mqtt.is_a?(String)
18
20
  @mqtt = mqtt || MQTT::Client.new
19
21
  @mqtt.set_will("#{topic}/$state", "lost", retain: true, qos: 1)
@@ -87,12 +89,13 @@ module MQTT
87
89
  Thread.current.report_on_exception = false
88
90
 
89
91
  mqtt.get do |packet|
92
+ logger&.debug("received packet at #{packet.topic} with payload #{packet.payload.inspect}")
90
93
  match = packet.topic.match(topic_regex)
91
94
  node = @nodes[match[:node]] if match
92
95
  property = node[match[:property]] if node
93
96
 
94
97
  unless property&.settable?
95
- @block&.call(packet.topic, packet.payload)
98
+ @out_of_band_topic_proc&.call(packet.topic, packet.payload)
96
99
  next
97
100
  end
98
101
 
@@ -170,8 +170,10 @@ module MQTT
170
170
  def publish_value
171
171
  serialized = value
172
172
  serialized = serialized&.iso8601 if %i[datetime duration].include?(datatype)
173
+ serialized = serialized.to_s
173
174
 
174
- mqtt.publish(topic, serialized.to_s, retain: retained?, qos: 1)
175
+ node.device.logger&.debug("publishing #{serialized.inspect} to #{topic}")
176
+ mqtt.publish(topic, serialized, retain: retained?, qos: 1)
175
177
  end
176
178
  end
177
179
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MQTT
4
4
  module Homie
5
- VERSION = '1.4.2'
5
+ VERSION = '1.4.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homie-mqtt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer