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 propertiespublic 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 deviceint port
: device communicates on this port, defaults to9999
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 deviceint port
: device communicates on this port, defaults to9999
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 percentDimmerMode mode
(optional):DimmerMode
to use during this transition, if left empty uses default option fromOptions.Mode
int duration
(optional): time in milliseconds in which the bulb transitions from old to new brightness
- Exceptions
-
ArgumentException
:brightness
should be between0
and100
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 between0
and100
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 switchint index
(optional): zero-based preset index, use in combination withDimmerMode.Preset
to execute preset on double click
- Exceptions
-
ArgumentException
:index
should be between0
and3
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 switchint index
(optional): zero-based preset index, use in combination withDimmerMode.Preset
to execute preset on long press
- Exceptions
-
ArgumentException
:index
should be between0
and3
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