Sha256: 0c1fd2894ff65a59cc8ba486300b68dae006bcd4a7ef8a0d97a2f57a243eb288
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
# frozen_string_literal: true require_relative '../shared/discover' require_relative 'group' require_relative 'products/smart_plug' module Wizrb module Power class Discover < Wizrb::Shared::Discover private def parse_response(data, addr) response = JSON.parse(data) return unless response.dig('result', 'success') && addr[1] && addr[2] resolve_device(ip: addr[2], port: addr[1]) rescue StandardError nil end def resolve_device(ip:, port: 38_899) module_name = Wizrb::Shared::Products::Device.new(ip: ip, port: port).module_name return unless module_name.include?(Wizrb::Power::Products::SmartPlug::MODULE_NAME_IDENTIFIER) Wizrb::Power::Products::SmartPlug.new(ip: ip, port: port) end def group_devices Wizrb::Power::Group.new(devices: @devices) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wizrb-1.1.2 | lib/wizrb/power/discover.rb |