Viva Connections and a nasty hack – because UX frigging matters!

When our turtles aren’t swinging around New York City or munching on their favorite past time food of pizza’s – they are checking in on the TMNT HQ Intranet to see what’s happening, or chatting with other crime fighting colleagues in Teams.

Using a Home site via Viva Connections is the best way to do this, but unfortunately there’s a bug where the home site shines thru the navigation menu and breaks the user experience.

Quickest way to solve this? Contact Pizza Times trusted member Mikael and have him install the swizz army knife off all time – https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-script-editor. With a simple accessibility script in place, things are back to normal.

Script to fix the order of business

(Thieving bastard badge is attributing to other 3rd party usage in the solution – API’s etc)

The ALIAS from hell

.NET MAUI is in Preview. Visual Studio is in Preview. If you try to do it on a Mac it feels like every single line of code is in Preview. It isn’t even the real Visual Studio, it’s “Visual Studio for Mac”.

Developing a .NET MAUI project on a MacBook is pain. The project will suddenly stop building and you will not know why. We spent hours debugging to get it working on a Mac again, but even then it is inconsistent.

To get a consistent build I created an ALIAS to run the app.

alias fuck="cd ~/git/all-the-code/Sos.ClientApp && rm -rf obj bin && dotnet restore && dotnet restore && dotnet build -t:Run -f net6.0-maccatalyst"

This command navigates to the project, removes any generated files, restores not once but twice (trust me, I have to) and then builds the project.

It’s way slower than just building normally, but it works. Now I can go back to being happy and creating awesomeness 😄

The real nasty hacker

  1. When visiting www.elskling.no we used Fiddler to decrypt the HTTPS traffic to find the API they are using to get data. And turned it into our own custom connector.

2. We came above another API that gets both historical and today’s spot price in Norway. This could be filtered with “NO1” and so on, based on where in Norway you want to get a price from.

After getting some errors using the API, we needed an API key. After submitting an email to the email listed we received an API Key. After some more research, we could see that this is an API created by a “hacker” who abuses another public API that requires payment. We think that this is the ultimate candidate for “Thieving bastard”.

We are using this API to visualize today’s spot price and to create a local history in our database to create forecasts on prices with AI in the future.

3. The last API we are using is to get each day’s weather forecast, this is going to be combined with historical spot prices to forecast future prices on electricity. These prices are very much based on weather, and that’s why it is very relevant to include this in our library of apis.

Skumle lyder

Ved å bruke Microbit sound sensor, makecode-rammeverket Microsoft MakeCode for micro:bit (microbit.org) og Azure functions registerer vi lyder fra mutanter som romsterer rundt i fjæra.

Vi snakker med Azure functions gjennom Microbit-rammeverket via Wifi

Lydsensor koblet mot Microbit

Vi kobler sammen hovedkort og IoT-modulen til Microbit. I tillegg har vi koblet på lydsensoren for å registrere lyder innenfor et bestemt lydnivå.

Inne i makecode konfigurerer vi IoT-modulen til å snakke med Wifi. Dette gir oss mulighet til å snakke med skyen.

Videre viser vi også lokalt på tilkoblet led-skjerm på Microbitmodulen indikasjon på registrert lyd for å verifisere at vi tar i mot data lokalt.

Ved å sende lyddata fra sensoren til Azure function så registerer vi dataene i Dataverse.

Vil claimer Thieving Bastards og Nasty Hacker for denne

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

Badge – Nasty Hacker

Superdirty hack to acheive awesomeness.

First we installed Ubuntu SUB System on windows 10.

This was so we could install ansible runbook on this Rasberry PI.

Only so we could install a camera on the Train streaming live content to a webserver!!

Quite the workaround to complete a pretty awesome function!!