Power Chess Final Delivery

Interessen rundt sjakk har eksplodert det siste året, blant annet The New York Times melder om rekordsalg og en økning på over 1000% på salg av fysiske sjakkbrett. Økningen i salget er hovedsakelig påvirket av den populære serien the Queen’s Gambit, og streaming programmet PogChamp. Men det er et problem, vi er midt i en pandemi og ingen kan spille fysisk sjakk mot hverandre.

Heldigvis sitter vi på løsningen: Power Chess!
Ved å bruke Power Chess kan du spille et fysisk sjakkparti mot hvem du vil uansett hvor i verden motstanderen befinner seg.

Slik fungerer det:

Hver spiller har hvert sitt sjakkbrett som er koblet på internett og bruker AI som identifiserer hvilke trekk som er utført. Når et sjakktrekk er identifisert vil sjakkbrettet til motstanderen utføre det samme sjakktrekket.

Under ser dere den automatiske lego-armen i Action. Filmen viser først et sjakktrekk på sjakkbrett 1, deretter ser vi lego-armen på sjakkbrett 2 på motstanderen sitt sjakkbrett.

Teknologien bak Power Chess

API og Azure Cognitive Services

Gjennom å integrere oss mot SharePoint, function app og ACS (Azure Cognitive Services)

I den tekniske løsningen vår benytter vi en integrasjon mot SharePoint, for å detektere at en ny fil har blitt lagt til, samt uthenting av denne filens innhold.

Videre har vi en integrasjon mot Function App som vi kjører et POST-kall mot tjenesten som gir oss 64 objekter tilbake.

Disse 64 objektene sendes til Azure Cognitive Services for analysering av innholdet.

Deretter blir dataen(Sjakkbrettet) prosessert og sendt til DataVerse ved en create.

Flow:

Ved å bruke Power Automate sin Cloud Flow har vi opprettet en Flow som trigges ved opprettelse av en ny fil i SharePoint i en mappe vi har kalt “Moves”. Ved å bruke en standard funksjon i Flow som henter innholdet i filen, får vi en string som vi kan sende til function app.

Function-app

Function appen mottar en string gjennom HTTP protokollen og deretter kutter opp bildet/Sjakkbrettet i 64 objekter, samt legger metadata på hver enkelt objekt for å identifisere hvor plasseringen er. Deretter blir disse sendt tilbake til flowen gjennom HTTP.

CRM / Dataverse

All dataen vi prosesserer illustrerer vi i en Model Driven app. Her kan vi se oversikt over alle rundene i enhvert spill, og posisjonene på alle brikkene. Ved hjelp av plattformen, og litt fancy HTML-kode, har vi fått denne skalerbar i forhold til enheter og skjermstørrelser.
Er man «on-the-run», kan man enkelt åpne applikasjonen via telefonen, og få en tilsvarende opplevelse.

HTML/CSS og Javascript kan være et kraftig verktøy. Om man trives i «den ville vesten», får man virkelig testet seg. Det har vært en god utfordring for oss CRM-konsulenter, men er fornøyd med resultatet.

Rasberry PI + Lego Boost

For å kontrollere Boost motoren til Lego har vi benyttet en Raspberry PI med Python script som kan sende signaler til boost motoren via BLE (Bluetooth Low Energy).

Badger vi clamer med denne posten:

#Glossy Pixels
#High 5
#Go With the Flow
#Chameleon
#Plug N’ Play
#Power User Love

Badge – Go with the flow

To manage the important task of notifying the crisis team when disaster occurs we have created a logic app that runs through a process.

IF the IOT device goes offline (LAVA killed the device) a notification is received to logic app. This in turn triggers a message in Teams of the Mayor, and rends the mayor an approval request for “Create Task Force”.

The logic app awaits the confirmation from the Mayor.

Once the Mayor confirms, we have a Disaster Team ready to coordinate the help we need, and a task to be completed.

IOT: Reading out messages on Sonos from Dataverse

When tasks are created in our nice little family the kids often doesn’t respond when their parents are sending out push notifications to their devices.

As a way to remind the kids on their tasks we have developed a system that reads out the tasks on the sonos speakers in the house

