Skip to content

Commit

Permalink
Rescue plug library error on initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhughes committed Feb 14, 2024
1 parent 82ee5d1 commit 5d8e3a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions influx_hs110_energy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@

measurement_strings.push(measurement_string)

debug_message("Took #{seconds_since(time_start)} seconds to poll plug #{plug.name}") if options[:debug]
debug_message("Took #{seconds_since(time_start)} seconds to poll plug #{plug_name}") if options[:debug]
rescue TpLinkSmartplugInflux::BaseError => e
debug_message("Error occured processing plug #{plug.name}:\n #{e}") if options[:verbose]
debug_message("Error occured processing plug #{plug_name}:\n #{e}") if options[:verbose]
exit 1 unless options[:silent_error]
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/tp_link_smartplug_influx/plug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def initialize(name:, address:, timeout: 3)
@calculated_fields = TpLinkSmartplugInflux::Plug::CalculatedFieldCollection.new

debug_message("Initialised new plug #{@name} with timeout #{device.timeout}.") if @debug
rescue TpLinkSmartplug::BaseError => e
raise PlugPollError, "Error occured creating plug device for #{@name}, inner error: #{e}"
end

# get all data for the plug.
Expand Down

0 comments on commit 5d8e3a5

Please sign in to comment.