TPLinkSmartBulb Class
Namespace: TPLinkSmartDevices.Devices
Inheritance: TPLinkSmartDevice -> TPLinkSmartBulb
encloses bulb specific system information and bulb controls
Properties
IsColor
- Returns whether bulb supports color changes
public bool IsColor { get; private set; }
IsDimmable
- Returns whether bulb supports dimming the brightness
public bool IsDimmable { get; private set; }
IsVariableColorTemperature
- Returns whether bulb supports changing of color temperature
public bool IsVariableColorTemperature { get; private set; }
Brightness
- Returns bulb brightness in percent
public int Brightness { get; private set; }
ColorTemperature
- Returns bulbs color temperature in kelvin
public int ColorTemperature { get; private set; }
LightDetails
- Contains further hardware specifications of this bulb, , see
LightDetails
referencepublic LightDetails LightDetails { get; private set; }
HSV
- Returns bulb color in HSV scheme
public BulbHSV HSV { get; private set; }
PoweredOn
- Returns whether bulb is powered on
public bool PoweredOn { get; private set; }
PreferredLightStates
- Returns collection of the four light state preset configurations
public List<PreferredLightState> PreferredLightStates { get; }
Constructors
TPLinkSmartBulb(string, int)
-
Creates a new object of this type, used for KL100/KL110/KL130 bulbs
public TPLinkSmartBulb(string hostname, int port=9999)
- Parameters
-
string hostname
: ip-address of of this bulbint port
: bulb communicates on this port, defaults to9999
Methods
Create(string, int)
-
Factory instantiation method. Returns a new instance of this type.
public static async Task<TPLinkSmartBulb> Create(string hostname, int port = 9999)
- Parameters
-
string hostname
: ip-address of of this bulbint port
: bulb communicates on this port, defaults to9999
Refresh()
- Refreshes all properties of this bulb (includes a call to
TPLinkSmartDevice.Refresh(dynamic)
for the common device information)public async Task Refresh()
SetPoweredOn(bool)
-
Change the power state of this bulb
public async task SetPoweredOn(bool value)
- Parameters
-
bool value
:true
power on,false
power off
SetBrightness(int, int)
-
Change the bulbs brightness
public void SetBrightness(int brightness, int transition_period = 0)
- Parameters
-
int brightness
: brightness value in percentint transition_period
(optional): time in milliseconds in which the bulb transitions from old to new brightness. Allowed values between0
and10000
- Exceptions
-
NotSupportedException
: the bulb does not support dimmingArgumentException
:transition_period
only allows values between0
and10000
SetColorTemp(int, int)
-
Change the bulbs color temperature
public void SetColorTemp(int colortemp, int transition_period = 0)
- Parameters
-
int colortemp
: color temperature in kelvin, common values ranging between 2700K (soft light) to 6500K (bright daylight)int transition_period
(optional): time in milliseconds in which the bulb transitions from old to new brightness. Allowed values between0
and10000
- Exceptions
-
NotSupportedException
: the bulb does not support color temperature changesArgumentException
:transition_period
only allows values between0
and10000
Note
Color temperature values depend on device model, for instance KL120 supports 2500K-5000K and KL130 2700K-9000K!
SetHSV(BulbHSV, int)
-
Change the bulbs color
public void SetHSV(BulbHSV hsv, int transition_period = 0)
- Parameters
-
BulbHSV hsv
: color in HSV color scheme, seeBulbHSV
referenceint transition_period
(optional): time in milliseconds in which the bulb transitions from old to new brightness. Allowed values between0
and10000
- Exceptions
-
NotSupportedException
: the bulb does not support color changesArgumentException
:transition_period
only allows values between0
and10000
Example
BulbHSV red = new BulbHSV { Hue = 0, Saturation = 100, Value = 100 }; // red HSV(0, 100, 100) smartBulb.SetHSV(red);
ApplyPreset(int)
-
Operate smart bulb on one of the four light state presets
public void ApplyPreset(int presetIndex)
- Parameters
-
int presetIndex
: index of the four presets, ranging from0
to3
- Exceptions
-
ArgumentOutOfRangeException
:presetIndex
only allows values between0
and3