Sha256: 3565ff64457758aac7d4bede288ce319353a96428eaf90fdf3b8efa6b6aef2d8

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

# frozen_string_literal: true

module Switchbot
  class Device
    attr_reader :client, :device_id

    def initialize(client:, device_id:)
      @client = client
      @device_id = device_id
    end

    def status
      client.status(device_id: device_id)
    end

    def commands(command:, parameter: 'default', command_type: 'command')
      client.commands(device_id: device_id, command: command, parameter: parameter, command_type: command_type)
    end

    def on
      client.commands(device_id: device_id, command: 'turnOn')
    end

    def off
      client.commands(device_id: device_id, command: 'turnOff')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
switchbot-0.3.0 lib/switchbot/device.rb