mqtt-homeassistant 0.1.2 → 0.1.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 +4 -4
- data/lib/mqtt/home_assistant/homie/device.rb +7 -1
- data/lib/mqtt/home_assistant/version.rb +1 -1
- data/lib/mqtt/home_assistant.rb +17 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d0d4267529911dcd46d67137facee40859218e31c1de6f7c057aaa536f302c2
|
4
|
+
data.tar.gz: 8f7ed7810a6ae5a4c2b03b3ca3e50954c654b29307c9c19bf31bd36671319293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea2c835d1171876cf826a71e05e4b5cad925e1107c259d184f93b8fd1848870168c0cf9e84589e575c9db20ef185869e1c11b6a48e69459ba29d4c3576fa7a7
|
7
|
+
data.tar.gz: 383b55527730a79b6fc966061246df42d5e0d36daf8c604937dbd90f4e05e55c87101dfdad58003e20c21ea9212de0a670365fbd38b9cd49cb2f0c55483434e0
|
data/lib/mqtt/home_assistant.rb
CHANGED
@@ -105,7 +105,7 @@ module MQTT
|
|
105
105
|
.merge({
|
106
106
|
payload_off: "false",
|
107
107
|
payload_on: "true",
|
108
|
-
|
108
|
+
object_id: "#{property.node.id}_#{property.id}",
|
109
109
|
state_topic: property.topic
|
110
110
|
})
|
111
111
|
config[:expire_after] = expire_after if expire_after
|
@@ -163,7 +163,8 @@ module MQTT
|
|
163
163
|
device: device,
|
164
164
|
entity_category: entity_category,
|
165
165
|
icon: icon)
|
166
|
-
|
166
|
+
|
167
|
+
config[:object_id] = id || node.id
|
167
168
|
read_only_props = %i[action current_temperature]
|
168
169
|
properties.each do |prefix, property|
|
169
170
|
add_property(config, property, prefix, templates: templates, read_only: read_only_props.include?(prefix))
|
@@ -258,7 +259,7 @@ module MQTT
|
|
258
259
|
target_humidity_command_topic: "#{target_property.topic}/set",
|
259
260
|
payload_off: "false",
|
260
261
|
payload_on: "true",
|
261
|
-
|
262
|
+
object_id: id || property.node.id
|
262
263
|
})
|
263
264
|
add_property(config, property)
|
264
265
|
add_property(config, target_property, :target_humidity)
|
@@ -306,7 +307,7 @@ module MQTT
|
|
306
307
|
device: device,
|
307
308
|
entity_category: entity_category,
|
308
309
|
icon: icon)
|
309
|
-
config[:
|
310
|
+
config[:object_id] = "#{property.node.id}_#{property.id}"
|
310
311
|
add_property(config, property)
|
311
312
|
case property.datatype
|
312
313
|
when :boolean
|
@@ -354,7 +355,7 @@ module MQTT
|
|
354
355
|
device: device,
|
355
356
|
entity_category: entity_category,
|
356
357
|
icon: icon)
|
357
|
-
config[:
|
358
|
+
config[:object_id] = "#{property.node.id}_#{property.id}"
|
358
359
|
add_property(config, property)
|
359
360
|
config[:unit_of_measurement] = property.unit if property.unit
|
360
361
|
if property.range
|
@@ -383,7 +384,7 @@ module MQTT
|
|
383
384
|
device: device,
|
384
385
|
entity_category: entity_category,
|
385
386
|
icon: icon)
|
386
|
-
config[:
|
387
|
+
config[:object_id] = "#{property.node.id}_#{property.id}"
|
387
388
|
add_property(config, property)
|
388
389
|
config[:payload_on] = property.range.first
|
389
390
|
|
@@ -406,7 +407,7 @@ module MQTT
|
|
406
407
|
device: device,
|
407
408
|
entity_category: entity_category,
|
408
409
|
icon: icon)
|
409
|
-
config[:
|
410
|
+
config[:object_id] = "#{property.node.id}_#{property.id}"
|
410
411
|
add_property(config, property)
|
411
412
|
config[:options] = property.range
|
412
413
|
|
@@ -440,7 +441,7 @@ module MQTT
|
|
440
441
|
entity_category: entity_category,
|
441
442
|
icon: icon)
|
442
443
|
.merge({
|
443
|
-
|
444
|
+
object_id: "#{property.node.id}_#{property.id}",
|
444
445
|
state_topic: property.topic
|
445
446
|
})
|
446
447
|
config[:state_class] = state_class if state_class
|
@@ -468,7 +469,7 @@ module MQTT
|
|
468
469
|
entity_category: entity_category,
|
469
470
|
icon: icon)
|
470
471
|
.merge({
|
471
|
-
|
472
|
+
object_id: "#{property.node.id}_#{property.id}",
|
472
473
|
payload_off: "false",
|
473
474
|
payload_on: "true"
|
474
475
|
})
|
@@ -514,6 +515,7 @@ module MQTT
|
|
514
515
|
|
515
516
|
config = {
|
516
517
|
name: name,
|
518
|
+
node_id: homie_device.id,
|
517
519
|
availability_topic: "#{homie_device.topic}/$state",
|
518
520
|
payload_available: "ready",
|
519
521
|
payload_not_available: "lost",
|
@@ -533,7 +535,12 @@ module MQTT
|
|
533
535
|
end
|
534
536
|
|
535
537
|
def publish(mqtt, component, config, discovery_prefix:)
|
536
|
-
|
538
|
+
node_id, object_id = config.values_at(:node_id, :object_id)
|
539
|
+
config = config.dup
|
540
|
+
config[:unique_id] = "#{node_id}_#{object_id}"
|
541
|
+
config.delete(:node_id)
|
542
|
+
config.delete(:object_id)
|
543
|
+
mqtt.publish("#{discovery_prefix || "homeassistant"}/#{component}/#{node_id}/#{object_id}/config",
|
537
544
|
config.to_json,
|
538
545
|
retain: true,
|
539
546
|
qos: 1)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mqtt-homeassistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: homie-mqtt
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.3.7
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Library for publishing device auto-discovery configuration for Home Assistant
|