diff --git a/influx_hs110_energy.rb b/influx_hs110_energy.rb index 532be98..17e4822 100755 --- a/influx_hs110_energy.rb +++ b/influx_hs110_energy.rb @@ -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 diff --git a/lib/tp_link_smartplug_influx/plug.rb b/lib/tp_link_smartplug_influx/plug.rb index e11aa70..0d95691 100644 --- a/lib/tp_link_smartplug_influx/plug.rb +++ b/lib/tp_link_smartplug_influx/plug.rb @@ -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.