@karnold69 sorry, I didn't read your first post well enough. Now I understand you want to be able to dim your X10 bulbs with a Windows batch file using Alexa. Please try this script:
Be aware though, you can't dim smart bulbs or send a percentage to a triggercmd acommand by saying to Alexa, "Alexa, dim bulb X". You have to say "Alexa, dim bulb X to 20 percent", or something like that (where X is the bulb name or voice name for your triggercmd command.
I used ChatGPT to create this script, and tested it. I think it could work for you.
https://chatgpt.com/share/67a91dfc-f4a4-8004-bfd5-09f488830d9e
Here’s a revised version of your script that allows you to specify a percentage instead of the word "dim." It ensures the dim level is one of the allowed values (10, 20, 30, etc.) and calculates the number of dim commands needed accordingly.
script.bat:
batch
@echo off
set "level=%1"
:: Ensure the input is a valid percentage (10, 20, ..., 90)
if "%level%"=="10" goto valid
if "%level%"=="20" goto valid
if "%level%"=="30" goto valid
if "%level%"=="40" goto valid
if "%level%"=="50" goto valid
if "%level%"=="60" goto valid
if "%level%"=="70" goto valid
if "%level%"=="80" goto valid
if "%level%"=="90" goto valid
echo Invalid dim level. Please enter 10, 20, 30, ..., 90.
exit /b
:valid
:: Turn on the light (assumes it starts at 100)
curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~"K4 on"
:: Calculate the number of dim commands (each step reduces by 10%)
set /a "steps=(100 - %level%) / 10"
:: Send the dim commands
for /l %%i in (1,1,%steps%) do (
curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~"K4 dim"
)
echo Dimmed to %level%%