Index: /trunk/I_Rain8_1.xml
===================================================================
--- /trunk/I_Rain8_1.xml	(revision 1)
+++ /trunk/I_Rain8_1.xml	(revision 3)
@@ -16,22 +16,22 @@
         function sendCommand(command)
             luup.log("rain8net: sending command: " .. textToHex(tostring(command)) )
-            if (luup.io.write(command) == false) then
+            if (luup.io.write(tostring(command)) == false) then
                 luup.log("Cannot send command " .. textToHex(tostring(command)) .. " communications error", 1)
                 luup.set_failure(true)
                 return false
+	        end
+            --TODO: Verify ACK from device?
+	        return true
 	    end
-        --TODO: Verify ACK from device?
-	    return true
-	end
 
-    function buildCommand( unit, zone, command )
-	    -- 0x40 [unit] [command | zone]
-	    return string.char( 0x40, unit, (command + zone) )
-    end
+        function buildCommand( unit, zone, command )
+    	    -- 0x40 [unit] [command | zone]
+    	    return string.char( 0x40, unit, (command + zone) )
+        end
 
-    function rain8Startup(lul_device)
-        luup.log("Running I_Rain8_1.xml")
-        -- TODO: Should get poll device for current state?
-    end
+        function rain8Startup(lul_device)
+            luup.log("Running I_Rain8_1.xml")
+            -- TODO: Should get poll device for current state?
+        end
     </functions>
 
@@ -47,10 +47,10 @@
 
         <action>
-            <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId>
+            <serviceId>urn:upnp-org:serviceId:Rain8Switch_1</serviceId>
             <name>SetTarget</name>
 	        <run>
                 local power = lul_settings[ 'newTargetValue']
-		        local unit = 1 --luup.variable_get("urn:edmidor-com:serviceId:Rain8_1", "Unit", lul_device)
-		        local zone = 1 --luup.variable_get("urn:edmidor-com:serviceId:Rain8_1", "Zone", lul_device)
+		        local unit = luup.variable_get( "urn:upnp-org:serviceId:Rain8Switch_1", "Unit", lul_device )
+		        local zone = luup.variable_get( "urn:upnp-org:serviceId:Rain8Switch_1", "Zone", lul_device )
 
                 if( power == "1" ) then
@@ -61,8 +61,23 @@
                     sendCommand( buildCommand(unit, zone, 0x40) );
                 end
+
+                -- Indicate we have run
+                -- TODO: Move to when we have verified valve is on (ACK)
+                luup.variable_set( "urn:upnp-org:serviceId:Rain8Switch_1", "Status", power, lul_device )
+
                 return true
             </run>
         </action>
 
+        <action>
+            <serviceId>urn:upnp-org:serviceId:Rain8Switch_1</serviceId>
+            <name>SetAddress</name>
+            <run>
+                luup.log("Rain8: Set address to " .. lul_settings['Unit'] .. ":" .. lul_settings['Zone'] )
+    	        luup.variable_set( "urn:upnp-org:serviceId:Rain8Switch_1", "Unit", lul_settings['Unit'], lul_device )
+    	        luup.variable_set( "urn:upnp-org:serviceId:Rain8Switch_1", "Zone", lul_settings['Zone'], lul_device )
+            </run>
+	    </action>
+
         </actionList>
 </implementation>
