Premise Show Temperature reading in Premise Browser.

Motorola Premise

123

Senior Member
Temperature Sensors and Appliances fail to prominently display their status. You have to click a TemperatureSensor icon to view its temperature reading. How much more convenient it'd be if the reading was displayed under the icon.

Here's how to fix it:

  1. In Premise Builder, click Modules in the Shortcut Bar.
  2. Navigate to: Modules > Plugins > Selectors > ClimateControl > TemperatureSensor
  3. Right-click TemperatureSensor and select: New > StatusScript
  4. Call the script: ShowStatus
  5. In the Properties window, find TargetProperty and click its Browse button ("...").
  6. In the Select Property dialog box, select: Schema > Device > TemperatureSensor > Temperature
  7. Click in the Editor pane, copy and paste the following script code and then press F12 to commit the modifications to the Premise Server.

Code:
dim oTempScale, sTemp, sTag, sHTML

set objectGrid = sys.GetObject("sys://Schema/Modules/Plugins/Components/RoomList")

' Determine the default temperature scale for this web session
set oTempScale = Sysevent.Clientsession.Temperature
with this.CurrentObject.Temperature
	select case oTempScale.StandardName
		case "F": sTemp = round(.Fahrenheit, 1)
		case "C": sTemp = round(.Celsius, 1)
		case "K": sTemp = round(.Kelvin, 1)
		case "R": sTemp = round(.Rankine, 1)
	end select
end with

' Format the temperature reading
if sTemp > -250 then
	sTemp = sTemp & chr(176) & oTempScale.StandardName
else ' Probably an uninitialized value
	sTemp = "None"
end if
set oTempScale = nothing

' Display the temperature reading
sTag = "DIV" ' For Grid view
if sysevent.ClientSession.DisplayMode = 1 then sTag = "SPAN" ' For List view
sHTML = "&nbsp;&nbsp;<" & sTag & " style=""color:" & GetHTMLColor(objectGrid.OnStateColor)
sHTML = sHTML & ";background-color:" & GetHTMLColor(objectGrid.OnStateBackgroundColor)
this.Output = sHTML & ";"">" & sTemp & "</" & sTag & ">"


Temperature readings will now be displayed below the sensor's icon (see the attached image).
 

Attachments

  • TempSensor.png
    TempSensor.png
    7.1 KB · Views: 11
Yes, looks good...I'm on the road and cant log into my own server, but a couple of questions a) can you hide the icon :D can you show the temp status on the top level (like a room/zone status)?

But nice job and thanks for the code....
 
... can you hide the icon
... can you show the temp status on the top level (like a room/zone status)?
1) Hide the icon
Copy the attached file, "OnePixel.gif", to c:\Program\Files\Premise\SYS\web\Images\ClassImages. This image contains a single transparent pixel. Any object that uses it will effectively have a blank icon.

To hide all TemperatureSensor icons:
In the ClassImages folder, rename TemperatureSensor.gif to something else like OLD_TemperatureSensor.gif
Rename OnePixel.gif to TemperatureSensor.gif

To hide specific TemperatureSensor icons:
In the object's list of Properties, find the "Image" property in the TagEx section. Set it to point to OnePixel.gif in the ClassImages folder.

2) Show temperature in a Room
This solution relies on the fact that Location objects (like Rooms) have aggregated properties. The Room object has an aggregated Temperature property (i.e. the average of all temperature sensors found in the Room and its sub-Rooms). The following code is very similar to the one I posted for Temperature Sensors.

  1. In Premise Builder, click Modules in the Shortcut Bar.
  2. Navigate to: Modules > Plugins > Selectors > Locations > Room
  3. Right-click Room and select: New > StatusScript
  4. Call the script: ShowStatus
  5. In the Properties window, find TargetProperty and click its Browse button ("...").
  6. In the Select Property dialog box, select: Schema > Device > TemperatureSensor > Temperature
  7. Click in the Editor pane, copy and paste the following script code and then press F12 to commit the modifications to the Premise Server.
Code:
dim oTempScale, sTemp, sHTML

set objectGrid = sys.GetObject("sys://Schema/Modules/Plugins/Components/RoomList")

' Determine the default temperature scale for this web session
set oTempScale = Sysevent.Clientsession.Temperature

' Get the aggregated temperature
sTemp = this.CurrentObject.GetAggregatedPropertyValue("Temperature", Schema.Device.TemperatureSensor.Path)

select case oTempScale.StandardName
	case "F": sTemp = round(sTemp/(5/9) - 459.67, 1)
	case "C": sTemp = round(sTemp - 273.15, 1)
	case "K": sTemp = round(sTemp, 1)
	case "R": sTemp = round(sTemp/(5/9), 1)
end select

' Format the temperature reading
if sTemp > -250 then ' Display the temperature reading
	sTag = "DIV" ' For Grid view
	if sysevent.ClientSession.DisplayMode = 1 then sTag = "SPAN" ' For List view
	sHTML = "&nbsp;&nbsp;<" & sTag & " style=""color:" & GetHTMLColor(objectGrid.OnStateColor)
	sHTML = sHTML & ";background-color:" & GetHTMLColor(objectGrid.OnStateBackgroundColor)
	this.Output = sHTML & ";"">" & sTemp & chr(176) & oTempScale.StandardName & "</" & sTag & ">"
