|
Page 1 of 2
|
[ 28 posts ] |
Go to page: 1, 2 Next |
X10 to INSTEON mapping script
| Author |
Message |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
 X10 to INSTEON mapping script
I wrote this script to support X10 controllers without having to define X10 addresses in Indigo or Insteon devices and without having to create a dozen triggers. For example, if you have Insteon devices and X10 remotes, you could define X10 addresss for these devices and control them. However, this eliminates the benefits of Insteon reliability and continues to put X10 traffic on the powerline. You could also use a combination of dummy X10 devices and a series of triggers (one trigger each for on, off, dim, brighten); but that becomes a maintenance headache (to support a single 4001X remote, you'd need to create 16 dummy devices and 64 triggers). So this script allows you to map an X10 address to one of more devices (X10 or Insteon) and will send the appropriate command to the device after receiving an X10 command for that address. The only thing to define is the mapping of the X10 address to the device in the script. The script also supports a default power-on level for dimmable devices. As an enhancement to regular remote operation, successive on commands will toggle the device between the default on level and 100%. - Code: Select all
-- Virtual X10 -- virtual X10 allows you to control Indigo devices using X10 controllers -- without having to create multiple triggers for the various X10 -- commands or configuring Insteon devices for X10 operation. -- -- v1.0 Nick Sosnicki December 2006 (tested on 2.0b12) -- the following X10 commands are supported: on, off, brighten by, dim by. -- the script could be easily enhanced to support other x10 commands (like -- status requests, all on/off, etc.) as needed. On-level toggle will toggle -- the device between the default on-level and 100% with subsequent -- on commands.
-- Map of X10 addresses to Indigo objects -- a X10 address can map to multiple objects to create scenes. -- maps are defined with these parameters: -- X10 address "C7" -- Name "Lamp" Name of the device to control as defined in Indigo -- On level 75 For a lamp type device, the default brightness when on command received (0-100); -- set to 100 to disable on-level toggle property x10DeviceMap : {¬ {"B1", "Ceiling Light-Master Bedroom", 70}, ¬ {"B2", "Bedside Lamp Right-Master Bedroom", 60}, ¬ {"B3", "Bedside Lamp Left-Master Bedroom", 60}, ¬ {"B4", "Closet Light-Master Bedroom", 80}, ¬ {"B5", "Chiffonier Lamp-Master Bedroom", 60} ¬ }
property debugLog : false --set to true to send debug messages to the log
using terms from application "IndigoServer" on receive x10 event of command for address addr with dim dimVal with preset presetlevel with xdata xdataVal with xcommand xcommandVal if debugLog then log "Adr: " & addr & " Cmd: " & command & " Dim: " & dimVal & " Pre: " & presetlevel & " xDa: " & xdataVal & " xCm: " & xcommandVal using type "VirtualX10" --Cycle through map and perform actions set deviceAddress to "" repeat with mapEntry in x10DeviceMap if item 1 of mapEntry is addr then set deviceAddress to item 2 of mapEntry if debugLog then log "address " & addr & " maps to " & deviceAddress using type "VirtualX10" if command is x10TurnOn then set defaultBright to item 3 of mapEntry if defaultBright is 100 then if debugLog then log "turn on " & deviceAddress using type "VirtualX10" turn on device deviceAddress else status request device deviceAddress set currentBright to brightness of device deviceAddress if currentBright is greater than or equal to defaultBright and currentBright < 100 then set targetBright to 100 else set targetBright to defaultBright end if if debugLog then log deviceAddress & " is at " & currentBright & "; default bright is " & defaultBright & "; brighten to " & targetBright using type "VirtualX10" brighten device deviceAddress to targetBright end if else if command is x10TurnOff then if debugLog then log "turn off " & deviceAddress using type "VirtualX10" turn off device deviceAddress else if command is x10BrightenDevice then if debugLog then log "brighten " & deviceAddress & " by " & (dimVal as text) using type "VirtualX10" brighten device deviceAddress by dimVal else if command is x10DimDevice then if debugLog then log "dim " & deviceAddress & " by " & (dimVal as text) using type "VirtualX10" dim device deviceAddress by dimVal end if end if end repeat if deviceAddress is "" then if debugLog then log "address " & addr & " not found." using type "VirtualX10" end if end receive x10 event end using terms from
Last edited by matt (support) on Wed May 11, 2011 6:57 am, edited 2 times in total.
Removed deprecated Indigo call from script.
|
| Mon Jan 01, 2007 1:18 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Great script!
I'm using it right now and I've allready disabled 32 triggers.
Found one small error in your code though, because of the copy/paste action:
- Code: Select all
if currentBright ? defaultBright and currentBright < 100 then
The ? should be a = with / sign. (Don't know what it's real name is, but you can get it by typing the option key and the = key simultaneously.) Can you explain why you are using this piece of code? - Code: Select all
set currentBright to brightness of device deviceAddress if currentBright ? defaultBright and currentBright < 100 then set targetBright to 100 else set targetBright to defaultBright end if if debugLog then log deviceAddress & " is at " & currentBright & "; default bright is " & defaultBright & "; ¬ brighten to " & targetBright using type "VirtualX10" brighten device deviceAddress to targetBright
According to the code, if the brightness of the device is not the default brightness and it is not at it's maximum you set it to the max.
This means that if you switch the light on, it will allways go to the max level. And if it's allready on, but not at the default brightness level, it will also go to the max.
I find this a bit strange, but maybe you have a reason to do this.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Sun Jan 28, 2007 11:50 am |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
macpro wrote:Great script! I'm using it right now and I've allready disabled 32 triggers.
I'm glad its useful for you. Its been a real time saver for me too. I also like the fact I can build quick and dirty remote button scenes just by defining multiple devices to a single X10 address. macpro wrote:Found one small error in your code though, because of the copy/paste action: - Code: Select all
if currentBright ? defaultBright and currentBright < 100 then
The ? should be a = with / sign.
Actually it should be >=. For clarity: - Code: Select all
if currentBright is greater than or equal to defaultBright and currentBright < 100 then
macpro wrote:Can you explain why you are using this piece of code? ... This means that if you switch the light on, it will allways go to the max level.
It works a little differently with the >=.
Many of the lights I use the remote for, I usually have on at a dimmed level. Like my bedside lamp I usually like on at 50%. So using the remote, I could press "on" then press dim 3 or 4 times. But with the script I just press on and it goes to 50%. If I really want it on all the way, I just press on again. And if I press on yet again, it returns to the default level (and I can toggle between the two levels). If you set the default level for the device to 100, this functionality is disabled.
|
| Sun Jan 28, 2007 2:19 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Ok, now it's clear.
Thanks for explaining that.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Sun Jan 28, 2007 3:15 pm |
|
 |
|
Rickk
Joined: Oct 21, 2005 Posts: 52 Location: Milford, Michigan
|
Looks like a great script. I can't wait to try it tonight.
A few of questions...
1) I assume you put this script in the "Attachment scripts" Folder.
2) Also you mention "can map to multiple objects to create scenes."
is this using a new line or do you use a separator in the same X10 address line.
3) and finally, is one script all that is needed for mapping all remotes, Or should I set up a house code B script seperat from a house code c script?
I am sure I could figure this out when I get home, but I thought I would ask before.
Thanks
|
| Mon Jan 29, 2007 3:41 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Rickk wrote:1) I assume you put this script in the "Attachment scripts" Folder.
Yes. Rickk wrote:3) and finally, is one script all that is needed for mapping all remotes, Or should I set up a house code B script seperat from a house code c script?
Yes. You can add every address you use into the device map, so one script is all you need.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Mon Jan 29, 2007 3:55 pm |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
Rickk wrote:2) Also you mention "can map to multiple objects to create scenes." is this using a new line or do you use a separator in the same X10 address line.
For example:
- Code: Select all
property x10DeviceMap : {¬ {"B1", "Ceiling Light-Master Bedroom", 70}, ¬ {"B1", "Bedside Lamp Right-Master Bedroom", 60}, ¬ {"B1", "Bedside Lamp Left-Master Bedroom", 60}, ¬ {"B1", "Closet Light-Master Bedroom", 80}, ¬ {"B1", "Chiffonier Lamp-Master Bedroom", 60} ¬ }
B1 will activate all 5 lights.
|
| Mon Jan 29, 2007 8:25 pm |
|
 |
