3D printed casing

Ho ho ho snipsters and followers! Ok, I’m about 7 days late, but better late than never no?

Just wanted to shoot a little message as it’s been a long time. Pretty busy end of the year. Been working on stabilizing Project Alice while implementing minor changes and addons. I am actually thinking over the possibility of sharing it to the grand public. As of now, Snips offices have kindly asked to have a look at the code so I decided to share it to them, as well as Rand for his home, along with some 3D printed cases.

Last week I decided I needed a Linux running computer instead of always having to flash a raspberry pi and start it. This is for the some cases I need to access a linux file system of shrink a raspberry pi image. And other cases as well. So I started to play around the idea and finally designed a casing. It’s prett cool, so imma use it for Alice main unit as well. Alice doesn’t need any mic or speaker, just a pi running with an SD. This case is designed to host a pi 3, with a 50×50 active fan. And if you need disk space, it can accomodate an X850 MSata adapter.

A few pictures? As you wish!!

I hear you already “Why all that empty space??”. I’m pretty sure some of you will add a speaker in there and instead of having the msata card and the fan, use a respeaker, no? ūüėČ

You like it? Well, then I shall share the files too!! You’ll need to print the spacers 4 times, the grille and fan guards 2 times and choose, based on your printer cap, to print the full cover, in which case you won’t need the pin, or both left and right cover

Download files

Good luck and dev safe!

Advertisements

Online, offline, back online, ISP crash…

Well, what then? No more voice, no more voice control over your house? Well, that’s only true if you are using a cloud service for your text-to-speech and/or your ASR. To be very honest, I do use Google ASR as well as Amazon Polly for TTS and I’m planning to migrate the TTS part to Google Wavenet.

In my opinion the only little devil here would be the ASR, but then again, it’s listening only when you wake Snips, unlike Google Home or Amazon dot. And the TTS? Well, it only turns a string into a voice, so don’t try to make your Snips assistant say sensitive information aloud and you’re fine.

But….. What when internet goes down? If your electricity goes out, I imagine you are clever enough to have your assistant running on a backup battery, but you surely don’t have your own internet. So either your assistant is a dead hardware in your home doing nothing more than led animations because this is most probably controlled by Snips, or you have a fallback solution.

This is where I have again worked around the corners, and to be honest again, it’s very very simple. How simple? As simple as saying it: No internet? Use Pico and Snips ASR. Internet, use whatever online service you want. How? Let’s explain first, I’ll share a Gist for you at the end of this post

  • First, install Snips, of course
  • On top of that, install Snips Google ASR.¬†Do not uninstall Snips-ASR!
  • Now, let’s open you assistant python (or whatever language)
    • Let’s make sure, when your assistant starts, to have it call my bash script
      subprocess.call(['/home/pi/offlineFallback/shell/switchOnlineState.sh', "1"])
    • Create some kind of loop in your assistant, that will call the online state check method every minutes. If it’s your assistant, do not use time.sleep() as in my demo, it would block the thread! Instead, use threading.Timer()
      while RUNNING:
         ONLINE = checkOnlineState()
         time.sleep(60)
    • In our online state checker, we’ll check if we have access to internet and act accordingly. Meaning we try to ping google.com (ever saw google offline??) with a short timeout of 2 seconds. If the ping fails it will raise an error. If not, and only if we actually were offline before, then we call the bash script and print the happy new. If we had an error raised, we are offline, so if we were online before let’s call the bash script and announce the terrible news
      def checkOnlineState():
         global ONLINE
      
         try:
            req = requests.get('http://clients3.google.com/generate_204')
            if req.status_code != 204:
               raise Exception
      
            if not ONLINE:
               subprocess.call(['/home/pi/offlineFallback/shell/switchOnlineState.sh', "1"])
               print('Internet is back, switching back to Amazon Polly voice and Google ASR')
      
            return True
         except:
            pass
      
         if ONLINE:
            subprocess.call(['/home/pi/offlineFallback/shell/switchOnlineState.sh', "0"])
            print('No more internet connection, falling back to PicoTTS and Snips ASR')
      
         return False
    • That’s pretty simple isn’t it? Oh wait, the bash script itself…So, the variable state becomes whatever was passed as an arguments, in our case 1 or 0, for online and offline. If we are online, then change picoTTS by customTTS in your snips.toml file, stop snips-asr and start snips-asr-google. And do the opposite if we are offline! And don’t forget to restart snips after that.
      #!/usr/bin/env bash
      
      state="$1"
      
      if [[ "$1" -eq "1" ]]; then
          sudo sed -i -e 's/provider = "picotts"/provider = "customtts"/' /etc/snips.toml
          sudo systemctl stop snips-asr
          sudo systemctl start snips-asr-google
      else
          sudo sed -i -e 's/provider = "customtts"/provider = "picotts"/' /etc/snips.toml
          sudo systemctl stop snips-asr-google
          sudo systemctl start snips-asr
      fi
      
      sudo systemctl restart snips-*
  • If you don’t add this directly to your assistant, you could add this script to your system startup.

