datech / node-red-contrib-amazon-echo

Alexa controlled Node-Red nodes supporting latest Amazon Echo devices. NO Alexa Skills required. NO cloud dependencies.
MIT License
140 stars 42 forks source link

Feed brightness % in from MQTT #193

Closed harvybob closed 7 months ago

harvybob commented 1 year ago

Is your feature request related to a problem? Please describe. I have setup a dimmer (Tasmota using TuyaMCU). Turning it on/off dimmer is working ok - I have set up the feedback as per the Wiki, which allows me to see the On/Off status on Alexa App. I am not able to set the brightness in this way AS A PERCENTAGE - only as the brightness value. MQTT has the value as a percentage so I have to do the math to convert from percentage back to brightness value.

Describe the solution you'd like Using the example feedback in the Wiki, the currently I need to do this:

var dimmerval = (msg.payload.Dimmer / 0.4).toFixed(0);
if (msg.payload.POWER == "ON") {
    msg.payload = {
        on: true,
        bri: dimmerval,
        nodeid: nodeid
    }

I want to be able to do:

var dimmerval = msg.payload.Dimmer;
if (msg.payload.POWER == "ON") {
    msg.payload = {
        on: true,
        percentage: dimmerval,
        nodeid: nodeid
    }

Describe alternatives you've considered Having to do the math to convert from % to dimmer value - isnt accurate due to rounding issues - Alexa cant handle decimal values between 0 and 250

Additional context This may already be in place, but I am unable to use it correctly - if so, is there a list of the feedback values to use? I have tried percentage

datech commented 7 months ago

You may use range node to convert percentage to brightness (bri).