Skip to content

TPLinkSmartDimmmer Class

Namespace: TPLinkSmartDevices.Devices
Inheritance: TPLinkSmartDevice -> TPLinkSmartDimmer

controls for wall switches with dimmer functionality

Properties

Brightness

Returns brightness (dimmer value) in percent
public int Brightness { get; private set; }

Options

Returns an object of type DimmerOptions with configuration properties
public DimmerOptions Options { get; private set; }

Presets

Returns array of the four dimmer state preset configurations containing brightness values
public int[] Presets { get; private set; }

PoweredOn

Returns whether switch is powered on
public bool PoweredOn { get; private set; }

Constructors

TPLinkSmartPlug(string, int, DimmerOptions)

Creates a new object of this type, used for HS220 wall switch

public TPLinkSmartPlug(string hostname, int port=9999, DimmerOptions opts = null)

Parameters
  • string hostname: ip-address of this device
  • int port: device communicates on this port, defaults to 9999
  • DimmerOptions opts: configuration properties`

Methods

Create(string, int, DimmerOptions)

Factory instantiation method. Returns a new instance of this type.

public static async Task<TPLinkSmartPlug> Create(string hostname, int port = 9999, DimmerOptions opts = null)

Parameters
  • string hostname: ip-address of this device
  • int port: device communicates on this port, defaults to 9999
  • DimmerOptions opts: configuration properties`

Refresh()

Refreshes all properties of this device (includes a call to TPLinkSmartDevice.Refresh(dynamic) for the common device information)
public async Task Refresh()

SetPoweredOn(bool)

Change the power state

public void SetPoweredOn(bool value)

Parameters
  • bool value: true power on, false power off

TransitionBrightness(int, DimmerMode, int)

Transition to a specified brightness level

public async Task TransitionBrightness(int brightness, DimmerMode? mode = null, int? duration = null)

Parameters
  • int brightness: dimmer brightness value in percent
  • DimmerMode mode (optional): DimmerMode to use during this transition, if left empty uses default option from Options.Mode
  • int duration (optional): time in milliseconds in which the bulb transitions from old to new brightness
Exceptions
  • ArgumentException: brightness should be between 0 and 100

SetBrightness(int)

Instantly change to a specified brightness level

public async Task SetBrightness(int brightness)

Parameters
  • int brightness: dimmer brightness value in percent
Exceptions
  • ArgumentException: brightness should be between 0 and 100

SetDoubleClickAction(DimmerMode, int)

Configures change mode on double click of switch

public async Task SetDoubleClickAction(DimmerMode mode, int index=0)

Parameters
  • DimmerMode mode: DimmerMode to use on double clicking the switch
  • int index (optional): zero-based preset index, use in combination with DimmerMode.Preset to execute preset on double click
Exceptions
  • ArgumentException: index should be between 0 and 3

SetLongPressAction(DimmerMode, int)

Configures change mode on long press of switch

public async Task SetLongPressAction(DimmerMode mode, int index=0)

Parameters
  • DimmerMode mode: DimmerMode to use on long press of switch
  • int index (optional): zero-based preset index, use in combination with DimmerMode.Preset to execute preset on long press
Exceptions
  • ArgumentException: index should be between 0 and 3

SetFadeOnTime(int)

Configures speed of fade on transition

public async Task SetFadeOnTime(int fadeOnTime)

Parameters
  • int fadeOnTime: transition time used on next uses of switch when turning on
Exceptions
  • ArgumentException: fadeOnTime should be a positive number

SetFadeOffTime(int)

Configures speed of fade on transition

public async Task SetFadeOffTime(int fadeOffTime)

Parameters
  • int fadeOffTime: transition time used on next uses of switch when turning off
Exceptions
  • ArgumentException: fadeOffTime should be a positive number