openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.46k stars 273 forks source link

Mass configuration script for Windows (works for OBK and Tasmota, via HTTP cmnd API) #719

Open openshwprojects opened 1 year ago

openshwprojects commented 1 year ago

Here's a little thingy that can send commands over HTTP to devices that are already on your network: https://github.com/openshwprojects/TasmotaHTTPCurlConfigurator

Writeup: https://www.elektroda.com/rtvforum/topic3963037.html

What do you guys think? Any pull requests are welcome.

no2chem commented 1 year ago

Why a non cross-platform batch file?

I use a simple nodejs script, but I'm sure it's easy enough to just whip one up in your preferred scripting language. As a bonus it runs in parallel which is useful if there's 30 lights to update...

The script I use is below.... could dump it somwhere if you'd find it useful.

#!/usr/bin/env -S node --no-warnings --loader ts-node/esm

export {}

const runCommand = async (host: string, cmd : string) => {
    await fetch(`http://${host}/cmd_tool?cmd=${encodeURIComponent(cmd)}`);
}

const hosts = ['192.168.4.1', '192.168.4.2'];
const commands = [ 'SetPinRole 6 PWM', 'SetPinRole 4 PWM'];

const hostTasks = hosts.map(async host =>{
    for (const command of commands) {
        await runCommand(host, command);
    }
});

console.log(await Promise.allSettled(hostTasks));
openshwprojects commented 1 year ago

I really wanted to use something that is available on most of the average user PCs. Well, except that CURL...

I may update the script and add versions in other languages.