mqtt-homeassistant 0.1.3 → 0.1.5

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: 71dd3444a38fb640c9ca56fa26938cf6530dbfb566f39313558101fc98098c37
4
- data.tar.gz: 7d6d78f91d49f2dbbc585e89c73efcfc809c34db03bb639de67ea29f1b36b4b2
3
+ metadata.gz: 96765202ae955e74f283eb348c22fed1c8bd4cd792aa9792ef071cc5f4bf68c3
4
+ data.tar.gz: bfd420db58ba339dd034c177b5352b9dee84063cd2800f7db21fbe5a125ee8ea
5
5
  SHA512:
6
- metadata.gz: ebb5c6e8bbf19c7b22b9fd99d333f767bfd83b83297096dbebb5dd4c2a538a2ae8217319820f4688b16b15b3e9e0eb378ed7118b889eb0f73abdb158c7c20637
7
- data.tar.gz: 6249d5ae0fcadc1fec9be359502f92c3a5c9468f44935d983ae3b505008b4c199816cf1d2e36fdceb36db6004417cc19b2199e0d2f1d4bf6b51ca6f7292131bc
6
+ metadata.gz: bb2f2bd2d70e208ad42a9420723088d16c33cb4607104f7b3edcaaf26a0c7a04211bd2ba04d9c31e26df84cdbd71b726ad1b995b2d34afb580648b6ee540d0fd
7
+ data.tar.gz: c1ee571c04ddeea59975ea544dddd1690607ae58fd4bd7c7e825879b8357bcaf405389cdb9c7154e6ce91a4f2a1562742676d5aba5d36acd21bcbbd74f7f5f17
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MQTT
4
4
  module HomeAssistant
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
@@ -97,7 +97,7 @@ module MQTT
97
97
  end
98
98
 
99
99
  config = base_config(property.device,
100
- property.full_name,
100
+ "#{property.node.name} #{property.name}",
101
101
  device_class: device_class,
102
102
  device: device,
103
103
  entity_category: entity_category,
@@ -105,7 +105,7 @@ module MQTT
105
105
  .merge({
106
106
  payload_off: "false",
107
107
  payload_on: "true",
108
- unique_id: "#{property.device.id}_#{property.node.id}_#{property.id}",
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
@@ -159,11 +159,12 @@ module MQTT
159
159
  node = properties.first.last.node
160
160
 
161
161
  config = base_config(node.device,
162
- name || node.full_name,
162
+ name || node.name,
163
163
  device: device,
164
164
  entity_category: entity_category,
165
165
  icon: icon)
166
- config[:unique_id] = "#{node.device.id}_#{id || node.id}"
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))
@@ -210,7 +211,7 @@ module MQTT
210
211
  icon: nil
211
212
  )
212
213
  config = base_config(property.device,
213
- name || property.node.full_name,
214
+ name || property.node.name,
214
215
  device: device,
215
216
  device_class: device_class,
216
217
  entity_category: entity_category,
@@ -248,7 +249,7 @@ module MQTT
248
249
  end
249
250
 
250
251
  config = base_config(property.device,
251
- name || property.node.full_name,
252
+ name || property.node.name,
252
253
  device: device,
253
254
  device_class: device_class,
254
255
  entity_category: entity_category,
@@ -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
- unique_id: "#{property.device.id}_#{id || property.node.id}"
262
+ object_id: id || property.node.id
262
263
  })
263
264
  add_property(config, property)
264
265
  add_property(config, target_property, :target_humidity)
@@ -302,11 +303,11 @@ module MQTT
302
303
  end
303
304
 
304
305
  config = base_config(property.device,
305
- property.full_name,
306
+ "#{property.node.name} #{property.name}",
306
307
  device: device,
307
308
  entity_category: entity_category,
308
309
  icon: icon)
309
- config[:unique_id] = "#{property.device.id}_#{property.node.id}_#{property.id}"
310
+ config[:object_id] = "#{property.node.id}_#{property.id}"
310
311
  add_property(config, property)
311
312
  case property.datatype
312
313
  when :boolean
@@ -350,11 +351,11 @@ module MQTT
350
351
  float].include?(property.datatype)
351
352
 
352
353
  config = base_config(property.device,
353
- property.full_name,
354
+ "#{property.node.name} #{property.name}",
354
355
  device: device,
355
356
  entity_category: entity_category,
356
357
  icon: icon)
357
- config[:unique_id] = "#{property.device.id}_#{property.node.id}_#{property.id}"
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
@@ -379,11 +380,11 @@ module MQTT
379
380
  end
380
381
 
381
382
  config = base_config(property.device,
382
- property.full_name,
383
+ "#{property.node.name} #{property.name}",
383
384
  device: device,
384
385
  entity_category: entity_category,
385
386
  icon: icon)
386
- config[:unique_id] = "#{property.device.id}_#{property.node.id}_#{property.id}"
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
 
@@ -402,11 +403,11 @@ module MQTT
402
403
  raise ArgumentError, "Homie property must be settable" unless property.settable?
403
404
 
404
405
  config = base_config(property.device,
405
- property.full_name,
406
+ "#{property.node.name} #{property.name}",
406
407
  device: device,
407
408
  entity_category: entity_category,
408
409
  icon: icon)
409
- config[:unique_id] = "#{property.device.id}_#{property.node.id}_#{property.id}"
410
+ config[:object_id] = "#{property.node.id}_#{property.id}"
410
411
  add_property(config, property)
411
412
  config[:options] = property.range
412
413
 
@@ -434,13 +435,13 @@ module MQTT
434
435
  end
435
436
 
436
437
  config = base_config(property.device,
437
- property.full_name,
438
+ "#{property.node.name} #{property.name}",
438
439
  device: device,
439
440
  device_class: device_class,
440
441
  entity_category: entity_category,
441
442
  icon: icon)
442
443
  .merge({
443
- unique_id: "#{property.device.id}_#{property.node.id}_#{property.id}",
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
@@ -462,13 +463,13 @@ module MQTT
462
463
  raise ArgumentError, "Homie property must be a boolean" unless property.datatype == :boolean
463
464
 
464
465
  config = base_config(property.device,
465
- property.full_name,
466
+ "#{property.node.name} #{property.name}",
466
467
  device: device,
467
468
  device_class: device_class,
468
469
  entity_category: entity_category,
469
470
  icon: icon)
470
471
  .merge({
471
- unique_id: "#{property.device.id}_#{property.node.id}_#{property.id}",
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
- mqtt.publish("#{discovery_prefix || "homeassistant"}/#{component}/#{config[:unique_id]}/config",
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-11 00:00:00.000000000 Z
11
+ date: 2023-08-12 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.1.2
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