Class Device

java.lang.Object
de.justofplay.xled.Device

public class Device extends Object
Represents a Twinkly device and provides methods to interact with it via the Twinkly API.
  • Constructor Details

    • Device

      public Device(String ip)
      Constructs a Device object and initializes device info by logging in and querying the device.
      Parameters:
      ip - The IP address of the Twinkly device.
  • Method Details

    • getProductName

      public String getProductName()
      Returns:
      The product name of the device.
    • getHardwareVersion

      public int getHardwareVersion()
      Returns:
      The hardware version.
    • getBytesPerLed

      public int getBytesPerLed()
      Returns:
      The number of bytes per LED.
    • getHwId

      public String getHwId()
      Returns:
      The hardware ID.
    • getFlashSize

      public int getFlashSize()
      Returns:
      The flash size.
    • getLedType

      public int getLedType()
      Returns:
      The LED type.
    • getProductCode

      public String getProductCode()
      Returns:
      The product code.
    • getFwFamily

      public String getFwFamily()
      Returns:
      The firmware family.
    • getDeviceName

      public String getDeviceName()
      Returns:
      The device name.
    • getUptime

      public long getUptime()
      Returns:
      The uptime in seconds.
    • getMac

      public String getMac()
      Returns:
      The MAC address.
    • getUuid

      public String getUuid()
      Returns:
      The UUID.
    • getMaxSupportedLeds

      public int getMaxSupportedLeds()
      Returns:
      The maximum supported number of LEDs.
    • getNumberOfLed

      public int getNumberOfLed()
      Returns:
      The number of LEDs.
    • getLedProfile

      public String getLedProfile()
      Returns:
      The LED profile.
    • getFrameRate

      public int getFrameRate()
      Returns:
      The frame rate.
    • getMeasuredFrameRate

      public float getMeasuredFrameRate()
      Returns:
      The measured frame rate.
    • getMovieCapacity

      public int getMovieCapacity()
      Returns:
      The movie capacity.
    • getMaxMovies

      public int getMaxMovies()
      Returns:
      The maximum number of movies.
    • getWireType

      public int getWireType()
      Returns:
      The wire type.
    • getCopyright

      public String getCopyright()
      Returns:
      The copyright string.
    • getLogin

      public Login getLogin()
      Returns:
      The Login object containing authentication info.
    • getIp

      public String getIp()
      Returns:
      The device IP address.
    • setIp

      public void setIp(String ip)
      Sets the device IP address.
      Parameters:
      ip - The new IP address.
    • login

      public String login()
      Performs login to the device and returns the raw HTTP response.
      Returns:
      The HTTP response as a string.
    • setDeviceName

      public String setDeviceName(String deviceName)
    • getDeviceInfo

      public String getDeviceInfo()
      Gets device information (gestalt) as a JSON string.
      Returns:
      The JSON body as a string.
    • getFirmwareVersion

      public String getFirmwareVersion()
      Gets the firmware version of the device.
      Returns:
      The firmware version as a string.
    • logout

      public String logout()
      Logs out from the device.
      Returns:
      The HTTP response as a string.
    • setBrightness

      public String setBrightness(int brightness)
      Sets the brightness of the LEDs.
      Parameters:
      brightness - Brightness value (0..100)
      Returns:
      The HTTP response as a string.
    • getBrightness

      public int getBrightness()
      Gets the current brightness value.
      Returns:
      The brightness value (0..100)
    • setColor

      public String setColor(int red, int green, int blue)
      Sets the LED color using RGB values.
      Parameters:
      red - Red component (0..255)
      green - Green component (0..255)
      blue - Blue component (0..255)
      Returns:
      The HTTP response as a string.
    • setColorHSV

      public String setColorHSV(int hue, int saturation, int value)
      Sets the LED color using HSV color space.
      Parameters:
      hue - Hue component (0..359)
      saturation - Saturation component (0..255)
      value - Value/Brightness component (0..255)
      Returns:
      HTTP response as String
    • getColor

      public String getColor()
      Gets the current LED color as a raw HTTP response.
      Returns:
      The HTTP response as a string.
    • getLedRed

      public int getLedRed()
      Gets the red component of the current LED color.
      Returns:
      The red value (0..255)
    • getLedGreen

      public int getLedGreen()
      Gets the green component of the current LED color.
      Returns:
      The green value (0..255)
    • getLedBlue

      public int getLedBlue()
      Gets the blue component of the current LED color.
      Returns:
      The blue value (0..255)
    • setSaturation

      public String setSaturation(int saturation)
      Sets the saturation of the LEDs.
      Parameters:
      saturation - Saturation value (0..255)
      Returns:
      The HTTP response as a string.
    • getSaturation

      public int getSaturation()
      Gets the current saturation value.
      Returns:
      The saturation value (0..255)
    • setMode

      public String setMode(String mode)
      Sets the operating mode of the LEDs.
      Parameters:
      mode - The mode string (e.g., "movie", "color", etc.)
      Returns:
      The HTTP response as a string.
    • getMode

      public String getMode()
      Gets the current operating mode of the LEDs.
      Returns:
      The mode string.
    • setCurrentMovie

      public String setCurrentMovie(int movieId)
      Sets the current movie by its ID.
      Parameters:
      movieId - The movie ID.
      Returns:
      The HTTP response as a string.
    • verify

      public String verify()
      Verifies the authentication token with the device.
      Returns:
      The HTTP response as a string.