Dimming X10 modules
-
I finally got back to trying this. Found that you send an "on" command, following by "dim" commands. Each "dim" command dims the lights by 10%.
e.g.
if "%1"=="dim" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"K4% on%"
if "%1"=="dim" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"K4% dim%"
if "%1"=="dim" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"K4% dim%"
if "%1"=="dim" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"K4% dim%"
to dim to 70%.
This works clicking the dim button on your site:
"Ceiling light script ran with param dim" Thu 02/06/2025 13:08:43.20
I had Alexa discover devices to pick up the new parameter, but when I give the command "turn ceiling lights dim" I get this in logging:
"Ceiling light script ran with param undefined" Thu 02/06/2025 13:09:23.64
Apparently your TRIGGERcmd Home Automation skill doesn't pass anything but on/off. Be great if this was changed,
Thanks,
Ken -
@karnold69, you can send a dim level from 0 to 100 percent.
For example, I have a command called "logger" with parameters enabled. I just said, "Alexa, logger 10 percent" and it ran my command with 10 as the parameter.
Here's the Runs list entry:
-
@Russ
That doesn't work with X10. It needs to receive an "on" command followed by X number of "dim" commands as in the example I posted.. I did try Alexa, ceiling lights 60 percent and logging showed it passed a 60 parameter. When I used the "dim" parameter it logs as "parameter undefined." Although it works clicking the "dim" button on your site. -
@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%%
-
@Russ Sorry, gave you bad intel. The DIM command requires a percentage parameter. To complicate things more, when the PLM receives DIM 60, it changes it to DIM 63.
e.g. from log
Transmit J Dim 60(Loft Lights)
Receive J Dim 63(Loft Lights)
X10 Commander sends both, dimming it twice. The Active Home software shows it dimmed to 13%. It's not good at math!
Also, a light has to be on to accept DIM/BRIGHT commands.
I documented everything in the bat file so others can use it. I'm using an X10 CM15a USB PLM with X10 Commander and Active Home Pro software.
After extensive trial an error, here's the resulting batch file that works:
batch
@echo off
if "%1"=="on" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"J7% bright% 100%"
if "%1"=="on" exit \b
if "%1"=="off" curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"J7% off%"
if "%1"=="off" exit \bset "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 validecho "Invalid dim level. Please enter 10, 20, 30, ..., 90." %date% %time% >> c:\scripts\x10_log.txt
exit /b:valid
:: change input value to legitimate values. (10% is valid as 10%)
if "%level%"=="20" set level="21"
if "%level%"=="30" set level="31"
if "%level%"=="40" set level="42"
if "%level%"=="50" set level="52"
if "%level%"=="60" set level="63"
if "%level%"=="70" set level="73"
if "%level%"=="80" set level="84"
if "%level%"=="90" set level="94"
:: light must be on to accept DIM/BRIGHT commands
curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"J7% on%"
:: set a delay so my phase coupler/repeater in my breaker box has time to repeat command before receiving another
ping -n 4 localhost >nul
:: bring light to full brightness. If light was previously dimmed, it will dim it more.
curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"J7% bright% 100%"
ping -n 4 localhost >nul
curl http://127.0.0.1:8086/?x10command=DEVICE~sendplc~%"J7% dim% %level%%"::echo "Dimmed to %level%" %date% %time% >> c:\scripts\x10_log.txt
-
Nice @karnold69 ! Thanks for sharing your working script.
-
@Russ Thanks for getting me started.
Also meant to post commands must be URL encoded even though it isn't a URL.
Verbal command would be something like "Alexa, turn Loft Lights 40 [percent]