PowerShell

All, this is my small contribution using PowerShell to get an inventory of your system:

Base code:
$vera = wget “http://192.168.81.1:3480/data_request?id=user_data2&output_format=xml
$xmlvera = [xml]$vera.Content

(you could create $devices here that is equal to $xmlvera.root.devices.ChildNodes to shorten/replace typing, I didn’t to allow some basic raw examples)

What you can do with these objects (type in the whole line and press enter):
$xmlvera.root.devices.ChildNodes.Count

$cooper = $xmlvera.root.devices.ChildNodes | Where {$_.manufacturer -Match “Cooper”}
$cooper.Count

$dimcooper = $cooper | Where {$.device_type -Match “DimmableLight”}
$swcooper = $cooper | Where {$
.device_type -Match “BinaryLight”}
$alldim = $xmlvera.root.devices.ChildNodes | Where {$.device_type -Match “DimmableLight”}
$allsw_and_relay = $xmlvera.root.devices.ChildNodes | Where {$
.device_type -Match “BinaryLight”}

$dimcooper.count
$swcooper.count
$alldim.count
$allsw_and_relay.count

Count by manufacturer field example:

$xmlvera.root.devices.ChildNodes | Group-Object manufacturer

Okay, I have these in variables, how do I get this data to excel (use $[VARIABLE] | Export-Csv -NoTypeInformation [PATH AND FILE NAME].csv)?

$xmlvera.root.devices.ChildNodes | Export-Csv -NoTypeInformation .\alldevices.csv
$cooper | Export-Csv -NoTypeInformation .\cooperdevices.csv

I believe this works for both UI5 and 7, 7 I know works for sure.

You can use PowerShell to change state as well. If you don’t know PowerShell, that’s okay, if you have Windows you have it and with an IP change above these commands should work as is (if you have Cooper, otherwise you can use the name of your devices in place of the word cooper or you can even filter on different field). If you have Linux you can use mono.

Enjoy

[quote=“wholm, post:1, topic:185951”]Base code:
$vera = wget “http://192.168.81.1:3480/data_request?id=user_data2&output_format=xml”[/quote]

Update:

This works in PowerShell for Linux (GitHub - PowerShell/PowerShell: PowerShell for every system!) as well as other platforms listed there.

Please note that you need to change wget to Invoke-WebRequest:

$vera = Invoke.WebRequest “http://192.168.81.1:3480/data_request?id=user_data2&output_format=xml

The reason for this is in Windows, wget and curl are simply aliases. In Linux and MacOSX (because they are OpenBSD based) have these commands and will perform much more different than PowerShell. PS is superior in many ways but for expectations, I am guess they removed the aliases.

The remaining commands work as is and haven’t changed in over 2.5+ years.

Good Job! It never dawned on me to look into PS for anything Vera related. Going to give your inventory script a try as I think that will help me in my upcoming migration from Vera 3 to and Edge and a Plus.

I have verified that these still work with Vera as of this date and also works in PowerShell Core, which means it will work in other OS’s other than Windows as well (Linux and MacOS with PowerShell Core installed from GitHub - PowerShell/PowerShell: PowerShell for every system!).

Also I just noticed a ton of typos, not sure what happened in the pasting in the past, but here is the full set of examples:

$vera = Invoke-WebRequest "http://192.168.81.1:3480/data_request?id=user_data2&output_format=xml"
$xmlvera = [xml]$vera.Content

$cooper = $xmlvera.root.devices.ChildNodes | Where {$_.manufacturer -Match "Cooper"}
$cooper.Count

$dimcooper = $cooper | Where {$_.device_type -Match "DimmableLight"}
$swcooper = $cooper | Where {$_.device_type -Match "BinaryLight"}
$alldim = $xmlvera.root.devices.ChildNodes | Where {$_.device_type -Match "DimmableLight"}
$allsw_and_relay = $xmlvera.root.devices.ChildNodes | Where {$_.device_type -Match "BinaryLight"}

$dimcooper.count
$swcooper.count
$alldim.count
$allsw_and_relay.count