mqtt-homeassistant 0.1.6 → 1.0.1

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.
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mqtt-homeassistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-09 00:00:00.000000000 Z
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: homie-mqtt
14
+ name: mqtt-ccutrer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.3
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '1.6'
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: json
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +44,6 @@ dependencies:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: byebug
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '11.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '11.0'
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: rake
57
49
  requirement: !ruby/object:Gem::Requirement
@@ -66,35 +58,7 @@ dependencies:
66
58
  - - "~>"
67
59
  - !ruby/object:Gem::Version
68
60
  version: '13.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-inst
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.6'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.6'
97
- description:
61
+ description:
98
62
  email: cody@cutrer.com'
99
63
  executables: []
100
64
  extensions: []
@@ -102,16 +66,14 @@ extra_rdoc_files: []
102
66
  files:
103
67
  - lib/mqtt-homeassistant.rb
104
68
  - lib/mqtt/home_assistant.rb
105
- - lib/mqtt/home_assistant/homie/device.rb
106
- - lib/mqtt/home_assistant/homie/node.rb
107
- - lib/mqtt/home_assistant/homie/property.rb
69
+ - lib/mqtt/home_assistant/client.rb
108
70
  - lib/mqtt/home_assistant/version.rb
109
71
  homepage: https://github.com/ccutrer/ruby-mqtt-homeassistant
110
72
  licenses:
111
73
  - MIT
112
74
  metadata:
113
75
  rubygems_mfa_required: 'true'
114
- post_install_message:
76
+ post_install_message:
115
77
  rdoc_options: []
116
78
  require_paths:
117
79
  - lib
@@ -126,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
88
  - !ruby/object:Gem::Version
127
89
  version: '0'
128
90
  requirements: []
129
- rubygems_version: 3.3.7
130
- signing_key:
91
+ rubygems_version: 3.5.11
92
+ signing_key:
131
93
  specification_version: 4
132
94
  summary: Library for publishing device auto-discovery configuration for Home Assistant
133
95
  via MQTT.
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MQTT
4
- module Homie
5
- class Device
6
- attr_accessor :home_assistant_device, :home_assistant_discovery_prefix
7
- end
8
- end
9
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MQTT
4
- module HomeAssistant
5
- module Homie
6
- module Node
7
- {
8
- climate: %i[action
9
- aux
10
- away_mode
11
- current_temperature
12
- fan_mode
13
- mode
14
- hold
15
- power
16
- swing_mode
17
- temperature
18
- temperature_high
19
- temperature_low],
20
- fan: [nil, :oscillation],
21
- humidifier: [nil, :target, :mode],
22
- light: [nil, :brightness, :color_mode, :color_temp, :effect, :hs, :rgb, :white, :xy]
23
- }.each do |(integration, properties)|
24
- has_nil = properties.include?(nil)
25
- method_arguments = []
26
- method_arguments << "property" if has_nil
27
- method_arguments.concat(properties.compact.map { |p| "#{p}_property: nil" })
28
- transforms = []
29
- transforms << "property = self[property] if property.is_a?(String)"
30
- transforms.concat(
31
- properties.compact.map do |p|
32
- "kwargs[:#{p}_property] = #{p}_property.is_a?(String) ? self[#{p}_property] : #{p}_property"
33
- end
34
- )
35
- args_code = has_nil ? "args = [property]" : "args = []"
36
-
37
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
38
- def hass_#{integration}(#{method_arguments.join(", ")}, device: nil, discovery_prefix: nil, **kwargs)
39
- #{transforms.join("\n")}
40
- discovery_prefix ||= self.device.home_assistant_discovery_prefix
41
- device = self.device.home_assistant_device.merge(device || {}) if self.device.home_assistant_device
42
-
43
- kwargs[:device] = device
44
- kwargs[:discovery_prefix] = discovery_prefix
45
- #{args_code}
46
- if published?
47
- HomeAssistant.publish_#{integration}(*args, **kwargs)
48
- else
49
- pending_hass_registrations << [:publish_#{integration}, args, kwargs]
50
- end
51
- end
52
- RUBY
53
- end
54
-
55
- def publish
56
- super.tap do
57
- @pending_hass_registrations&.each do |(method, args, kwargs)|
58
- HomeAssistant.public_send(method, *args, **kwargs)
59
- end
60
- @pending_hass_registrations = nil
61
- end
62
- end
63
-
64
- private
65
-
66
- def pending_hass_registrations
67
- @pending_hass_registrations ||= []
68
- end
69
- end
70
- end
71
- end
72
- end
73
-
74
- MQTT::Homie::Node.prepend(MQTT::HomeAssistant::Homie::Node)
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MQTT
4
- module HomeAssistant
5
- module Homie
6
- module Property
7
- def initialize(*args, hass: nil, **kwargs)
8
- super(*args, **kwargs)
9
-
10
- return unless hass
11
-
12
- case hass
13
- when Symbol
14
- public_send("hass_#{hass}")
15
- when Hash
16
- raise ArgumentError, "hass must only contain one item" unless hass.length == 1
17
-
18
- public_send("hass_#{hass.first.first}", **hass.first.last)
19
- else
20
- raise ArgumentError, "hass must be a Symbol or a Hash of HASS device type to additional HASS options"
21
- end
22
- end
23
-
24
- %i[binary_sensor fan humidifier light number scene select sensor switch].each do |integration|
25
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
26
- def hass_#{integration}(device: nil, discovery_prefix: nil, **kwargs)
27
- discovery_prefix ||= self.device.home_assistant_discovery_prefix
28
- device = self.device.home_assistant_device.merge(device || {}) if self.device.home_assistant_device
29
-
30
- kwargs[:device] = device
31
- kwargs[:discovery_prefix] = discovery_prefix
32
- if published?
33
- HomeAssistant.publish_#{integration}(self, **kwargs)
34
- else
35
- kwargs[:method] = :publish_#{integration}
36
- pending_hass_registrations << kwargs
37
- end
38
- end
39
- RUBY
40
- end
41
-
42
- def publish
43
- super.tap do
44
- @pending_hass_registrations&.each do |entity|
45
- method = entity.delete(:method)
46
- HomeAssistant.public_send(method, self, **entity)
47
- end
48
- @pending_hass_registrations = nil
49
- end
50
- end
51
-
52
- private
53
-
54
- def pending_hass_registrations
55
- @pending_hass_registrations ||= []
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
62
- MQTT::Homie::Property.prepend(MQTT::HomeAssistant::Homie::Property)