Hi all,
I have made a few rules for my son’s desk lamp, essentially in the rules I need to make comparison of brightness and send command to control brightness and colour temperature . The rules are all working, however when I open the rules in VS Code I received some errors, any suggestion how to fix them? Many thanks in advance!
First, run the code and see if it’s a “real” error. The syntax checking in VS Code sometimes has false positives when it comes to identifying errors, particularly errors having to do with types.
If this generates a real error when it’s actually run:
- Don’t specify the types of variables unless absolutely necessary.
- Don’t ever use DecimalType. Use Number instead.
- When posting code, logs, or configs to the forum, please post the text, not just screen shots. Use code fences.
code goes here
var brightness = hsb.brightness as Number
if(brightness == 0 && Outdoor_light_sensor.state < 2000|lx)
1 Like
Hi @rlkoshak :
Thank you for your reply, sorry I didn’t paste code in my post.
I did what you suggested and it solves the issue, thanks a lot!
Regarding another issue, I need to cast PercentType to Number to make the warning disappear. Just in case anybody also experience the same problem, below is how I fix sendCommand warning:
desk_lamp_dimmer.sendCommand(new PercentType(2*seed) as Number)