skip to Main Content

Monitor & Visualize Your SmartThings Smart Home with Splunk

Over the past few years, the smart home has gone through quite a convergence. Modern protocols like Z-Wave & ZigBee, along with mart hubs, and smart assistants like Amazon Alexa, Google Home & Apple Siri are finally bringing everything together to make the smart home a practical and reliable reality.

What had been still missing from the picture for me, is the ability to log, analyze, and visualize all the data that my smart home generated. I use Splunk (data capture and visualization tool) at work so I decided to give it a try at home and it’s worked out great.

Here’s a Splunk dashboard I created for my home, showing current and historical data from multiple data sources: energy meter, contact sensors, switches, weather data feed, Windows event logs, and some custom PowerShell scripts.

My SmartThings-based smart home setup:

  • Samsung SmartThings Hub 2nd Gen
  • Amazon Echo Devices
  • Various ZigBee/Z-Wave devices
    • Samsung SmartThings GP-U999SJVLAAA Door & Window Multipurpose Sensors
    • Samsung SmartThings GP-U999SJVLBAA Motion Sensors
    • Samsung F-OUT-US-2 SmartThings Outlets
    • Other ZigBee/Z-Wave switches, dimmers, and plugs
    • Samsung ST-CEN-MOIS-1/FTR-US-2 Water Leak Sensors
    • Aeotec HEM G2 whole house energy monitor
    • First Alert ZCOMBO 2-in-1 Smoke Detector & Carbon Monoxide Alarm, Z-Wave
  • PowerShell scripts to pull data from openweathermap.org & run/log periodic Internet speed tests.
  • Splunk Free

Installing Splunk Free Edition

Download and install Splunk. You will start with the Enterprise version which comes with a 60-Day Trial. After that you can switch to the Free edition. Splunk Free allows indexing up to 500 MB of data per day which has been sufficient for my home logging needs. For my setup I installed Splunk on a 14-year old Windows box with a Intel Core2 Quad CPU Q6600 @2.40GHz – Splunk indexing/query performance has been pretty acceptable.

If your install was successful, you should be able to log into Splunk web by navigating to http://localhost:8000 (or replace localhost with your Splunk server hostname).

If you want to monitor other computers, install Splunk Universal Forwarder on each of those computers. I’ll go through how to configure the Universal Forwarders in a future post.

Read More

.NET Transactional File Manager Migrated to GitHub

I have migrated the .NET Transactional File Manager project to GitHub from CodePlex. I originally wrote about it in this blog post.

The library allows you do enlist file I/O operations in transactions using System.Transactions. For example you can wrap a SQL Server insert and creation of a new file on disk in the same transaction, and commit or rollback the two operations together as a unit.

Example code:

// Wrap a file copy and a database insert in the same transaction
TxFileManager fileMgr = new TxFileManager();
using (TransactionScope scope1 = new TransactionScope())
{
    // Copy a file
    fileMgr.CopyFile(srcFileName, destFileName);

    // Insert a database record
    dbMgr.ExecuteNonQuery(insertSql);

    scope1.Complete();
}

This library is available as a NuGet package.

dotnet add package TxFileManager

Version 1.4 is now available with the following changes/fixes:

  • Convert to xUnit tests
  • Add support for custom temp paths to address issues with file/dir operations accross filesystems
  • Fix for resource leak in TxFileManager._txEnlistment
  • Target .NET Standard 2.0
  • Additional testing for .NET Core on Ubuntu
  • Additional stress testing both on Windows and Ubuntu
  • Created Github workflow to automatically build/test on ubuntu
  • Added FxCop static analysis

Finding developers who recently made changes to a component with git

Who knows about this

A few git commands to list the developers with recent commits in a specific folder. I find that this is a good/quick way to find out who you need to talk to if you have questions about a specific code component or feature.

chinhdo@ubuntu2:~/v/tmp/converted2$ git shortlog -sn
    10  Chinh Do
     6  cdo
     5  Vas Gábor

Use git log and –pretty to show more columns:

