[SOLVED] HSBType error

running:

var HSBType weiss = new HSBType(new DecimalType(0),new PercentType(0),new PercentType(100))
Yeelightc_5.sendCommand(weiss)

Gives me the following syntax error in VS Code with OH extension:

"Ambiguous feature call.
The extension methods
    sendCommand(Item, Number) in BusEvent and
    sendCommand(Item, Command) in BusEvent
both match."

It still works but I would want to know, why I’m getting this error.

Had a similar chunk of code, swore it worked and didn’t throw an error a few weeks ago in VS code. Open the rules file a few days ago to work on something else and VS code flagged the last line of the following with similar error

var DecimalType hueINT = new DecimalType(0)
var PercentType saturationINT = new PercentType(100) 
var PercentType brightnessINT = new PercentType(5)
var HSBType lightOBJ = new HSBType(hueINT, saturationINT, brightnessINT)
Hue_Stairwell_Color.sendCommand(lightOBJ) 

Had to comment out the last line to get the file to not throw this error. VS code has auto updated itself a couple times, maybe something changed in VS code?

Is it an error or a warning?

You are getting this error because the item Yeelightc_5 can accept different types of command and VS is struggling to find out which one you actually mean to use even through you declared an HSBType.

You could get rid of the error by doing:

Yeelightc_5.sendCommand(weiss.toString)
1 Like

So…
this doesn’t work

var DecimalType hueINT = new DecimalType(0)
var PercentType saturationINT = new PercentType(100) 
var PercentType brightnessINT = new PercentType(5)
var HSBType lightOBJ = new HSBType(hueINT, saturationINT, brightnessINT)
Hue_Stairwell_Color.sendCommand(lightOBJ) 

but this does

var DecimalType hueINT = new DecimalType(0)
var PercentType saturationINT = new PercentType(100) 
var PercentType brightnessINT = new PercentType(5)
var HSBType lightOBJ = new HSBType(hueINT, saturationINT, brightnessINT)
Hue_Stairwell_Color.sendCommand(lightOBJ.toString) 

just checked it, Vincent is right. I can set a Lifx bulb like this:

LifXbulb.sendcommand('0,100,2')

but I have to construct a HSBType for my Hue bulbs, then use toString on the variable to work.

Once again, thank you alot!
works perfect