esphome 1.1.1 → 1.2.0

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: 7290628c333abc933faa1582a521381217a7c518b0db41cd476f61644f90fa1a
4
- data.tar.gz: 52a9eda4cff49e44c4695bd7b0bb9e911052cca5178f5a6092810845bf638909
3
+ metadata.gz: 8bf65aff6fec29a72dd0778f8482b625a9ce87b300fc580be836a7e3750f9a52
4
+ data.tar.gz: b092afddf51e1b12b7d88290aa4727df6d09f8f13a587974049464f933bf47e7
5
5
  SHA512:
6
- metadata.gz: 29309825cb9b36c0a1991e41435c64fdad4d33d6472873aadec652cd1d76841e8dae3929f5f4b56a9998834af62f57bbcc550efe1482c00e65b3f4ca69bec9ea
7
- data.tar.gz: c1eabdd29c70ce725e5949a6b2450a9f5c9087f10d45c1fe060f4a644c1a27b2f4c62ff599ab659b430a2083176730de2d4dd6d5af1b9e2d219243b2a20113b8
6
+ metadata.gz: df0ffbec0941cb74ef17d8dcb8386c1df50f601c9b7581d02f24f8d492e0dabb4a3703c9d839205ef1ea5fe857bac9f70ac47340de3c68b76868c4b13c8a2fc4
7
+ data.tar.gz: b0109906cdcfbb787cc4ff6685456a2d6849463b41975e7ae656f69d22495adf7e639e617d0b1b04e91f65d7687bc083e93db4ac6a41936c0adb657d161a0c1a
data/exe/esphome-monitor CHANGED
@@ -17,6 +17,9 @@ connection_log_level = :warn
17
17
  device_log_level = :debug
18
18
  dump_config = false
19
19
  port = 6053
20
+ diagnostic_entities = false
21
+ config_entities = true
22
+ states = false
20
23
  opts = OptionParser.new do |opts|
21
24
  opts.banner = <<~TEXT
22
25
  Usage: esphome-monitor ([<uri>] <device_name> | <address> <encryption_key>)
@@ -43,6 +46,15 @@ opts = OptionParser.new do |opts|
43
46
  opts.on("--dump-config", "Dump device configuration on connect (requires log streaming at info level)") do
44
47
  dump_config = true
45
48
  end
49
+ opts.on("--[no-]diagnostic-entities", "include diagnostic entities (default off)") do |v|
50
+ diagnostic_entities = v
51
+ end
52
+ opts.on("--[no-]config-entities", "include configuration entities (default on)") do |v|
53
+ config_entities = v
54
+ end
55
+ opts.on("--[no-]states", "Log entity state changes (default off)") do |v|
56
+ states = v
57
+ end
46
58
  opts.on("-h", "--help", "Show this help message") do
47
59
  puts opts
48
60
  exit
@@ -75,4 +87,12 @@ end
75
87
 
76
88
  device = ESPHome::Device.new(address, encryption_key, port:)
77
89
 
78
- ESPHome::Cli::Monitor.run(device, connection_log_level:, device_log_level:, log_level:, actions:, dump_config:)
90
+ ESPHome::Cli::Monitor.run(device,
91
+ connection_log_level:,
92
+ device_log_level:,
93
+ log_level:,
94
+ actions:,
95
+ dump_config:,
96
+ diagnostic_entities:,
97
+ config_entities:,
98
+ states:)
@@ -47,7 +47,10 @@ module ESPHome
47
47
  device_log_level: nil,
48
48
  connection_log_level: nil,
49
49
  log_level: nil,
50
- dump_config: false)
50
+ dump_config: false,
51
+ diagnostic_entities: true,
52
+ config_entities: true,
53
+ states: false)
51
54
  @device = device
52
55
  @win = nil
53
56
  @entities_by_key = {}
@@ -61,6 +64,9 @@ module ESPHome
61
64
  @logger = LoggerWrapper.new(self, level: log_level || Logger::INFO)
62
65
  @actions = actions
63
66
  @dump_config = dump_config
67
+ @diagnostic_entities = diagnostic_entities
68
+ @config_entities = config_entities
69
+ @states = states
64
70
  @winch_trapped = false
65
71
  @logwin = nil
66
72
  @screen_initialized = false
@@ -79,9 +85,17 @@ module ESPHome
79
85
 
80
86
  def run
81
87
  @device.on_message do |entity_or_log_line|
82
- if entity_or_log_line.respond_to?(:key) && (entity_wrapper = @entities_by_key[entity_or_log_line.key])
83
- entity_wrapper.touch
84
- queue_ui_event(:entity, entity_wrapper)
88
+ if entity_or_log_line.respond_to?(:key)
89
+ key = entity_or_log_line.key
90
+ if (entity_wrapper = @entities_by_key[key])
91
+ entity_wrapper.touch
92
+ log_entity_state(entity_wrapper.__getobj__) if @states
93
+ queue_ui_event(:entity, entity_wrapper)
94
+ elsif @device.entities.key?(key)
95
+ # ignored diagnostic or config entity
96
+ else
97
+ logger.warn("Unexpected entity #{entity_or_log_line.inspect}")
98
+ end
85
99
  elsif entity_or_log_line.is_a?(Action)
86
100
  logger.info(entity_or_log_line.inspect)
87
101
  else
@@ -91,10 +105,16 @@ module ESPHome
91
105
 
92
106
  @device.on_connect do
93
107
  logger.info("Connected")
94
- @name_width = @device.entities.values.map { |e| e.name.length }.max || 0
108
+ entities = @device.entities.values.select do |entity|
109
+ next false if entity.entity_category == :diagnostic && !@diagnostic_entities
110
+ next false if entity.entity_category == :config && !@config_entities
111
+
112
+ true
113
+ end
114
+ @name_width = entities.map { |e| e.name.length }.max || 0
95
115
  @entities_by_key = {}
96
116
  @entities = []
97
- @device.entities.values.sort_by(&:name).each_with_index do |entity, idx|
117
+ entities.sort_by(&:name).each_with_index do |entity, idx|
98
118
  simple_name = entity.class.name.split("::").last
99
119
  entity_class = if Entities.const_defined?(simple_name)
100
120
  Entities.const_get(simple_name, false)
@@ -190,6 +210,11 @@ module ESPHome
190
210
  @device.disconnect
191
211
  end
192
212
 
213
+ def log_entity_state(entity)
214
+ type = entity.class.name.split("::").last.gsub(/[A-Z]/) { |c| "_#{c.downcase}" }[1..]
215
+ add(nil, "\e[36m[S][#{type}]: '#{entity.name}' >> #{entity.formatted_state}\e[0m")
216
+ end
217
+
193
218
  def add(_level, message = nil, progname = nil, render: true)
194
219
  if message.nil?
195
220
  message = if block_given?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ESPHome
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esphome
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-07-26 00:00:00.000000000 Z
10
+ date: 2026-08-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: curses