Index: /trunk/S_Rain8Switch_1.xml
===================================================================
--- /trunk/S_Rain8Switch_1.xml	(revision 3)
+++ /trunk/S_Rain8Switch_1.xml	(revision 3)
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<scpd xmlns="urn:schemas-upnp-org:service-1-0">
+  <specVersion>
+    <major>1</major>
+    <minor>0</minor>
+  </specVersion>
+  <serviceStateTable>
+    <stateVariable sendEvents="no">
+      <name>Target</name>
+      <sendEventsAttribute>no</sendEventsAttribute> 
+      <dataType>boolean</dataType>
+      <defaultValue>0</defaultValue>
+    </stateVariable>
+    <stateVariable sendEvents="yes">
+      <name>Status</name>
+      <dataType>boolean</dataType>
+      <defaultValue>0</defaultValue>
+      <shortCode>status</shortCode>
+    </stateVariable>
+  </serviceStateTable>
+  <actionList>
+    <action>
+    <name>SetTarget</name>
+      <argumentList>
+        <argument>
+          <name>newTargetValue</name>
+          <direction>in</direction>
+          <relatedStateVariable>Target</relatedStateVariable>
+        </argument>
+      </argumentList>
+    </action>
+    <action>
+    <name>GetTarget</name>
+      <argumentList>
+        <argument>
+          <name>RetTargetValue</name>
+          <direction>out</direction>
+          <relatedStateVariable>Target</relatedStateVariable>
+        </argument>
+      </argumentList>
+    </action>
+    <action>
+    <name>GetStatus</name>
+      <argumentList>
+        <argument>
+          <name>ResultStatus</name>
+          <direction>out</direction>
+          <relatedStateVariable>Status</relatedStateVariable>
+        </argument>
+      </argumentList>
+    </action>
+    <action>
+    <name>SetAddress</name>
+      <argumentList>
+        <argument>
+          <name>Unit</name>
+          <direction>in</direction>
+        </argument>
+        <argument>
+          <name>Zone</name>
+          <direction>in</direction>
+        </argument>
+      </argumentList>
+    </action>
+  </actionList>
+</scpd>
Index: /trunk/D_Rain8_1.json
===================================================================
--- /trunk/D_Rain8_1.json	(revision 3)
+++ /trunk/D_Rain8_1.json	(revision 3)
@@ -0,0 +1,280 @@
+{
+	"flashicon": "icons\/generic_sensor.swf",
+	"imgIconBody": "",
+	"imgIconDimmable": "",
+	"imgIconTurnable": "",
+	"imgIconMin": "",
+	"imgIconMax": "",
+	"halloIconsDir": "pics\/hallo",
+	"DisplayStatus": {
+		"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+		"Variable": "Status",
+		"MinValue": "0",
+		"MaxValue": "1" 
+	},
+
+	"doc_url":{
+		"doc_forced_url":{
+			"text":"http://wiki.micasaverde.com/index.php/Rain8"
+		}
+	},
+
+	"ToggleButton": 1,
+
+	"Tabs": [
+	{
+		"Label": {
+			"lang_tag": "tabname_control",
+			"text": "Control" 
+		},
+		"Position": "0",
+		"TabType": "flash",
+		"ControlGroup":[
+		{
+			"id":"1",
+			"isSingle":"1"
+		},
+		{
+			"id":"2",
+			"isSingle":"1"
+		}
+		],
+		"Control": [
+		{
+			"ControlGroup":"2",
+			"ControlType": "button",
+			"Label": {
+				"lang_tag": "cmd_on",
+				"text": "On" 
+			},
+			"Display": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Variable": "Status",
+				"Value": "1",
+				"Top": 60,
+				"Left": 145,
+				"Width": 75,
+				"Height": 20 
+			},
+			"Command": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Action": "SetTarget",
+				"Parameters": [
+				{
+					"Name": "newTargetValue",
+					"Value": "1" 
+				}
+				]
+			} 
+		},
+		{
+			"ControlGroup":"1",
+			"ControlType": "button",
+			"Label": {
+				"lang_tag": "cmd_off",
+				"text": "Off" 
+			},
+			"Display": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Variable": "Status",
+				"Value": "0",
+				"Top": 60,
+				"Left": 50,
+				"Width": 75,
+				"Height": 20 
+			},
+			"Command": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Action": "SetTarget",
+				"Parameters": [
+				{
+					"Name": "newTargetValue",
+					"Value": "0" 
+				}
+				]
+			}
+		}
+		]
+	},
+	{
+		"Label": {
+			"lang_tag": "Rain8_Irigation_Controller",
+			"text": "Rain8 Irigation Controller"
+		},
+		"Position": "3",
+		"TabType": "flash",
+		"Control": [
+		{
+			"ControlGroup": "2",
+			"ControlHeader": "1",
+			"ControlType": "label",
+			"Label": {
+				"lang_tag": "unit",
+				"text": "Unit"
+			},
+			"Display": {
+				"Top": 20,
+				"Left": 10,
+				"Width": 50,
+				"Height": 20
+			}
+		},
+		{
+			"ControlGroup": "2",
+			"ControlPair": "1",
+			"ControlType": "input",
+			"ID": "Unit",
+			"Display": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Variable": "Unit",
+				"Top": 20,
+				"Left": 60,
+				"Width": 50,
+				"Height": 20
+			}
+		},
+		{
+			"ControlGroup": "2",
+			"ControlHeader": "1",
+			"ControlType": "label",
+			"Label": {
+				"lang_tag": "zone",
+				"text": "Zone"
+			},
+			"Display": {
+				"Top": 50,
+				"Left": 10,
+				"Width": 50,
+				"Height": 20
+			}
+		},
+		{
+			"ControlGroup": "2",
+			"ControlPair": "1",
+			"ControlType": "input",
+			"ID": "Zone",
+			"Display": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Variable": "Zone",
+				"Top": 50,
+				"Left": 60,
+				"Width": 50,
+				"Height": 20
+			}
+		},
+		{
+			"ControlType": "button",
+			"Label": {
+				"lang_tag": "cmd_set",
+				"text": "Set"
+			},
+			"Display": {
+				"Top": 80,
+				"Left": 60,
+				"Width": 50,
+				"Height": 20
+			},
+			"Command": {
+				"Service": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"Action": "SetAddress",
+				"Parameters": [
+				{
+					"Name": "Unit",
+					"ID": "Unit"
+				},
+				{
+					"Name": "Zone",
+					"ID": "Zone"
+				}
+				]
+			}
+		}
+		]
+	},
+	{
+		"Label": {
+			"lang_tag": "notifications",
+			"text": "Notifications"
+		},
+		"Position": "5",
+		"TabType": "javascript",
+		"ScriptName": "shared.js",
+		"Function": "device_notifications"
+	},
+	{
+		"Label": {
+			"lang_tag": "settings",
+			"text": "Settings"
+		},
+		"Position": "1",
+		"TabType": "javascript",
+		"ScriptName": "shared.js",
+		"Function": "simple_device"
+	},
+	{
+		"Label": {
+			"lang_tag": "advanced",
+			"text": "Advanced"
+		},
+		"Position": "2",
+		"TabType": "javascript",
+		"ScriptName": "shared.js",
+		"Function": "advanced_device"
+	}
+	],
+
+	"sceneList": {
+		"group_1": {
+			"cmd_1": {
+				"label": "ON",
+				"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"action": "SetTarget",
+				"arguments": {
+					"newTargetValue": "1" 
+				},
+				"display": {
+					"service": "urn:upnp-org:serviceId:Rain8Switch_1",
+					"variable": "Status",
+					"value": "1" 
+				}
+			},
+			"cmd_2": {
+				"label": "OFF",
+				"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+				"action": "SetTarget",
+				"arguments": {
+					"newTargetValue": "0" 
+				},
+				"display": {
+					"service": "urn:upnp-org:serviceId:Rain8Switch_1",
+					"variable": "Status",
+					"value": "0" 
+				}
+			}
+		}
+	},
+
+	"eventList": {
+		"event_1": {
+			"label": "A device is turned on or off",
+			"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+			"argumentList": {
+				"argument_1": {
+					"dataType": "boolean",
+					"defaultValue": "1",
+					"allowedValueList": {
+						"Off": "0",
+						"On": "1" 
+					},
+					"name": "Status",
+					"comparisson": "=",
+					"prefix": "Which mode",
+					"suffix": "" 
+				} 
+			}
+		}
+	},
+
+	"DeviceType": "urn:schemas-micasaverde-com:device:Rain8_1:1",
+	"device_type": "urn:schemas-micasaverde-com:device:Rain8_1:1"
+}
Index: /trunk/D_Rain8_1.xml
===================================================================
--- /trunk/D_Rain8_1.xml	(revision 1)
+++ /trunk/D_Rain8_1.xml	(revision 3)
@@ -6,6 +6,6 @@
   </specVersion>
   <device>
