|
From: <Ba...@us...> - 2012-01-08 19:33:42
|
Revision: 4394
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4394&view=rev
Author: BartEv
Date: 2012-01-08 19:33:34 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/VeraControl/DevCategories.cs
trunk/plugins/VeraControl/DeviceDimmer.cs
trunk/plugins/VeraControl/DeviceDoorlock.cs
trunk/plugins/VeraControl/DeviceGWeather.cs
trunk/plugins/VeraControl/DeviceGeneric.cs
trunk/plugins/VeraControl/DeviceHumidity.cs
trunk/plugins/VeraControl/DeviceLightSensor.cs
trunk/plugins/VeraControl/DevicePowerMeter.cs
trunk/plugins/VeraControl/DeviceSecurity.cs
trunk/plugins/VeraControl/DeviceSprinkler.cs
trunk/plugins/VeraControl/DeviceSwitch.cs
trunk/plugins/VeraControl/DeviceTemperature.cs
trunk/plugins/VeraControl/DeviceThermostat.cs
trunk/plugins/VeraControl/DialogActionTrigger.cs
trunk/plugins/VeraControl/DialogDeviceControl.cs
trunk/plugins/VeraControl/Properties/AssemblyInfo.cs
trunk/plugins/VeraControl/Room.cs
trunk/plugins/VeraControl/Scene.cs
trunk/plugins/VeraControl/Section.cs
trunk/plugins/VeraControl/VeraCommunication.cs
trunk/plugins/VeraControl/VeraControl.cs
trunk/plugins/VeraControl/VeraControl.csproj
trunk/plugins/VeraControl/skin/Default/VeraControl.xml
trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml
trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml
Added Paths:
-----------
trunk/plugins/VeraControl/VeraHelper.cs
trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png
trunk/plugins/VeraControl/skin/Media/Vera/location.png
Modified: trunk/plugins/VeraControl/DevCategories.cs
===================================================================
--- trunk/plugins/VeraControl/DevCategories.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DevCategories.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -20,21 +20,20 @@
{
public DevCategories(XmlNode xn)
{
- if (xn == null) {
- m_sName = "";
- m_iId = 0;
- } else {
+ if (xn != null)
+ {
update(xn);
}
}
- private string m_sName;
- private int m_iId;
+ private string m_sName = "unknown category";
+ private int m_iId = 0;
+ public VeraHelper helper = VeraHelper.Instance;
public bool update(XmlNode xn)
{
- m_sName = xn.Attributes["name"].Value;
- m_iId = int.Parse(xn.Attributes["id"].Value);
+ m_sName = helper.getAttrAsString(xn, "name", m_sName);
+ m_iId = helper.getAttrAsInt (xn, "id", m_iId);
return true;
}
Modified: trunk/plugins/VeraControl/DeviceDimmer.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,8 +18,9 @@
/// </summary>
public class DeviceDimmer : DeviceGeneric
{
- private int m_iLevel;
- private string m_sWatt;
+ private int m_iLevel = 0;
+ private string m_sWatt = "-";
+ private string m_sKwh = "-";
public DeviceDimmer( XmlNode xn ): base (xn)
{
@@ -31,8 +32,9 @@
public override bool update(XmlNode xn)
{
- m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["level"].Value) : 0);
- m_sWatt = (xn.Attributes["watts"] != null ? xn.Attributes["watts"].Value : "0");
+ m_iLevel = helper.getAttrAsInt (xn, "level", m_iLevel);
+ m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt);
+ m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh);
return base.update(xn);
}
@@ -43,7 +45,7 @@
set { }
}
- public override bool state
+ public override bool status
{
get { return (m_iLevel > 0); }
set {
@@ -62,12 +64,14 @@
} else {
if (newValue < 0) { newValue = 0; }
}
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" +
- "&newLoadlevelTarget="+value;
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" +
+ "&newLoadlevelTarget="+value;
+ vera.doVeraRequest(cmd);
+ }
m_iLevel = newValue;
}
}
@@ -100,9 +104,15 @@
return "Dimmable_Light_"+leveltxt;
}
+
+ public override string getExtraText()
+ {
+ return (m_sKwh != "" ? m_sKwh + "kWh" : "");
+ }
+
public override string getStatusText()
{
- return ( state ? level.ToString() + "%" : "Off");
+ return ( status ? level.ToString() + "%" : "Off");
}
}
}
Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,7 +18,7 @@
/// </summary>
public class DeviceDoorlock : DeviceGeneric
{
- private bool m_bStatus;
+ private bool m_bStatus = false;
public DeviceDoorlock( XmlNode xn ): base (xn)
{
@@ -30,21 +30,23 @@
public override bool update(XmlNode xn)
{
- m_bStatus = (xn.Attributes["status"].Value == "1");
+ m_bStatus = helper.getAttrAsBool(xn, "status", m_bStatus);
return base.update(xn);
}
- public override bool state
+ public override bool status
{
get { return m_bStatus; }
set {
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ vera.doVeraRequest(cmd);
+ }
m_bStatus = value;
}
}
@@ -54,7 +56,7 @@
get { return (m_bStatus ? 1 : 0); }
set
{
- state = (value > 0);
+ status = (value > 0);
}
}
@@ -82,7 +84,7 @@
public override string getStatusText()
{
- return (state ? "Locked" : "Unlocked");
+ return (status ? "Locked" : "Unlocked");
}
}
Modified: trunk/plugins/VeraControl/DeviceGWeather.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,8 +18,8 @@
/// </summary>
public class DeviceGWeather : DeviceGeneric
{
- private string m_sCondition;
- private string m_sWindCondition;
+ private string m_sCondition = "-";
+ private string m_sWindCondition = "-";
public DeviceGWeather( XmlNode xn ): base (xn)
{
@@ -31,8 +31,10 @@
public override bool update(XmlNode xn)
{
- m_sCondition = (xn.Attributes["Condition"] != null ? xn.Attributes["Condition"].Value : "-");
- m_sWindCondition = (xn.Attributes["WindCondition"] != null ? xn.Attributes["WindCondition"].Value : "-");
+ m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition); // Google Weather Plugin
+ m_sCondition = helper.getAttrAsString(xn, "condition", m_sCondition); // World Weather plugin
+ m_sWindCondition = helper.getAttrAsString(xn, "WindCondition", m_sWindCondition);
+ m_sWindCondition = helper.getAttrAsString(xn, "windcondition", m_sWindCondition);
return base.update(xn);
}
@@ -50,5 +52,10 @@
{
return m_sWindCondition;
}
+
+ public override string getIconName()
+ {
+ return "location";
+ }
}
}
Modified: trunk/plugins/VeraControl/DeviceGeneric.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -4,8 +4,8 @@
* Date: 22-12-2011
* Time: 13:07
*
- * Copyright: 2012 GPL - Bart Eversdijk
- * MediaPort plugin - MicasaVerde (TM) Vera Controller
+ * Copyright: 2012 GPL - Bart Eversdijk
+ * MediaPort plugin - MicasaVerde (TM) Vera Controller
* E-mail: ba...@ev...
*/
using System;
@@ -14,17 +14,26 @@
namespace VeraControl.Properties
{
+
+
/// <summary>
/// Description of DeviceGeneric.
/// </summary>
public class DeviceGeneric
{
- private string m_sName = "";
+ private string m_sName = "unknown device";
private int m_iId = 0;
private string m_sAltId = "";
private int m_iCategory = 0;
private int m_iRoom = 0;
+ // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3)
+ private DevState m_dsState = DevState.NONE;
+ private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text
+
+ public VeraHelper helper = VeraHelper.Instance;
+ public VeraCommunication vera = VeraCommunication.Instance;
+
public DeviceGeneric(XmlNode xn)
{
if (xn != null)
@@ -35,11 +44,29 @@
public virtual bool update(XmlNode xn)
{
- m_sName = xn.Attributes["name"].Value;
- m_iId = int.Parse(xn.Attributes["id"].Value);
- m_sAltId = xn.Attributes["altid"].Value;
- m_iCategory = int.Parse(xn.Attributes["category"].Value);
- m_iRoom = int.Parse(xn.Attributes["room"].Value);
+ m_sName = helper.getAttrAsString(xn, "name", m_sName);
+ m_iId = helper.getAttrAsInt (xn, "id", m_iId);
+ m_sAltId = helper.getAttrAsString(xn, "altid", m_sAltId);
+ m_iCategory = helper.getAttrAsInt (xn, "category", m_iCategory);
+ m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom);
+
+ m_sComment = helper.getAttrAsString(xn, "comment", m_sComment );
+ m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1));
+
+ if (m_iId == 0)
+ {
+ // void device no further processing needed
+ return true;
+ }
+ // Make sure room exists
+ if (m_iRoom == 0 || !vera.status.isRoomFound(m_iRoom))
+ {
+ if (!vera.status.isRoomFound(0))
+ { // create dummy room to attach to
+ vera.rooms.Add(new Room(null));
+ }
+ m_iRoom = 0;
+ }
return true;
}
@@ -88,9 +115,21 @@
get { return false; }
set { }
}
-
- public virtual bool state
+
+ public virtual DevState commstate
{
+ get { return m_dsState; }
+ set { }
+ }
+
+ public virtual string comment
+ {
+ get { return (commstate != DevState.NONE ? m_sComment : ""); }
+ set { }
+ }
+
+ public virtual bool status
+ {
get { return false; }
set { }
}
Modified: trunk/plugins/VeraControl/DeviceHumidity.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,7 +18,7 @@
/// </summary>
public class DeviceHumidity : DeviceGeneric
{
- private int m_iLevel;
+ private int m_iLevel = 0;
public DeviceHumidity( XmlNode xn ): base (xn)
{
@@ -30,7 +30,7 @@
public override bool update(XmlNode xn)
{
- m_iLevel = int.Parse(xn.Attributes["humidity"].Value);
+ m_iLevel = helper.getAttrAsInt(xn, "humidity", m_iLevel);
return base.update(xn);
}
Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,7 +18,7 @@
/// </summary>
public class DeviceLightSensor : DeviceGeneric
{
- private int m_iLevel;
+ private int m_iLevel = 0;
public DeviceLightSensor( XmlNode xn ): base (xn)
{
@@ -30,11 +30,12 @@
public override bool update(XmlNode xn)
{
- m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["level"].Value) : 0);
+ m_iLevel = helper.getAttrAsInt(xn, "level", m_iLevel);
+ m_iLevel = helper.getAttrAsInt(xn, "light", m_iLevel);
return base.update(xn);
}
- public override bool state
+ public override bool status
{
get { return (m_iLevel > 0); }
set { }
Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs
===================================================================
--- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,7 +18,8 @@
/// </summary>
public class DevicePowerMeter : DeviceGeneric
{
- private int m_iLevel;
+ private int m_iLevel = 0;
+ private string m_sKwh = "";
public DevicePowerMeter( XmlNode xn ): base (xn)
{
@@ -30,7 +31,8 @@
public override bool update(XmlNode xn)
{
- m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["watts"].Value) : 0);
+ m_iLevel = helper.getAttrAsInt (xn, "watts", m_iLevel);
+ m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh);
return base.update(xn);
}
@@ -40,7 +42,7 @@
set { }
}
- public override bool state
+ public override bool status
{
get { return (m_iLevel > 0); }
set { }
@@ -68,6 +70,11 @@
return "Power_Meter";
}
+ public override string getExtraText()
+ {
+ return (m_sKwh != "" ? m_sKwh + "kWh" : "");
+ }
+
public override string getStatusText()
{
return level.ToString() + "W";
Modified: trunk/plugins/VeraControl/DeviceSecurity.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -19,8 +19,8 @@
/// </summary>
public class DeviceSecurity: DeviceGeneric
{
- private bool m_bTripped;
- private bool m_bArmed;
+ private bool m_bTripped = false;
+ private bool m_bArmed = true;
public DeviceSecurity( XmlNode xn ): base (xn)
{
@@ -32,20 +32,23 @@
public override bool update(XmlNode xn)
{
- m_bTripped = (xn.Attributes["tripped"].Value == "1");
- m_bArmed = (xn.Attributes["armed"].Value == "1");
+ m_bTripped = helper.getAttrAsBool(xn, "tripped", m_bTripped);
+ m_bArmed = helper.getAttrAsBool(xn, "armed", m_bArmed);
return base.update(xn);
}
- public override bool state
+ public override bool status
{
get { return m_bArmed; }
- set { VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" +
- "&newArmedValue=" + (value ? "1" : "0");
- string sResult = vera.doVeraRequest(cmd);
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" +
+ "&newArmedValue=" + (value ? "1" : "0");
+ vera.doVeraRequest(cmd);
+ }
m_bArmed = value;
}
}
@@ -59,7 +62,7 @@
public override int level
{
get { return (m_bArmed ? 1 : 0); }
- set { state = (value > 0); }
+ set { status = (value > 0); }
}
public override int maxLevel
@@ -84,7 +87,7 @@
public override string getStatusText()
{
- return (state ? ( tripped ? "TRIPPED" : "standby") : "bypass");
+ return (status ? ( tripped ? "TRIPPED" : "standby") : "bypass");
}
public override string[] getCommands()
Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -19,11 +19,11 @@
/// </summary>
public class DeviceSprinkler : DeviceGeneric
{
- private bool m_bStatus;
- private string m_sMode;
- private string m_sShortMode;
- private string m_sOperationMode;
- private string m_sCondition;
+ private bool m_bStatus = false;
+ private string m_sMode = "-";
+ private string m_sShortMode = "-";
+ private string m_sOperationMode = "-";
+ private string m_sCondition = "-";
public DeviceSprinkler( XmlNode xn ): base (xn)
{
@@ -35,24 +35,26 @@
public override bool update(XmlNode xn)
{
- m_bStatus = (xn.Attributes["status"].Value == "1");
- m_sMode = (xn.Attributes["Mode"] != null ? xn.Attributes["Mode"].Value : "-");
- m_sShortMode = (xn.Attributes["ShortMode"] != null ? xn.Attributes["ShortMode"].Value : "-");
- m_sOperationMode = (xn.Attributes["OperationMode"] != null ? xn.Attributes["OperationMode"].Value : "-");
- m_sCondition = (xn.Attributes["Condition"] != null ? xn.Attributes["Condition"].Value : "-");
+ m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus);
+ m_sMode = helper.getAttrAsString(xn, "Mode", m_sMode);
+ m_sShortMode = helper.getAttrAsString(xn, "ShortMode", m_sShortMode);
+ m_sOperationMode = helper.getAttrAsString(xn, "OperationMode", m_sOperationMode);
+ m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition);
return base.update(xn);
}
- public override bool state
+ public override bool status
{
get { return m_bStatus; }
set {
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ vera.doVeraRequest(cmd);
+ }
m_bStatus = value;
}
}
@@ -60,19 +62,21 @@
public override int level
{
get { return (m_bStatus ? 1 : 0); }
- set { state = (value > 0); }
+ set { status = (value > 0); }
}
public override string mode
{
get { return m_sMode; }
set {
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" +
- (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual"));
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" +
+ (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual"));
+ vera.doVeraRequest(cmd);
+ }
m_sMode = value;
}
}
@@ -108,8 +112,6 @@
{
return m_sCondition;
}
-
-
public override string [] getCommands()
{
Modified: trunk/plugins/VeraControl/DeviceSwitch.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,8 +18,9 @@
/// </summary>
public class DeviceSwitch : DeviceGeneric
{
- private bool m_bStatus;
- private string m_sWatt;
+ private bool m_bStatus = false;
+ private string m_sWatt = "-";
+ private string m_sKwh = "-";
public DeviceSwitch( XmlNode xn ): base (xn)
{
@@ -31,8 +32,10 @@
public override bool update(XmlNode xn)
{
- m_bStatus = (xn.Attributes["status"].Value == "1");
- m_sWatt = (xn.Attributes["watts"] != null ? xn.Attributes["watts"].Value : "0");
+ m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus);
+ m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt);
+ m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh);
+
return base.update(xn);
}
@@ -42,16 +45,18 @@
set { }
}
- public override bool state
+ public override bool status
{
get { return m_bStatus; }
set {
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ vera.doVeraRequest(cmd);
+ }
m_bStatus = value;
}
}
@@ -59,7 +64,7 @@
public override int level
{
get { return (m_bStatus ? 1 : 0); }
- set { state = (value > 0); }
+ set { status = (value > 0); }
}
public override int maxLevel
@@ -84,9 +89,14 @@
return "Binary_Light_" + (m_bStatus ? "100" : "0");
}
+ public override string getExtraText()
+ {
+ return (m_sKwh != "" ? m_sKwh + "kWh" : "");
+ }
+
public override string getStatusText()
{
- return (state ? "On" : "Off");
+ return (status ? "On" : "Off");
}
}
}
Modified: trunk/plugins/VeraControl/DeviceTemperature.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,8 +18,8 @@
/// </summary>
public class DeviceTemperature : DeviceGeneric
{
- public int m_iLevel;
- private bool m_bMetric = true;
+ public string m_sTemp = "0"; // public thermostat class
+ private bool m_bMetric = true;
public DeviceTemperature( XmlNode xn, bool bMetric ): base (xn)
{
@@ -32,13 +32,13 @@
public override bool update(XmlNode xn)
{
- m_iLevel = (xn.Attributes["temperature"] != null ? int.Parse(xn.Attributes["temperature"].Value) : 0);
+ m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp);
return base.update(xn);
}
public override int level
{
- get { return m_iLevel; }
+ get { return int.Parse(m_sTemp); }
set { }
}
@@ -66,7 +66,7 @@
public override string getStatusText()
{
- return level + (m_bMetric ? "°C" : "F");
+ return m_sTemp + (m_bMetric ? "°C" : "°F");
}
}
Modified: trunk/plugins/VeraControl/DeviceThermostat.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -18,10 +18,10 @@
/// </summary>
public class DeviceThermostat : DeviceTemperature
{
- private bool m_bMetric = true;
- private string m_sFan = "";
- private string m_sState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent"
- private string m_sMode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn",
+ private bool m_bMetric = true;
+ private string m_sFanMode = "";
+ private string m_sHvacState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent"
+ private string m_sMode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn",
// "AuxCoolOn", "EconomyCoolOn", "BuildingProtection", "EnergySavingsHeating", "EnergySavingsCooling"
public DeviceThermostat( XmlNode xn, bool bMetric ): base (xn, bMetric)
@@ -35,14 +35,14 @@
public override bool update(XmlNode xn)
{
- m_iLevel = (xn.Attributes["temperature"] != null ? int.Parse(xn.Attributes["temperature"].Value) : 0);
- m_sFan = (xn.Attributes["fan"] != null ? xn.Attributes["fn"].Value : "Off");
- m_sState = (xn.Attributes["hvacstate"] != null ? xn.Attributes["hvacstate"].Value : "Off");
- m_sMode = (xn.Attributes["mode"] != null ? xn.Attributes["mode"].Value : "Off");
+ m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp);
+ m_sFanMode = helper.getAttrAsString(xn, "fanmode", m_sFanMode);
+ m_sHvacState = helper.getAttrAsString(xn, "hvacstate", m_sHvacState);
+ m_sMode = helper.getAttrAsString(xn, "mode", m_sMode);
return base.update(xn);
}
- public override bool state
+ public override bool status
{
get { return (mode != "Off"); }
set { mode = (value ? "Auto" : "Off"); }
@@ -58,13 +58,15 @@
{
get { return m_sMode; }
set {
- VeraCommunication vera = VeraCommunication.Instance;
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" +
- "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver"))
- );
- string sResult = vera.doVeraRequest(cmd);
+ if (id > 0) // Only send when a valid ID is found
+ {
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" +
+ "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver"))
+ );
+ vera.doVeraRequest(cmd);
+ }
m_sMode = value;
}
}
@@ -93,7 +95,7 @@
public override string getExtraText()
{
- return m_sState + " - Fan : " + m_sFan + " - " + m_iLevel + (m_bMetric ? "°C" : "F") ;
+ return m_sHvacState + " - Fan : " + m_sFanMode + " - " + m_sTemp + (m_bMetric ? "°C" : "°F") ;
}
public override string getIconName()
Modified: trunk/plugins/VeraControl/DialogActionTrigger.cs
===================================================================
--- trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -65,6 +65,8 @@
[SkinControlAttribute(52)] protected GUISpinButton spMPExit = null;
+ private VeraCommunication vera = VeraCommunication.Instance;
+
public DialogActionTrigger()
{
GetID = (int)1974;
@@ -89,7 +91,7 @@
// (P)re load spin contor
for (int i = 0; i < spinList.Length; i++)
{
- initSpinButtons(spinList[i], VeraCommunication.Instance.actionTriggerTable[i]);
+ initSpinButtons(spinList[i], vera.actionTriggerTable[i]);
}
lblHeading.Label = strLine;
@@ -97,13 +99,6 @@
public override bool Init()
{
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
- {
- for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++)
- {
- VeraCommunication.Instance.actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0);
- }
- }
return Load(GUIGraphicsContext.Skin + @"\VeraDialogActionTrigger.xml");
}
@@ -128,10 +123,10 @@
int iSceneIndex = 0;
spin.AddSpinLabel("- none -", 0);
- for (int i = 0; i < VeraCommunication.Instance.scenes.Count; i++)
+ for (int i = 0; i < vera.scenes.Count; i++)
{
- spin.AddSpinLabel(shortString(VeraCommunication.Instance.scenes[i].name), VeraCommunication.Instance.scenes[i].id);
- if (VeraCommunication.Instance.scenes[i].id == iSelectedScene)
+ spin.AddSpinLabel(shortString(vera.scenes[i].name), vera.scenes[i].id);
+ if (vera.scenes[i].id == iSelectedScene)
{
iSceneIndex = i + 1; // 0 is - none -
}
@@ -164,11 +159,11 @@
for (int i = 0; i < spinList.Length; i++)
{
if (spinList[i].SpinValue == 0) {
- VeraCommunication.Instance.actionTriggerTable[i] = 0;
+ vera.actionTriggerTable[i] = 0;
} else {
- VeraCommunication.Instance.actionTriggerTable[i] = VeraCommunication.Instance.scenes[spinList[i].SpinValue - 1].id;
+ vera.actionTriggerTable[i] = vera.scenes[spinList[i].SpinValue - 1].id;
}
- xmlwritter.SetValue("veracontroller", ((Actiontrigger) i).ToString(), VeraCommunication.Instance.actionTriggerTable[i].ToString());
+ xmlwritter.SetValue("veracontroller", ((Actiontrigger) i).ToString(), vera.actionTriggerTable[i].ToString());
}
}
}
Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs
===================================================================
--- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -41,7 +41,9 @@
[SkinControl(13)] protected GUIButtonControl btnMode2 = null;
[SkinControl(14)] protected GUIButtonControl btnMode3 = null;
[SkinControl(15)] protected GUISliderControl slider = null;
+ [SkinControl(20)] protected GUIImage camImage = null;
+
DeviceGeneric myDev = null;
public DialogDeviceControl()
@@ -183,6 +185,17 @@
}
}
+ public void SetCamImage(string url)
+ {
+
+ camImage.Dispose();
+ camImage.SetFileName(url);
+ camImage.AllocResources();
+ camImage.KeepAspectRatio = true;
+ camImage.Visibility = System.Windows.Visibility.Visible;
+ imgLogo.Visibility = System.Windows.Visibility.Hidden;
+ }
+
public void SetImage(string filename)
{
imgLogo.Dispose();
Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -16,7 +16,7 @@
[assembly: AssemblyProduct("VeraControl")]
[assembly: AssemblyCopyright("Copyright 2012")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("ba...@ev...")]
+[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
Modified: trunk/plugins/VeraControl/Room.cs
===================================================================
--- trunk/plugins/VeraControl/Room.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/Room.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -20,25 +20,40 @@
{
public Room(XmlNode xn)
{
- if (xn == null)
+ if (xn != null)
{
- m_sName = "";
- m_iId = 0;
- m_iSection = 0;
- } else {
update(xn);
}
}
- private string m_sName;
- private int m_iId;
- private int m_iSection;
+ public VeraHelper helper = VeraHelper.Instance;
+ public VeraCommunication vera = VeraCommunication.Instance;
+ private string m_sName = "unknown room";
+ private int m_iId = 0;
+ private int m_iSection = 0;
+
public bool update(XmlNode xn)
{
- m_sName = xn.Attributes["name"].Value;
- m_iId = int.Parse(xn.Attributes["id"].Value);
- m_iSection = int.Parse(xn.Attributes["section"].Value);
+ m_sName = helper.getAttrAsString(xn, "name", m_sName);
+ m_iId = helper.getAttrAsInt (xn, "id", m_iId);
+ m_iSection = helper.getAttrAsInt (xn, "section", m_iSection);
+
+ if (m_iId == 0)
+ {
+ // void room no further processing needed
+ return true;
+ }
+ // Make sure room exists
+ if (m_iSection == 0 || !vera.status.isSectionFound(m_iSection))
+ {
+ if (!vera.status.isSectionFound(0))
+ { // create dummy room to attach to
+ vera.sections.Add(new Section(null));
+ }
+ m_iSection = 0;
+ }
+
return true;
}
Modified: trunk/plugins/VeraControl/Scene.cs
===================================================================
--- trunk/plugins/VeraControl/Scene.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/Scene.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -10,6 +10,7 @@
*/
using System;
using System.Xml;
+using VeraControl;
namespace VeraControl.Properties
{
@@ -20,28 +21,32 @@
{
public Scene(XmlNode xn)
{
- if (xn == null)
+ if (xn != null)
{
- m_sName = "";
- m_iId = 0;
- m_bActive = false;
- m_iRoom = 0;
- } else {
update(xn);
}
}
+ public VeraHelper helper = VeraHelper.Instance;
- private string m_sName;
- private int m_iId;
- private bool m_bActive;
- private int m_iRoom;
+ private string m_sName = "unknown scene";
+ private int m_iId = 0;
+ private bool m_bActive = false;
+ private int m_iRoom = 0;
+ // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3)
+ private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text
+ private DevState m_dsState = DevState.NONE;
+
public bool update(XmlNode xn)
{
- m_sName = xn.Attributes["name"].Value;
- m_iId = int.Parse(xn.Attributes["id"].Value);
- m_iRoom = int.Parse(xn.Attributes["room"].Value);
- m_bActive = (xn.Attributes["name"].Value == "1");
+ m_sName = helper.getAttrAsString(xn, "name", m_sName);
+ m_iId = helper.getAttrAsInt (xn, "id", m_iId);
+ m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom);
+ m_bActive = helper.getAttrAsBool (xn, "active", m_bActive);
+
+ m_sComment = helper.getAttrAsString(xn, "comment", m_sComment );
+ m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1));
+
return true;
}
@@ -56,7 +61,17 @@
get { return m_sName; }
set { }
}
-
+
+ public virtual DevState commstate
+ {
+ get { return m_dsState; }
+ set { }
+ }
+ public virtual string comment
+ {
+ get { return (commstate != DevState.NONE ? m_sComment : ""); }
+ set { }
+ }
public bool isActive()
{
Modified: trunk/plugins/VeraControl/Section.cs
===================================================================
--- trunk/plugins/VeraControl/Section.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/Section.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -20,22 +20,21 @@
{
public Section(XmlNode xn)
{
- if (xn == null)
+ if (xn != null)
{
- m_sName = "";
- m_iId = 0;
- } else {
update(xn);
}
}
- private string m_sName;
- private int m_iId;
+ public VeraHelper helper = VeraHelper.Instance;
+ private string m_sName = "unknown section";
+ private int m_iId = 0;
+
public bool update(XmlNode xn)
{
- m_sName = xn.Attributes["name"].Value;
- m_iId = int.Parse(xn.Attributes["id"].Value);
+ m_sName = helper.getAttrAsString(xn, "name", m_sName);
+ m_iId = helper.getAttrAsInt (xn, "id", m_iId);
return true;
}
Modified: trunk/plugins/VeraControl/VeraCommunication.cs
===================================================================
--- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -166,17 +166,20 @@
private static volatile VeraCommunication instance;
private static object syncRoot = new Object();
- private string m_sVeraIPAddress;
- private string m_sVeraTCPIPPort;
- private string m_sDataVersion = "";
- private bool m_bMetric = true;
+ private string m_sVeraIPAddress;
+ private string m_sVeraTCPIPPort;
+ private string m_sDataVersion = "";
+ private bool m_bMetric = true;
+ private DevState m_dsVeraState = DevState.NONE;
+ private string m_sComment = "";
private VeraStatus m_status = new VeraStatus();
private long m_lLastUpdate = 0;
private bool m_bUpdatePending = false;
public int[] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER];
-
+ private VeraHelper helper = VeraHelper.Instance;
+
public static VeraCommunication Instance
{
get
@@ -202,12 +205,16 @@
{
m_sVeraIPAddress = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1");
m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "49451");
+ m_sVeraIPAddress = "192.10.1.240";
+ // m_sVeraIPAddress = "demo.mios.com";
+ m_sVeraTCPIPPort = "3480";
+
+ // Fill action table (config settings)
+ for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++)
+ {
+ actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0);
+ }
}
- // Clear action table (TO DO: load with config settings)
- for (int i = 0; i < (int)Actiontrigger.LAST_ACTIONTRIGGER; i++)
- {
- actionTriggerTable[i] = 0;
- }
}
public bool updateCurrentStatus()
@@ -218,16 +225,18 @@
}
m_bUpdatePending = true;
string verastatus = doVeraRequest("?id=lu_sdata&output_format=xml");
- m_lLastUpdate = getSecondSince1970();
+ m_lLastUpdate = getSecondsSince1970();
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(verastatus);
// Parse header
- XmlNode rootnode = xmlDoc.SelectSingleNode("/root");
- m_bMetric = (rootnode.Attributes["temperature"].Value == "C");
- bool bFullRefresh = (m_sDataVersion != rootnode.Attributes["dataversion"].Value);
- m_sDataVersion = rootnode.Attributes["dataversion"].Value;
+ XmlNode rootnode = xmlDoc.SelectSingleNode("/root");
+ m_bMetric = (helper.getAttrAsString(rootnode, "temperature", "C") == "C");
+ bool bFullRefresh = helper.getAttrAsBool (rootnode, "full", true);
+ m_sDataVersion = helper.getAttrAsString (rootnode, "dataversion", "0");
+ m_sComment = helper.getAttrAsString (rootnode, "comment", "");
+ m_dsVeraState = helper.toDevState(helper.getAttrAsInt(rootnode, "state", -1));
if (bFullRefresh)
{
@@ -247,6 +256,18 @@
}
}
+ // Process Rooms
+ xnList = xmlDoc.SelectNodes("/root/rooms/room");
+ foreach (XmlNode xn in xnList)
+ {
+ Room room = m_status.getRoomById( int.Parse(xn.Attributes["id"].Value) );
+ if (room.id != 0) {
+ room.update(xn);
+ } else {
+ m_status.rooms.Add(new Room(xn));
+ }
+ }
+
// Process Scenes
xnList = xmlDoc.SelectNodes("/root/scenes/scene");
foreach (XmlNode xn in xnList)
@@ -259,17 +280,6 @@
}
}
- // Process Rooms
- xnList = xmlDoc.SelectNodes("/root/rooms/room");
- foreach (XmlNode xn in xnList)
- {
- Room room = m_status.getRoomById( int.Parse(xn.Attributes["id"].Value) );
- if (room.id != 0) {
- room.update(xn);
- } else {
- m_status.rooms.Add(new Room(xn));
- }
- }
// Process Categories
xnList = xmlDoc.SelectNodes("/root/categories/categorie");
@@ -293,6 +303,10 @@
} else {
switch (xn.Attributes["category"].Value)
{
+ //case "1":
+ // m_status.devices.Add(new DeviceInterface(xn));
+ // break;
+
case "2":
m_status.devices.Add(new DeviceDimmer(xn));
break;
@@ -311,9 +325,9 @@
m_status.devices.Add(new DeviceThermostat(xn, m_bMetric));
break;
- // case "6": // TODO: Implement camera class ?
- // m_status.devices.Add(new DeviceCamera(xn, m_bMetric));
- // break;
+ case "6":
+ m_status.devices.Add(new DeviceCam(xn));
+ break;
case "7":
m_status.devices.Add(new DeviceDoorlock(xn));
@@ -323,9 +337,9 @@
m_status.devices.Add(new DeviceWindowCovering(xn));
break;
- // case "14": // TODO: Implement Scene controller device ?
- // m_status.devices.Add(new DeviceSceneController(xn));
- // break;
+ case "14":
+ m_status.devices.Add(new DeviceSceneController(xn));
+ break;
// case "15": // TODO: Implement AV device ?
// m_status.devices.Add(new DeviceSensor(xn));
@@ -350,7 +364,7 @@
case "0":
default:
// Check for Google Weather Device
- if (xn.Attributes["WindCondition"] != null)
+ if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null)
{
m_status.devices.Add(new DeviceGWeather(xn));
break;
@@ -368,7 +382,7 @@
}
}
// update timer again (took some time to get the data)
- m_lLastUpdate = getSecondSince1970();
+ m_lLastUpdate = getSecondsSince1970();
m_bUpdatePending = false;
return bFullRefresh;
}
@@ -385,7 +399,8 @@
public string doVeraRequest( string param )
{
- return retrieveURL("http://" + m_sVeraIPAddress + ":" + m_sVeraTCPIPPort + "/data_request" + param + "&time="+DateTime.Now.Ticks);
+
+ return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks);
}
private string retrieveURL( string url )
@@ -410,14 +425,14 @@
return response;
}
- private long getSecondSince1970()
+ private long getSecondsSince1970()
{
return (DateTime.Now.Ticks / 10000000);
}
public long secondsSinceLastUpdate
{
- get { return (getSecondSince1970() - m_lLastUpdate); }
+ get { return (getSecondsSince1970() - m_lLastUpdate); }
set { }
}
Modified: trunk/plugins/VeraControl/VeraControl.cs
===================================================================
--- trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -1,6 +1,6 @@
/*
* Created by SharpDevelop.
- * User: Bart Everrsdijk
+ * User: Bart
* Date: 21-12-2011
* Time: 21:20
*
@@ -444,9 +444,9 @@
//Store last action - never send the same action twice...
iLastAction = action;
- if ((VeraCommunication.Instance.actionTriggerTable[(int)action] > 0) && (VeraCommunication.Instance.actionTriggerTable[(int)action] < Int16.MaxValue))
+ if ((vera.actionTriggerTable[(int)action] > 0) && (vera.actionTriggerTable[(int)action] < Int16.MaxValue))
{
- Scene scene = vera.status.getSceneById(VeraCommunication.Instance.actionTriggerTable[(int)action]);
+ Scene scene = vera.status.getSceneById(vera.actionTriggerTable[(int)action]);
if (scene.id > 0)
{
scene.run();
@@ -683,25 +683,30 @@
if (dev.GetType() == typeof(DeviceSprinkler))
{
dlg.SetText(dev.name, dev.getStatusText() + " - " + dev.mode, dev.getExtraText() );
- dlg.SetActiveBut((dev.state ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "Block" ? 2 : 1) ));
+ dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "Block" ? 2 : 1) ));
}
else if (dev.GetType() == typeof(DeviceThermostat))
{
dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText() );
- dlg.SetActiveBut((dev.state ? 1 : 0), (dev.mode == "Auto" ? 0 :
+ dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 :
(dev.mode == "CoolOn" || dev.mode == "Cool" ? 1 :
(dev.mode == "HeatOn" || dev.mode == "Heat" ? 2 : 3) )));
- }
+ }
else
{
dlg.SetText(dev.name, "", "");
- dlg.SetActiveBut(dev.state ? 1 : 0, -1);
+ dlg.SetActiveBut(dev.status ? 1 : 0, -1);
}
dlg.SetButtons(dev.getCommands());
dlg.SetSlider(dev.level, dev.maxLevel);
}
else
{
+ if (dev.GetType() == typeof(DeviceCam))
+ {
+ DeviceCam cam = (DeviceCam) dev;
+ dlg.SetCamImage(cam.imgUrl);
+ }
dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText());
}
dlg.DoModal(GUIWindowManager.ActiveWindow);
Modified: trunk/plugins/VeraControl/VeraControl.csproj
===================================================================
--- trunk/plugins/VeraControl/VeraControl.csproj 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/VeraControl.csproj 2012-01-08 19:33:34 UTC (rev 4394)
@@ -84,6 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DevCategories.cs" />
+ <Compile Include="DeviceCam.cs" />
<Compile Include="DeviceDimmer.cs" />
<Compile Include="DeviceDoorlock.cs" />
<Compile Include="DeviceGeneric.cs" />
@@ -91,6 +92,7 @@
<Compile Include="DeviceHumidity.cs" />
<Compile Include="DeviceLightSensor.cs" />
<Compile Include="DevicePowerMeter.cs" />
+ <Compile Include="DeviceSceneController.cs" />
<Compile Include="DeviceSecurity.cs" />
<Compile Include="DeviceSprinkler.cs" />
<Compile Include="DeviceSwitch.cs" />
@@ -105,6 +107,7 @@
<Compile Include="Scene.cs" />
<Compile Include="Section.cs" />
<Compile Include="VeraCommunication.cs" />
+ <Compile Include="VeraHelper.cs" />
<Compile Include="VeraSetupForm.cs" />
<Compile Include="VeraSetupForm.Designer.cs">
<DependentUpon>VeraSetupForm.cs</DependentUpon>
Added: trunk/plugins/VeraControl/VeraHelper.cs
===================================================================
--- trunk/plugins/VeraControl/VeraHelper.cs (rev 0)
+++ trunk/plugins/VeraControl/VeraHelper.cs 2012-01-08 19:33:34 UTC (rev 4394)
@@ -0,0 +1,104 @@
+/*
+ * Created by SharpDevelop.
+ * User: Bart
+ * Date: 7-1-2012
+ * Time: 12:07
+ *
+ * Copyright: 2012 GPL - Bart Eversdijk
+ * MediaPort plugin - MicasaVerde (TM) Vera Controller
+ * E-mail: ba...@ev...
+ */
+using System;
+using System.Xml;
+
+namespace VeraControl.Properties
+{
+
+ public enum DevState
+ {
+ NONE = 0,
+ PENDING,
+ SUCCESS,
+ ERROR
+ }
+
+ /// <summary>
+ /// Description of VeraHelper.
+ /// </summary>
+ public class VeraHelper
+ {
+ public VeraHelper()
+ {
+ }
+
+ private static volatile VeraHelper instance;
+ private static object syncRoot = new Object();
+
+ public static VeraHelper Instance
+ {
+ get
+ {
+ if (instance == null)
+ {
+ lock (syncRoot)
+ {
+ if (instance == null)
+ {
+ instance = new VeraHelper();
+ }
+ }
+ }
+
+ return instance;
+ }
+ }
+
+ public DevState toDevState (int iRawState)
+ { // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3)
+ switch (iRawState)
+ {
+ case -1:
+ return DevState.NONE;
+ case 0:
+ case 1:
+ case 5:
+ case 6:
+ return DevState.PENDING;
+ case 4:
+ return DevState.SUCCESS;
+ case 2:
+ case 3:
+ default:
+ return DevState.ERROR;
+ }
+ }
+
+ public int getAttrAsInt(XmlNode xn, string key, int iDefault)
+ {
+ if (xn == null || xn.Attributes[key] == null)
+ {
+ return iDefault;
+ }
+ return int.Parse(xn.Attributes[key].Value);
+ }
+
+ public bool getAttrAsBool(XmlNode xn, string key, bool bDefault)
+ {
+ if (xn == null || xn.Attributes[key] == null)
+ {
+ return bDefault;
+ }
+ string value = xn.Attributes[key].Value.ToLower();
+ return (value == "true" || value == "1" || value == "yes");
+ }
+
+ public string getAttrAsString(XmlNode xn, string key, string sDefault)
+ {
+ if (xn == null || xn.Attributes[key] == null)
+ {
+ return sDefault;
+ }
+ return xn.Attributes[key].Value;
+ }
+ }
+}
Modified: trunk/plugins/VeraControl/skin/Default/VeraControl.xml
===================================================================
--- trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-01-08 19:33:34 UTC (rev 4394)
@@ -104,7 +104,7 @@
<id>40</id>
<posX>30</posX>
<posY>85</posY>
- <height>200</height>
+ <height>300</height>
<width>250</width>
<onup>20</onup>
<ondown>70</ondown>
@@ -147,7 +147,7 @@
<id>50</id>
<posX>300</posX>
<posY>55</posY>
- <height>400</height>
+ <height>460</height>
<width>300</width>
<onleft>40</onleft>
<onright>60</onright>
Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml
===================================================================
--- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-08 19:33:34 UTC (rev 4394)
@@ -64,7 +64,7 @@
<type>label</type>
<id>6</id>
<posX>180</posX>
- <posY>150</posY>
+ <posY>130</posY>
<label>Dit is een label!!!</label>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
@@ -215,6 +215,17 @@
<animation effect="fade" time="250">visiblechange</animation>
<animation effect="fade" time="250">windowopen</animation>
</control>
-
+
+ <control>
+ <type>image</type>
+ <id>20</id>
+ <posX>240</posX>
+ <posY>160</posY>
+ <width>600</width>
+ <height>240</height>
+ <texture></texture>
+ <visible>no</visible>
+ </control>
+
</controls>
</window>
Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml
===================================================================
--- trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-08 19:32:04 UTC (rev 4393)
+++ trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-08 19:33:34 UTC (rev 4394)
@@ -216,6 +216,17 @@
<animation effect="fade" time="250">visiblechange</animation>
<animation effect="fade" time="250">windowopen</animation>
</control>
-
+
+ <control>
+ <type>image</type>
+ <id>20</id>
+ <posX>450</posX>
+ <posY>200</posY>
+ <width>600</width>
+ <height>300</height>
+ <texture></texture>
+ <visible>no</visible>
+ </control>
+
</controls>
</window>
Added: trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png
===================================================================
(Binary files differ)
Property changes on: trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/plugins/VeraControl/skin/Media/Vera/location.png
===================================================================
(Binary files differ)
Property changes on: trunk/plugins/VeraControl/skin/Media/Vera/location.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|