This setup requires the following components

  • Dataverse Tasks table
  • Power Automate Flow with “Common Data Service (current environment)” and “Service Bus” steps
  • Azure Service Bus
  • Talkity.com free text to speech subscription
  • Some device able to run Python on the same local netwok as the Sonos devices. E.g. a Raspberry PI
  • One or more Sonos Speakers

Power Automate Flow to put messages on Azure Service Bus Queue

Text to speech using Talkify

We have investigating several services for Text to Speech. Azure Cognitive Services have some, but we went the easy route and found one where it was possible to just compose a long url and post it directly and get a MP3 file with the speech back. https://talkify.com

The URL is on the format https://talkify.net/api/speech/v1?text=Clean your room&rate=2&format=mp3&voice=Microsoft Hazel Desktop&fallbackLanguage=English&key=xxxxxxx

The paid verison of Talkify also supports Norwegian, but as we are using the free version only English are supported

Our initial idea was to have a power automate flow step to do fetch the MP3 and upload the MP3 somewhere readable for Sonos (like Azure Blob Storage), but when it was as easy as calling an GET URL we can send that URL directly to Sonos.

Subscribing to the Azure Service Bus Queue and triggering the Sonos Speakers using Python running on a Raspberry PI

So playing files on the Sonos isn’t THAT difficult – especially when the sound files are from publically available URLs

The following Python script is using the SoCo Sonos Library (https://soco.readthedocs.io/en/v0.21/releases/0.13.html) and Azure Sevice Bus SDK v7.

The python script is deployed to a local raspberry Pi that can works as a local controller of the Sonos System.

Note: as long as you are on the same network as a Sonos speaker you can control it without any authentication. Tip for practical jokes 👌👍


from azure.servicebus import ServiceBusClient, ServiceBusMessage

from soco import SoCo
import soco
import urllib

sonos = SoCo('192.168.x.x') #kontor
print(sonos.player_name)

with ServiceBusClient.from_connection_string("Endpoint=sb://acdctaskservice.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxx=") as servicebus_client:
        print("ok")

        while True:
                try:
                        receiver = servicebus_client.get_queue_receiver(queue_name="taskqueue", max_wait_time=5)
                        with receiver:
                                for msg in receiver:
                                        print(msg)
                                        sonos.volume = 10
                                        url = "https://talkify.net/api/speech/v1?text="+ str(msg) +"&rate=2&format=mp3&voice=Microsoft Hazel Desktop&fallbackLanguage=English&key=xxx"
                                        print(url)
                                        sonos.play_uri(url)

                                        track = sonos.get_current_track_info()
                                        print(track)
                                        receiver.complete_message(msg)

                except Exception as e:
                        print( "Error: %s" % e )	
Bilderesultater for raspberry pi
Bilderesultater for sonos 1

Hopes for (some of) the following badges:

Embedding Numbnut

Go with the flow

Right now (uses service bus to send events directly)

Thieving Bastards (uses 3rd party SoCo Sonos library and shady text to speech service)

Nasty hacker (sends in the composed text-to-speech url with subscription key and everything to sonos)

And maybe a point or two in the categories

Blow my Mindstorm

Lego Autobots

Lego Shark Thank

Using Teams as a Familiy Management Hub

We have built a data structure in Dataverse where we are using the standard “systemuser” table to hold information about the famili members

We have added a new table “Family” which is connected to Systemuser / “Family Member” so users can be members of a family with either “Parent” og “Child” roles.

This is the first iteration of this Team, more functionality will follw

Add Kids and Parents to your selected family directly in teams

Giving tasks / chores to kids

We want a system where parents can assign daily tasks / chores to their kids. This can be “Clean your room”, “get the mail”, “take out the trash” etc

This is solved by using standard “Task” acitvities in Dataverse, and we have a Power Automate Flow that is listening to new tasks, ready to give the kid a notification on his Power App on his/hers phone, and further alerting with sound on Sonos it the kid does not respond

We haven’t built a dedicated GUI for the task assignings process yet. This would probably be a Canvas app. So far we are using the model driven app to assign tasks to kids

Power Automate Flow to push notifications to the Kid’s Power App. We also put messages to an Azure Service Bus Queue which is supposed to be picked up by a Raspberry PI controlling the Sonos speakers in the family house

Goal for this post:

  • Get daily category points for Power Platform usage
  • Go with the flow badge
  • Power User love badge