-    <deviceType>urn:schemas-upnp-org:device:BinaryLight:1</deviceType>
-    <staticJson>D_BinaryLight1.json</staticJson>
+    <deviceType>urn:schemas-upnp-org:device:Rain8_1:1</deviceType>
+    <staticJson>D_Rain8_1.json</staticJson>
     <friendlyName>Rain8net Irigation Controller over RS232</friendlyName>
     <manufacturer>WGL Designs</manufacturer>
@@ -24,12 +24,62 @@
     <serviceList>
         <service>
-           <serviceType>urn:schemas-upnp-org:service:SwitchPower:1</serviceType>
-	   <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId>
-           <controlURL>/upnp/control/SwitchPower1</controlURL>
-           <eventSubURL>/upnp/event/SwitchPower1</eventSubURL>
-           <SCPDURL>S_SwitchPower1.xml</SCPDURL>
+           <serviceType>urn:schemas-upnp-org:service:Rain8Switch_1:1</serviceType>
+	   <serviceId>urn:upnp-org:serviceId:Rain8Switch_1</serviceId>
+           <controlURL>/upnp/control/Rain8Switch_1</controlURL>
+           <eventSubURL>/upnp/event/Rain8Switch_1</eventSubURL>
+           <SCPDURL>S_Rain8Switch_1.xml</SCPDURL>
         </service>
     </serviceList>
-
+    <sceneList>
+{
+	"group_1":{
+		"cmd_1": 
+		{
+			"label": "ON",
+			"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+			"action": "SetTarget",
+			"arguments":
+			{
+				"newTargetValue": "1"
+			}
+		},
+		"cmd_2": 
+		{
+			"label": "OFF",
+			"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+			"action": "SetTarget",
+			"arguments":
+			{
+				"newTargetValue": "0"
+			}
+		}
+	}
+}	
+	</sceneList>
+ 	<eventList>
+{
+	"event_1":{
+		"label": "A device is turned on or off",
+		"serviceId": "urn:upnp-org:serviceId:Rain8Switch_1",
+		"argumentList" :
+		{
+			"argument_1" :
+			{
+				"dataType": "boolean",
+				"defaultValue": "1",
+				"allowedValueList" : 
+				{
+					"Off" : "0",
+					"On" : "1"
+				},
+				"name": "Status",
+				"comparisson": "=",
+				"prefix": "Which mode",
+				"suffix": ""
+			}
+		}
+	}
+}
+  </eventList>	
   </device>
 </root>