|
Rickk
Joined: Oct 21, 2005 Posts: 52 Location: Milford, Michigan
|
The script is very flexible.
Nice job, the only short coming I felt was speed.
I am not sure if this is in the script, Line noise or RF antenna setup.
I am using a WRF80032.
Do you have any suggestions to speed up the actions?
Should the antenna RF interface Options have "Retransmit to X10 interface" checked?
Any other ideas?
Thanks
Rick
|
| Tue Jan 30, 2007 2:27 pm |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
Do not check the "retransmit" option unless you have other X10 devices on the same housecode you want to control directly, that should speed things up.
Disabling the default on level (by setting the default on level to 100) will speed up "turn on."
Also, the more devices you have defined, the slower it will be. If you have a large list of devices in the script, you could put the ones you want to be the most responsive at the top of the list.
FWIW, in my installation I don't notice any difference in response time between activating an Insteon device using this script (via the WRF80032 interface and X10 remote) and activating a X10 device with the same interface/remote (even with the retransmit option checked).
|
| Tue Jan 30, 2007 8:13 pm |
|
 |
|
jldomains
Joined: Jan 30, 2007 Posts: 32
|
 Can I use your script for X10 dimmers (i don't use Insteon)
Hi,
I read about your script and I really like your double rf on button first 2 dim level then to 100%. This is exactly what I need. However you mention the script is for Insteon, is there any problem using it for X10 dimmers and X10 lamp modules?
_________________ JSL
|
| Tue Jan 30, 2007 9:37 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Not at all. I'm using it in a X10 only installation, as Insteon is still not available in Europe.
The script works without any problems.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Wed Jan 31, 2007 12:25 am |
|
 |
|
jldomains
Joined: Jan 30, 2007 Posts: 32
|
 Problem w/ x10 lamp modules
macpro thanks for the x10 clarification. I installed the script in Indigo 2 and modified the x10DeviceMap for my x10 devices.
The script works on my Leviton hcm10-1dw light switches, which is great!
However on my Leviton Lamp modules hcp-03 the sript does not work as expected. What happens with the Leviton Lamp modules hcp-03 is that if you send RF on it goes to default brightness and then RF off and then RF on it goes to 100% brightness when what I want is that the first time pressing RF on (after a RF off) it should go to the default brightness. Can anyone help correct this?
_________________ JSL
|
| Sat Feb 03, 2007 4:41 pm |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
It sounds like the device status in Indigo is not getting updated after the off command. So even though the device may be off, Indigo is still showing it as on.
What is the device's state in Indigo after sending the Off command?
|
| Sat Feb 03, 2007 11:24 pm |
|
 |
|
jldomains
Joined: Jan 30, 2007 Posts: 32
|
 Getting lamp modules to work with Virtual X10
Hi Nick,
First of all thanks for sharing your script. The idea of being able to use a RF on button as a toggle between dim value and 100% on is brilliant.
I checked in the Indigo 2 Home Window and after I send a RF off command the number for the Leviton lamp module goes to 0.
I have several lamp modules Leviton hcp-03 and they all act the same way.
I tried adding some logging to your script (first time applescripting), but still cannot find out what is going on. Here is one of them:
if debugLog then log deviceAddress & " is at " & currentBright using type "VirtualX10"
right after your line
set currentBright to brightness of device deviceAddress
When I run the RF on right after a RF off for a wall switch (Leviton hcm10-1dw) I get:
VirtualX10 Gym Ceiling is at 0
When I run the RF on right after a RF off for a lamp module (Leviton hcp-03) I get:
VirtualX10 Gym Bedside Lamp JL is at 26
However in the Indigo 2 Home window after RF off they are both at 0.
Below is the log for both:
Feb 4, 2007 12:10:52 PM
Received X10 "new device 1" off
VirtualX10 Adr: D9 Cmd: «constant ****xF03» Dim: Pre: xDa: xCm:
VirtualX10 address D9 maps to Gym Ceiling
VirtualX10 turn off Gym Ceiling
Sent X10 "Gym Ceiling" off
Received X10 "new device 1" on
VirtualX10 Adr: D9 Cmd: «constant ****xF02» Dim: Pre: xDa: xCm:
VirtualX10 address D9 maps to Gym Ceiling
VirtualX10 Gym Ceiling is at 0
VirtualX10 Gym Ceiling is at 0; default bright is 15; brighten to 15
Sent X10 "Gym Ceiling" extended dim to 15
Feb 4, 2007 12:12:46 PM
Received X10 "Gym Bedside Lamp JL" off
VirtualX10 Adr: D10 Cmd: «constant ****xF03» Dim: Pre: xDa: xCm:
VirtualX10 address D10 maps to Gym Bedside Lamp JL
VirtualX10 turn off Gym Bedside Lamp JL
Sent X10 "Gym Bedside Lamp JL" off
Received X10 "Gym Bedside Lamp JL" on
VirtualX10 Adr: D10 Cmd: «constant ****xF02» Dim: Pre: xDa: xCm:
VirtualX10 address D10 maps to Gym Bedside Lamp JL
VirtualX10 Gym Bedside Lamp JL is at 26
VirtualX10 Gym Bedside Lamp JL is at 26; default bright is 26; brighten to 100
Sent X10 "Gym Bedside Lamp JL" extended dim to 100
Thanks.
_________________ JSL
|
| Sun Feb 04, 2007 4:20 pm |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
The logging function is built into the script. All you need to do is change the line "property debugLog : false" to "property debugLog : true" to turn on the debugging.
I'm not sure why Indigo is reporting one dim level via Applescript and a different level in the UI.
Try adding these 2 lines below after the line "turn off device deviceAddress":
- Code: Select all
set currentBright to brightness of device deviceAddress if debugLog then log deviceAddress & " is at " & currentBright & " after turn off"
|
| Sun Feb 04, 2007 5:20 pm |
|
|
|
Page 1 of 2
|
[ 28 posts ] |
Go to page: 1, 2 Next |
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|