koush / scrypted

Scrypted is a high performance video integration and automation platform
https://scrypted.app
Other
4.16k stars 247 forks source link

mqtt: add support for `ColorSettingTemperature` and `ColorSettingHsv` #1317

Closed nberardi closed 7 months ago

nberardi commented 7 months ago

I have added support for colored lights in the current MQTT design. In my testing this works with both Z2M and ZHA in Home Assistant.

nberardi commented 7 months ago

I will downgrade it and resubmit. Sent from my iPhone, expect autocorrection issuesOn Feb 13, 2024, at 5:49 PM, Koushik Dutta @.***> wrote: @koush commented on this pull request.

In plugins/mqtt/package.json:

   "aedes": "^0.46.1",
  • "axios": "^0.23.0",
  • "axios": "^1.6.7",

this version of axios adds a 4MB dependency on mime db. it's why I haven't upgraded. I'm actually migrating off axios and using fetch directly since that is in node 18.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

nberardi commented 7 months ago

I was having the same debate with myself. I will remove and include directly in ‘util.js’

On Tue, Feb 13, 2024 at 5:51 PM Koushik Dutta @.***> wrote:

@.**** commented on this pull request.

In plugins/mqtt/package.json https://github.com/koush/scrypted/pull/1317#discussion_r1488686248:

   "aedes": "^0.46.1",
  • "axios": "^0.23.0",
  • "axios": "^1.6.7",
  • "color-convert": "^2.0.1",

I'd rather not introduce a dependency for a simple function here: from copilot:

function rgbToHsv(r: number, g: number, b: number): [number, number, number] { r /= 255, g /= 255, b /= 255;

let max = Math.max(r, g, b), min = Math.min(r, g, b);
let h, s, v = max;

let d = max - min;
s = max == 0 ? 0 : d / max;

if (max == min) {
    h = 0; // achromatic
} else {
    switch (max) {
        case r: h = (g - b) / d + (g < b ? 6 : 0); break;
        case g: h = (b - r) / d + 2; break;
        case b: h = (r - g) / d + 4; break;
    }
    h /= 6;
}

return [h, s, v];}

— Reply to this email directly, view it on GitHub https://github.com/koush/scrypted/pull/1317#pullrequestreview-1879085119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEH5HH37W65V7F3KX76G3YTPU5ZAVCNFSM6AAAAABDHJJGO2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNZZGA4DKMJRHE . You are receiving this because you authored the thread.Message ID: @.***>

nberardi commented 7 months ago

I have addressed the above requests, and squashed them back into the commit