See how simple this was? As I love to say

Your imagination is your limit. Dream and you’ll walk the moon

This is especially true when it comes to programing and hacking your way around… Have fun with Snips and dev safe!

 

The links? Ok!

Proximity sensor??!?

Been quite some time I haven’t written again. Well, plenty to do and done a lot.

Using assistants at home is really really helpfull nowadays, everything is connected and it’s just awesome to be able to ask your lights to change, your shutters to close etc.

Snips is awesome! But for those using it also, you surely had many false hotword detection. At least I have many while watching TV. It just activates too much! Or maybe you have friends at home and you want to turn it off? Snips is local, so no worries about data privacy, but still, you don’t want your assistant to react on those foreign voices.

I built my satellites for Snips and in the design phase I thought it would be good to include captors and sensors, even with no use idea yet. This is why I built in a APDS9960 and a BME680. The first one is a color, proximity, gesture and light sensor. The second one is a temperature, pressure, humidity, gas sensor.

The second one is clearly in full use, to make sure my windows and shutters behave nicely and assure me a fresh but not cold house.

But the first one? Well, it wasn’t in use at all. But I finally had an idea for the proximity sensor! Introducing Mute! Enjoy!

 

The leds are Neopixels, also by Adafruit, driven directly from the raspberry pi zero.

Some links? Sure!

Project Alice – Snips Velux Red Queen

Velux windows, velux blinders, velux shades, skylights. These products are well-known, so known that in switzerland, you don’t speak about “roof windows” but you have “velux”.

Velux is using a completely closed protocol for its products which is a radio protocol belonging to IO-Homecontrol, an attempt to home automation, on a closed protocol that entirely locks users from doing anything or changing/adding a behavior. Reversing and tempering with this protocol has been tried by many, I haven’t seen any successful attempts yet.

Netatmo is a very successful french startup to brought some very well designed smart weather stations in our home, offering I think the best weather data around the world. They also made some nice indoor and outdoor security camera. Their base controller not only checks for the temperature, but also the air quality, the noise level, the atmospheric pressure, the humidity. Add to that the other (quite expensive) modules for the outside and you’ve got a full weather station with rain meter and wind sensor! They also provide control for you heating system, helping you lower your monthly bills!

I’m having both velux and Netatmo. Velux remotes are from the stone age, bulky, not updatable, very slow, even the new touch screens ones are maybe a bit better, but hell, try to make a complex program! And of course, no integration with anything else than IO… Until lately, when Netatmo announced a partnership with Velux for an intelligent home:¬†https://www.netatmo.com/fr-FR/partners/velux

It all started when I decided to use my voice to control my velux products using Snips, a raspberry and an old velux remote. It works like a charm and the latest updates I pushed to the script make it fail safe throughout the day and storms! But I needed more. Bored to ask Snips to open my windows when it was hot. Bored of opening them to only realise it was even hotter outside and all I was doing was warming up the inside of my house.

So I thought, hey, why not automate all that? I was for sure gonna buy the Netatmo Velux thingy, but hmm… A device per room? How much is this gonna cost? I thought, let’s use Project Alice and give it some abilities to control my house for myself…

I decided to name that module “Red Queen” because “Project Alice”. I worked a little on it, tested it in real-time. It’s far from finished, but…. it’s basically doing what Netatmo is going to release end of this year!! For the very modest sum of a raspberry pi 3 a Velux controller and a few electronic¬†components!!

