mqtt-homeassistant 0.0.1 → 0.0.2
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/version.rb +1 -1
- data/lib/mqtt/home_assistant.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2701bd3fb3bde99e200213253949dbe73787ada219260463309ea1f27dcd9af
|
4
|
+
data.tar.gz: 3c58be7186fb3aa443e6d1ff33b5282549988422536daf34c430415effece799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2257944fc2298287e7c9cd6ffa8b2afd4edd7c22c7a47165817cd8b7ee32084e4e11b7fd30fc794805472cb06c9f608d4d4c587b7685ebdb2e4f1df20ca4777f
|
7
|
+
data.tar.gz: 60a670f138fe6378810cc5b86291a99d92084dfaf509769c67f515132f51ad336fb421cae45f8192113e5e1a01a48cc98fad110218a73071b4c78a3f59f553f8
|
data/lib/mqtt/home_assistant.rb
CHANGED
@@ -159,8 +159,9 @@ module MQTT
|
|
159
159
|
entity_category: entity_category,
|
160
160
|
icon: icon)
|
161
161
|
config[:unique_id] = "#{node.device.id}_#{id || node.id}"
|
162
|
+
read_only_props = %i[action current_temperature]
|
162
163
|
properties.each do |prefix, property|
|
163
|
-
add_property(config, property, prefix, templates)
|
164
|
+
add_property(config, property, prefix, templates, read_only: read_only_props.include?(prefix))
|
164
165
|
end
|
165
166
|
temp_properties = [
|
166
167
|
temperature_property,
|
@@ -472,16 +473,17 @@ module MQTT
|
|
472
473
|
|
473
474
|
private
|
474
475
|
|
475
|
-
def add_property(config, property, prefix = nil, templates = {})
|
476
|
+
def add_property(config, property, prefix = nil, templates = {}, read_only: false)
|
476
477
|
return unless property
|
477
478
|
|
478
479
|
prefix = "#{prefix}_" if prefix
|
479
|
-
|
480
|
-
if property.
|
480
|
+
state_prefix = "state_" unless read_only
|
481
|
+
config[:"#{prefix}#{state_prefix}topic"] = property.topic if property.retained?
|
482
|
+
if !read_only && property.settable?
|
481
483
|
config[:"#{prefix}command_topic"] = "#{property.topic}/set"
|
482
484
|
config[:"#{prefix}command_template"] = "{{ value | round(0) }}" if property.datatype == :integer
|
483
485
|
end
|
484
|
-
config.merge!(templates.slice(:"#{prefix}
|
486
|
+
config.merge!(templates.slice(:"#{prefix}template", :"#{prefix}command_template"))
|
485
487
|
end
|
486
488
|
|
487
489
|
def add_enum(config, property, prefix = nil, valid_set = nil)
|