else ' Probably an uninitialized value
	this.Output = ""
end if
set oTempScale = nothing

The primary differences are:
  • This ShowStatus script applies to any Room object (Living, Dining, Family, etc). If you were to put it directly under Locations it would apply to any area; but this can lead to misleading values because aggregation shows an average of all temperature sensors (interior and exterior units).
  • GetAggregatedPropertyValue returns a numeric value and not a Temperature property (with Methods to convert between temperature scales). That's why I had to put in formulas to perform the conversions.
  • I moved the HTML code so that there's no HTML generated (at all) if the temperature value is uninitialized. The first posted example could benefit from this change as well. Why tax the browser with useless HTML codes when there's nothing to display?

Variations of these examples could be used to display the values of other objects like HumiditySensor, WindSpeedSensor, WindowSensor, etc.
 

Attachments

  • OnePixel.zip
    164 bytes · Views: 18
... can you hide the icon
... can you show the temp status on the top level (like a room/zone status)?
1) Hide the icon
Copy the attached file, "OnePixel.gif", to c:\Program\Files\Premise\SYS\web\Images\ClassImages. This image contains a single transparent pixel. Any object that uses it will effectively have a blank icon.

To hide all TemperatureSensor icons:
In the ClassImages folder, rename TemperatureSensor.gif to something else like OLD_TemperatureSensor.gif
Rename OnePixel.gif to TemperatureSensor.gif

To hide specific TemperatureSensor icons:
In the object's list of Properties, find the "Image" property in the TagEx section. Set it to point to OnePixel.gif in the ClassImages folder.

2) Show temperature in a Room
This solution relies on the fact that Location objects (like Rooms) have aggregated properties. The Room object has an aggregated Temperature property (i.e. the average of all temperature sensors found in the Room and its sub-Rooms). The following code is very similar to the one I posted for Temperature Sensors.

  1. In Premise Builder, click Modules in the Shortcut Bar.
  2. Navigate to: Modules > Plugins > Selectors > Locations > Room
  3. Right-click Room and select: New > StatusScript
  4. Call the script: ShowStatus
  5. In the Properties window, find TargetProperty and click its Browse button ("...").
  6. In the Select Property dialog box, select: Schema > Device > TemperatureSensor > Temperature
  7. Click in the Editor pane, copy and paste the following script code and then press F12 to commit the modifications to the Premise Server.
Code:
dim oTempScale, sTemp, sHTML

set objectGrid = sys.GetObject("sys://Schema/Modules/Plugins/Components/RoomList")

' Determine the default temperature scale for this web session
set oTempScale = Sysevent.Clientsession.Temperature

' Get the aggregated temperature
sTemp = this.CurrentObject.GetAggregatedPropertyValue("Temperature", Schema.Device.TemperatureSensor.Path)

select case oTempScale.StandardName
	case "F": sTemp = round(sTemp/(5/9) - 459.67, 1)
	case "C": sTemp = round(sTemp - 273.15, 1)
	case "K": sTemp = round(sTemp, 1)
	case "R": sTemp = round(sTemp/(5/9), 1)
end select

' Format the temperature reading
if sTemp > -250 then ' Display the temperature reading
	sTag = "DIV" ' For Grid view
	if sysevent.ClientSession.DisplayMode = 1 then sTag = "SPAN" ' For List view
	sHTML = "&nbsp;&nbsp;<" & sTag & " style=""color:" & GetHTMLColor(objectGrid.OnStateColor)
	sHTML = sHTML & ";background-color:" & GetHTMLColor(objectGrid.OnStateBackgroundColor)
	this.Output = sHTML & ";"">" & sTemp & chr(176) & oTempScale.StandardName & "</" & sTag & ">"
else ' Probably an uninitialized value
	this.Output = ""
end if
set oTempScale = nothing

The primary differences are:
  • This ShowStatus script applies to any Room object (Living, Dining, Family, etc). If you were to put it directly under Locations it would apply to any area; but this can lead to misleading values because aggregation shows an average of all temperature sensors (interior and exterior units).
  • GetAggregatedPropertyValue returns a numeric value and not a Temperature property (with Methods to convert between temperature scales). That's why I had to put in formulas to perform the conversions.
  • I moved the HTML code so that there's no HTML generated (at all) if the temperature value is uninitialized. The first posted example could benefit from this change as well. Why tax the browser with useless HTML codes when there's nothing to display?

Variations of these examples could be used to display the values of other objects like HumiditySensor, WindSpeedSensor, WindowSensor, etc.

Sweet...can hardly wait to give it a try...I think I forgot to open the builder port on my router and i still have a few more days away from home...:D
 
I'm using Rob Brun's Virtual Weather Station, which uses a data dump from Ambient Weatherstation SW. (My station is a Weatherhawk).
So I slightly modified Rob's code to pull in your excellent Status Script. (I just added a temperature selector (WSTemperature - TargetClass = WS Temp Sensor) to the WSWeather Selector Folder, added your script, set the TargetProperty to Temperature), etc for the other sensors.....

Works well and adds greatly to the UIsefulness ('UI' intentional)!
 
Back
Top