So what is it doing? Well, when Project Alice boots, the Red Queen awakes and takes control of the air quality and decides, purely data based, what to do. It will check the status every 15 minutes and act as needed to stay as closed to the programmed comfort temperature. It handles many things already, opening or not, wind or not, us sleeping or not, us home or away etc etc etc. I won’t go too far into the details, but this is a compilation of all the possible logs (so decision) the Red Queen can take at the moment:

  • - Red Queen checking the air quality
    - - Velux overridden by user voice command
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 21.9c, outside temperature at 20.5c
    - - Inside temperature is inside comfort zone
  • - Red Queen checking the air quality
    - - Co2 level above 850ppm opening all windows!
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 24.8c, outside temperature at 20.5c
    - - Outside is cooler, opening to cool
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 24.8c, outside temperature at 27.5c
    - - Outside is warmer than inside, making sure windows are closed
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 24.8c, outside temperature at 29.1c
    - - Outside is warmer than inside, making sure windows are closed
    - - Outside is over 29c, closing blinders too
  • - Red Queen checking the air quality
    - - Comfort temperature at 19c, actual temperature in bedroom at 20.8c, outside temperature at 20.5c
    - - (Sleeeping) Keeping windows at 30% for air
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 18.8c, outside temperature at 20.5c
    - - Inside temperature lower than comfort, outside is warmer, opening windows
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 20.8c, outside temperature at 7.5c
    - - Inside temperature lower than comfort, outside is even colder, closing the windows
  • - Red Queen checking the air quality
    - - Comfort temperature at 19c, actual temperature in bedroom at 18.7c, outside temperature at 16.2c
    - - (Sleeping) Keeping windows at 10% for minimum airing
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 25.6c, outside temperature at 27.2c
    - - 21km/h wind from the lake, opening both sides for 15 minutes
  • - Red Queen checking the air quality
    - - Comfort temperature at 22c, actual temperature in living room at 23.5c, outside temperature at 16.2c
    - - (Users away) Opening windows to 50% to cool

 

The first logs talks about override. What’s this? Well, whenever I or my wife ask Alice (Snips) to open the windows or the blinders, I don’t want the Red Queen to blindly close them again 2 minutes after because her 15 minutes timer just ended. So when Snips gets an order, any Red Queen decisions are overridden (canceled) for the next hour. We stay master of our home!!

That’s a quick tour of what’s made so far. I have many ideas, maybe integrating the Netatmo heating control devices, but I’m having a floor heating… But I’ll definitely improve the Red Queen to better suit our home to the best temperature and air quality, for better days and nights!

Dev safe!

Some links:

redqueen

redqueen3

redqueen2

redqueen4

Project Alice – Casing the Velux controller

I’m all about closing the different units I have so far in cardboard prototypes as I am still waiting and waiting on my 3D printer that will I hope come once this year…

I had enough of seeing my Velux Snip controlled module hanging in the dust, unprotected, looking like an unfinished project, so I quickly made it a little box to sit nicely on top of my wall plugs. Decided to let the screen visible, so I can still visually check in case of problems, but the code was rewritten and I have not had any errors since then.

Ho yeah! I also replace the Pi Zero that had the header soldered by a naked one, cut the wires to the remote shorter and soldered them directly on the pi 0.

 

If you are looking to have your own Snips controller Velux system, check my Github:

https://github.com/Psychokiller1888/snipsvelux

Dev safe!

Project Alice – Satellite casing

From drawing to cardboard first prototype… A serie of pictures of a casing I made today, from the sketch all the way through cutting, mounting and having it placed in the bedroom.

I use a hot glue pistol to glue the bolts on their place and to be able to screw the whole thing together. I was a bit too lazy to go out and fetch some plexiglass for the respeaker leds, will do that in a next iteration

This module embarks a raspberry pi zero W, an Adafruit passive speaker, a respeaker 2 and a MCP9808 for temperature. I am waiting on two RGB led bars, a light sensor, a temp+humidity sensor to replace the MCP9808 and a few other things to make it a complete module. And of course…. It’s powered by¬†Snips!

Enjoy the pictures and stay tuned for the next iteration!

 

Alice, let’s play

An important part of assistant, in my opinion, is the ability to assist me when I’m bored… Entertain me Alice!

Alice can already tell me jokes, she randomly says things like a person, sometimes asks us how we are etc etc. But I wanted her to be able to play with us!

So I made a simple but very known game, a spelling game!

Here are the logs of a game I had with Alice. In bold my conversation with her:

