Guide to using PowerShell with your Room Alert 3E

An exploration of how to retrieve sensor data from your Room Alert 3E using Windows PowerShell. Whilst the examples here use the Room Alert 3E as the target, very similar techniques would work with all of the other Room Alert monitors as well.

Introduction to PowerShell

PowerShell (including Windows PowerShell and PowerShell Core) is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework and .NET Core.

PowerShell was chosen because it is available on all modern Microsoft Windows installations and has a built-in mechanism for interacting with web based APIs thereby avoiding the need to install any new software to your system.

Accessing Room Alert Data

You can read the data from your Room Alert with the following Powershell command:

$result = Invoke-RestMethod -URI 'http://10.0.0.1/getData.json'

Invoke-RestMethod is quite a useful Powershell cmdlet because it does a lot of the heavy lifting for you. $result will now contain a .NET object containing a number of properties taken from the JSON data retrieved from the Room Alert. You can access the data as you would a regular object property.

Room Alert Data

Property Description Example Data
name Name of the Room Alert. Defaults to the serial number. RA3E-129912
date Date / time as set on the Room Alert 07/19/17 09:50:58
uptime How long the Room Alert has been running 1d 18:36:45
scale Temperature scale. 1 for Fahrenheit, 0 for Celsius 1
macaddr MAC address of the Room Alert 00:80:A3:93:EC:C8
serial Serial number of the Room Alert RA3E-129912
refresh Interval in seconds between refreshes of the web interface 60
gtmd_interval Number of seconds between sending data to GoToMyDevices.com 3600
version Firmware version number v2.0.0
port Port for the Room Alert web interface 80
ip IP address of the Room Alert 10.0.0.152
gtmd_disabled Status of the GoToMyDevices.com synchronisation. 0 for enabled, 1 for disabled 0
time_config Time zone and daylight saving information @{timezone=0; format=0; display=0; daylight_saving_en=0}
sensor Collection of digital sensor data {@{label=Internal Sensor; tempf=75.30; tempc=24.06; highf=76.87; highc=24.93; lowf=72.37; lowc=22.43; alarm=4; type=16; enabled=1}, @{label=Ext Sensor 1; tempf=75.65; tempc=24.25; highf=77.32; highc=25.18; lowf=74.40; lowc=23.56; alarm=0; type=16; enabled=1}}
switch_sen Collection of switch sensor data {@{label=Switch Sen 1; enabled=1; alarm=1; status=0}}

Sensor Data

Now you've read all of the data from your Room Alert, how do you access the sensor data?

Each Room Alert 3E has one built-in temperature sensor in addition there is one digital sensor port and one switch sensor port. Sensors do not have to be connected to either the digital or switch ports.

The data for each sensor type is stored separately. The digital sensor data is stored in the sensor collection and the switch sensor data is stored inside switch_sen.

First we'll tackle how to access the digital sensor data.

# Find all enabled sensors
$result.sensor |where{$_.enabled -eq 1}

The code above finds all of the enabled sensors and prints them out to the console.

# Find all enabled temperature sensors and print out the current temperature, high and low all in Celcius
$result.sensor |where{$_.enabled -eq 1 -and $_.type -eq 16}|select-object -Property label,tempc,highc,lowc

# Prints out the following to the console:

# label           tempc highc lowc
# -----           ----- ----- ----
# Internal Sensor 24.81 24.93 22.43
# Ext Sensor 1    25.06 25.18 23.56

The code above prints out the sensor name (label), the current temperature in Celsius as well as the high and low values for the last 24 hours for all enabled temperature sensors. A temperature sensor has type 16.

What Now?

If you need any further information about the web interface for any of the Room Alert monitors, please get in touch.

Categories: Guides AVTECH Software