diff --git a/Script-Cookbook.md b/Script-Cookbook.md index 6f35dacb..da6e1bc2 100644 --- a/Script-Cookbook.md +++ b/Script-Cookbook.md @@ -624,7 +624,7 @@ next Since I own a magic home with IR receiver I made a script to show how it works I have 2 magic home devices that should be synchronized so I send the commands also to a second magic home via websend -vers1 with if then else +**Script example using `if then else`** >; define (expand string section to 25 chars) **>D 25** istr="" @@ -693,44 +693,54 @@ endif > >istr="" -vers2 with switch case ends +**Script example using `switch case ends`** >; define (expand string section to 25 chars) **>D** 25 istr="" ws="websend [192.168.178.84]" + >; event section **>E** +; get ir data istr=IrReceived#Data -switch istr +> +>switch istr ; on case "0x00F7C03F" =>wakeup =>%ws% wakeup -;off +> +>;off case "0x00F740BF" =>power1 0 =>%ws% power1 0 -;white +> +>;white case "0x00F7E01F" =>color 000000ff =>%ws% color 000000ff -;red +> +>;red case "0x00F720DF" =>color ff000000 =>%ws% color ff000000 -;green +> +>;green case "0x00F7A05F" =>color 00ff0000 =>%ws% color 00ff0000 -;blue +> +>;blue case "0x00F7609F" =>color 0000ff00 =>%ws% color 0000ff00 -; dimmer up +> +>; dimmer up case "0x00F700FF" =>dimmer + =>%ws% dimmer + -; dimmer down +> +>; dimmer down case "0x00F7807F" =>dimmer - =>%ws% dimmer -