$ git log --after='2020-01-01' --no-merges --abbrev-commit --pretty="format: %h (%an - %cr) - %s" -- .
 13495c64f7 (Joey Perrott - 3 days ago) - docs(dev-infra): update triage and contributing docs for dev-infra (#35995)
 3f88de9407 (George Kalpakas - 9 days ago) - build: move build scripts to dedicated directory (#35780)
 2e728f7fff (George Kalpakas - 9 days ago) - docs: remove `ivy` and mention `ve` label in docs (#35809)
 5615928df9 (Paul Gschwendtner - 10 days ago) - build: no longer run tslint from within gulp task (#35800)
 ...

List recent authors sorted by number of commits:

$ git log --after='2019-06-01' --no-merges -- . | grep Author: | sort | uniq -c | sort -bgr
       9 Author: George Kalpakas kalpakas.g@gmail.com
       7 Author: Joey Perrott josephperrott.github@gmail.com
       3 Author: Paul Gschwendtner paulgschwendtner@gmail.com
       2 Author: Michael Prentice splaktar@gmail.com
       2 Author: Judy Bogart jbogart@gmail.com
       ...

See also

  • https://devhints.io/git-log-format

If anyone is looking for the original name in English/Spanish of the song “Ngày Vui Đêm Nay” (í ô à)

The original version is Cuentame (The Speak Up Mambo) by The Manhattan Transfer.

Knowing only the Vietnamese version, I had a hard time finding the original song. I hate that most “foreign” songs translated to Vietnamese simply have this in the credit line: “Nhạc Ngoại” (foreign song). If you are going to translate/record the song in Vietnamese, at least give proper credit to the original performer/composer.

Here’s the vietnamese lyrics to this song to help you googlers out there:

Í o à, í o a ê …
Í o à, í o a ề …

Chiều lắng xuống, rừng vang tiếng ca mừng
Lửa bốc cháy rực lên nhg tiếng ân tình,
Thiết tha ôi ngàn lời ca đắm say ngập trời ngất ngây

Này má thắm, này môi mắt đa tình
Làm say mê, làm ngây ngất ân tình
Trái tim theo nhịp vang vang đắm say triền miên thiết tha

Hãy vui đêm nay, nét môi thơm nồng ái ân !

( nhạc….. )

Hãy cho tim non đắm say mơ mộng vòng tay ân ái,
Hát lên muôn ngàn câu hát ngất ngây tình yêu đắm say !

Í o a, í o a ê …
Í o a, í o a ề …
Í o a, í o a ê …
Í o a, í o a ề …
u u u u u ….

Này má thắm, này môi mắt đa tình
Làm say mê, làm ngây ngất ân tình
Trái tim theo nhịp vang vang đắm say triền miên thiết tha

Hãy vui đêm nay, nét môi thơm nồng ái ân

How to get free 2 GB of data on each line for Life on Verizon Wireless for about $40

Verizon Wireless is running a promo until 1/6/2016, that will give you 2 GB of free data for life if you are on an XL plan or larger, and you upgrade an existing device or add a new device.

Here’s how to you can take advantage of this promo and add the 2 GB of bonus data per line for life by spending about $50, even if you don’t have an upgrade available. To me, $40 for 2 GB of data per month for life is more than worth it.

Here’s how:

  • “Upgrade” your device to the cheapest smartphone available. Right now for me it would be the Droid Mini. The full price is $108.
  • If you are ordering online, make sure the confirmation page says you are getting 2 GB data bonus. If via a Verizon rep, confirm with her/him.
  • Activate the new Droid Mini.
  • Wait a day or two, and reactive your original phone, and sell the Droid Mini on eBay or the marketplace of your choice. You should get about $90 for it.
  • Total cost to you, excluding shipping, etc is about $40.

Disclaimer: while I believe this to work based on my own experience and available information. I cannot warranty that this will work for you.

Make all of your home servers reachable by Remote Desktop

If you have more than one servers/PCs running at home behind the internet router, you can normally set up the router port forwarding to forward Remote Desktop traffic to just one server. However, by assigning different incoming ports for different servers, you can connect to each server individually.

Basically, use a different port for each server. Then configure the port forwarding on the router to router each port to the appropriate server on 3389. This assumes that your router supports different ranges for external and internal ports.

For example, for my home setup, I use three different port numbers for the 3 servers I have at home:

RemoteDesktopPortForwarding

By using non-standard ports, there’s also a side benefit of a little extra security.

In Remote Desktop Client, you would add the port number to the Computer name like this:

RemoteDesktopClient

 

Happy Remote Desktoping!

Using Wake On LAN to remotely wake up my Windows 8 server

What I did:

  • Under Network Properties, Power Management, check “Allow this device to wake the computer” and “Only allow a magic packet to wake the computer”.
  • Under Advanced tab, make sure “Wake on Magic Packet” and “Wake on pattern match” are enabled.
  • On the Internet router, forward port 9 to the server.
  • Use “Wol Wake on Lan” Android app to wake up server.

Posting a feed to Google Search Appliance (GSA) from PowerShell

PowerShell code to submit a feed to Google Search Appliance:

$dataSource = "MyFeed" # replace this with your datasource name
$gsaUrl = "http://testsearch.example.com:19900/xmlfeed"; # replace this with your GSA URL

$xml = @"
$dataSource incremental
"@
   
Write-Output "Submitting feed to $gsaUrl."

$body = "feedtype=metadata-and-url&datasource=$dataSource&data=$xml"
$contentType = "multipart/form-data"
$length = $body.Length

Write-Output "Posting feed to GSA:"
Write-Output $xml

$r=Invoke-WebRequest -uri $gsaUrl -method POST -body $body -ContentType $contentType -UserAgent "Ps-GsaFeedSubmitter"

See also Feeds Protocol Developer’s Guide

Finding the Last Friday (or any weekday) of the Month in PowerShell

If there are less than 7 days left in the month, then it’s the last weekday of this type in this month.

function Is-LastWeekDayOfMonth([DateTime] $d) {
    return [DateTime]::DaysInMonth($d.Year, $d.Month) - $d.Day -lt 7
}

Similarly, finding the last specific weekday of the month involves finding the last weekday, and the difference between that weekday and the target weekday:

function Get-LastFridayOfMonth([DateTime] $d) {
    $lastDay = new-object DateTime($d.Year, $d.Month, [DateTime]::DaysInMonth($d.Year, $d.Month))
    $diff = ([int] [DayOfWeek]::Friday) - ([int]
    $lastDay.DayOfWeek)
    if ($diff -ge 0) {
        return $lastDay.AddDays(- (7-$diff))
    }
    else
    {
        return $lastDay.AddDays($diff)
    }
}

Back To Top