[09:47:28] Watching on localhost:1883 (MQTT)
[09:47:34] [Hotword] detected on site office, for model alice
[09:47:35] [Dialogue] session with id ’68e5eff5-ecb1-4261-ad48-cd7b8ac77f2e’ was started on site office
[09:47:39] [Asr] captured text “let’s play a spelling game” in 3.7s
[09:47:40] [Nlu] detected intent Psychokiller1888:playGame with probability 0.485 for input “let’s play a spelling game”
Slots ->
game -> spelling game
[09:47:40] [Dialogue] New intent detected Psychokiller1888:playGame with probability 0.485
Slots ->
game -> spelling game
[09:47:40] [Dialogue] was ask to end session with id 68e5eff5-ecb1-4261-ad48-cd7b8ac77f2e
[09:47:40] [Dialogue] session with id ’68e5eff5-ecb1-4261-ad48-cd7b8ac77f2e’ was ended on site office. The session ended as expected
[09:47:40] [Dialogue] was asked to start a session on site office
[09:47:41] [Dialogue] session with id ‘a43b0618-c160-406e-a5ea-595cf9222c1d’ was started on site office
[09:47:41] [Tts] was asked to say “Ok, let’s play the spelling game!, How do you spell candle?
[09:47:50] [Asr] captured text “candle” in 4.5s
[09:47:51] [Nlu] intent not recognized for “candle”
[09:47:51] [Dialogue] was ask to end session with id a43b0618-c160-406e-a5ea-595cf9222c1d by saying ‘Perfect, you spelled it correctly!
[09:47:51] [Tts] was asked to say “Perfect, you spelled it correctly!”
[09:47:51] [Dialogue] was asked to start a session on site office
[09:47:55] [Dialogue] session with id ‘a43b0618-c160-406e-a5ea-595cf9222c1d’ was ended on site office. The session ended as expected
[09:47:55] [Dialogue] session with id ‘a1c0a5a3-1bb4-48dc-9948-01296f9f4911’ was started on site office
[09:47:55] [Tts] was asked to say “Next one, how do you spell hustler?
[09:48:07] [Asr] captured text “h u s t l e r” in 6.0s
[09:48:08] [Nlu] intent not recognized for “h u s t l e r”
[09:48:08] [Dialogue] was ask to end session with id a1c0a5a3-1bb4-48dc-9948-01296f9f4911 by saying ‘Bravo, you are correct!
[09:48:08] [Dialogue] was asked to start a session on site office
[09:48:08] [Tts] was asked to say “Bravo, you are correct!”
[09:48:12] [Dialogue] session with id ‘a1c0a5a3-1bb4-48dc-9948-01296f9f4911’ was ended on site office. The session ended as expected
[09:48:12] [Dialogue] session with id ‘47180a03-aaa6-40f5-8b8f-fc3cfe453369’ was started on site office
[09:48:12] [Tts] was asked to say “Next one, how do you spell hustler?
[09:48:20] [Asr] captured text “h u s t l e r” in 4.7s
[09:48:21] [Nlu] intent not recognized for “h u s t l e r”
[09:48:21] [Dialogue] was ask to end session with id 47180a03-aaa6-40f5-8b8f-fc3cfe453369 by saying ‘Excellent job, this is correct!
[09:48:21] [Tts] was asked to say “Excellent job, this is correct!”
[09:48:21] [Dialogue] was asked to start a session on site office
[09:48:25] [Dialogue] session with id ‘47180a03-aaa6-40f5-8b8f-fc3cfe453369’ was ended on site office. The session ended as expected
[09:48:25] [Dialogue] session with id ‘f716a882-42a4-4b46-a2d2-905e80f26431’ was started on site office
[09:48:25] [Tts] was asked to say “Next one, how do you spell bed?
[09:48:34] [Asr] captured text “b e d” in 3.4s
[09:48:35] [Nlu] intent not recognized for “b e d”
[09:48:35] [Dialogue] was ask to end session with id f716a882-42a4-4b46-a2d2-905e80f26431 by saying ‘Excellent job, this is correct!
[09:48:35] [Dialogue] was asked to start a session on site office
[09:48:35] [Tts] was asked to say “Excellent job, this is correct!”
[09:48:37] [Dialogue] session with id ‘f716a882-42a4-4b46-a2d2-905e80f26431’ was ended on site office. The session ended as expected
[09:48:37] [Dialogue] session with id ‘de54c2cc-0d22-471a-8f97-0dcd7eea1201’ was started on site office
[09:48:37] [Tts] was asked to say “Next one, how do you spell federation?
[09:48:49] [Asr] captured text “f e d e r a t i o n” in 6.3s
[09:48:50] [Nlu] intent not recognized for “f e d e r a t i o n”
[09:48:50] [Dialogue] was ask to end session with id de54c2cc-0d22-471a-8f97-0dcd7eea1201 by saying ‘Excellent job, this is correct!’
[09:48:50] [Tts] was asked to say “Excellent job, this is correct!
[09:48:50] [Dialogue] was asked to start a session on site office
[09:48:52] [Dialogue] session with id ‘de54c2cc-0d22-471a-8f97-0dcd7eea1201’ was ended on site office. The session ended as expected
[09:48:52] [Dialogue] session with id ‘5f947a82-cc36-4dc8-a84c-e814916edca1’ was started on site office
[09:48:52] [Tts] was asked to say “Next one, how do you spell water?
[09:49:02] [Asr] captured text “water” in 4.2s
[09:49:03] [Nlu] intent not recognized for “water”
[09:49:03] [Dialogue] was ask to end session with id 5f947a82-cc36-4dc8-a84c-e814916edca1 by saying ‘Bravo, you are correct!
[09:49:03] [Dialogue] was asked to start a session on site office
[09:49:03] [Tts] was asked to say “Bravo, you are correct!”
[09:49:05] [Dialogue] session with id ‘5f947a82-cc36-4dc8-a84c-e814916edca1’ was ended on site office. The session ended as expected
[09:49:05] [Dialogue] session with id ‘f43b908d-aae0-4f15-9aca-cae96c328083’ was started on site office
[09:49:05] [Tts] was asked to say “Next one, how do you spell federation?
[09:49:11] [Asr] captured text “JFK” in 2.4s
[09:49:12] [Nlu] intent not recognized for “JFK”
[09:49:12] [Dialogue] was ask to end session with id f43b908d-aae0-4f15-9aca-cae96c328083
[09:49:12] [Dialogue] session with id ‘f43b908d-aae0-4f15-9aca-cae96c328083’ was ended on site office. The session ended as expected
[09:49:12] [Dialogue] was asked to start a session on site office
[09:49:12] [Dialogue] was asked to start a session on site office
[09:49:12] [Dialogue] was asked to start a session on site office
[09:49:12] [Dialogue] was asked to start a session on site office
[09:49:12] [Dialogue] was asked to start a session on site office
[09:49:12] [Dialogue] session with id ‘011930eb-f478-4e86-bc1e-a19aacdee0f1’ was started on site office
[09:49:12] [Tts] was asked to say “This is wrong unfortunately…
[09:49:16] [Dialogue] session with id ‘011930eb-f478-4e86-bc1e-a19aacdee0f1’ was ended on site office. The session ended as expected
[09:49:16] [Dialogue] session with id ‘6df25c34-975c-4f08-9000-daa6ad5c4c7c’ was started on site office
[09:49:16] [Tts] was asked to say “federation is spelled: f, e, d, e, r, a, t, i, o, n,
[09:49:27] [Dialogue] session with id ‘6df25c34-975c-4f08-9000-daa6ad5c4c7c’ was ended on site office. The session ended as expected
[09:49:27] [Dialogue] session with id ‘a055dada-e285-4fe6-9599-564c01536942’ was started on site office
[09:49:27] [Tts] was asked to say “This is game over. You scored 6 points
[09:49:33] [Dialogue] session with id ‘a055dada-e285-4fe6-9599-564c01536942’ was ended on site office. The session ended as expected
[09:49:33] [Dialogue] session with id ‘5df42b3f-648c-49df-8fe8-97e3dfc3bd4b’ was started on site office
[09:49:33] [Tts] was asked to say “This is your new personal highscore! Congratulations!
[09:49:37] [Dialogue] session with id ‘5df42b3f-648c-49df-8fe8-97e3dfc3bd4b’ was ended on site office. The session ended as expected
[09:49:37] [Dialogue] session with id ’09be3a02-1cdb-47b2-bc72-2c78c14b1c63′ was started on site office
[09:49:37] [Tts] was asked to say “Do you want to play again?
[09:49:41] [Asr] captured text “no” in 1.9s
[09:49:42] [Nlu] detected intent Psychokiller1888:answerYesOrNo with probability 1.000 for input “no”
Slots ->
answer -> no
[09:49:42] [Dialogue] New intent detected Psychokiller1888:answerYesOrNo with probability 1.000
Slots ->
answer -> no
[09:49:42] [Dialogue] was ask to end session with id 09be3a02-1cdb-47b2-bc72-2c78c14b1c63 by saying ‘Ok, we’ll certainly play again soon!
[09:49:42] [Tts] was asked to say “Ok, we’ll certainly play again soon!”
[09:49:45] [Dialogue] session with id ’09be3a02-1cdb-47b2-bc72-2c78c14b1c63’ was ended on site office. The session ended as expected

Or if you prefer to listen, here’s another game:¬†Soundcloud

Yes, it tracks points and does store them in database so you are told if you beat your previous highscore. The game module engine can tell your ranking per game with the users that played in your home. Pretty good solution to decide who, between you and your partner, is going to cook this evening!

Nothing really hard to get there, taking advantage of intent not recognized again, using sqlite to store the highscores and query them. I’m planing on adding more games of course!

Dev safe!

Links

Snips: https://snips.ai
Soundcloud: https://soundcloud.com