I have made me a Christmas Present by myself, and ordered a LaMetric Watch a few days ago. If there is someone, who don’t know what this is, take a look here: https://lametric.com/
After some time, configuring and playing around, I got the idea to push Messages to the LaMetric Watch with PowerShell.
It took only a few minutes, reading the API Documentation and write some PowerShell Code, and it worked like a charm.
It took some more time, to write a nice looking PowerShell Code and to write this Article to provide you this Information.
The complete PowerShell Script is available at the Microsoft TechNet Gallery, see the Link at the bottom.
Preparation
Of course, you have to configure your LaMetric Watch and connect it to your Wi-Fi, I will not guide you through this steps
We need the IP and the API Key, the IP should be an easy one, go to your DHCP Server and check the IP, or open the LaMetric APP on your Phone, Settings About, and Wi-Fi, there is your IP
The API Key can be found in the Developer Area at the LaMetric Web Page, in the Device Section: https://developer.lametric.com/user/devices
See this Article for more Help if needed: https://lametric-documentation.readthedocs.io/en/latest/guides/first-steps/first-local-notification.html
Replace the Information at the following Part in the Script
#Api Settings $LametricIP="192.168.1.199" $ApiKey="asdasdwqd2332r3fwf3223w"
Settings and Script
The rest of the Script is straight forward, you have some settings, which are listed in the Script itself, if your interest in some more Details, take a look at the API Docs from LaMetric: https://lametric-documentation.readthedocs.io/en/latest/reference-docs/device-notifications.html
#Alert settings $Priority="info" #"info, warning, critical $Icon="25675" #25674 = au2mator $Text="My favorite Blog is Techguy.at :-)" $SoundCategory="notifications" #notifications, alarms $SoundId="notification4" $SoundRepeat="2" $DisplayCount=1 #Code #Build JSon $json=@" { "priority":"$Priority", "model": { "frames": [ { "icon":$Icon, "text":"$Text" } ], "sound": { "category": "$SoundCategory", "id": "$SoundId", "repeat":$SoundRepeat }, "cycles":$DisplayCount } } "@ $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("dev:$ApiKey"))) $header = @{ Authorization=("Basic {0}" -f $base64AuthInfo) } Invoke-RestMethod -Method POST -Uri ("http://"+$LametricIP+":8080/api/v2/device/notifications") -ContentType "application/json" -Headers $header -UseBasicParsing -Body $json
Result
GitHub: https://github.com/Seidlm/Lametric-Time-Send-Notification-with-PowerShell
Michael Seidl aka Techguy