| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|

A Magic Mirror module for displaying results from OwnTracks in a manner similar to the Harry Potter series of movies. This module will parse messages sent from your mobile phone and display your rough location.
This module was inspired by the Instructable Build Your Own Weasley Location Clock.
Installation of the Magic Mirror module is similar to all other Magic Mirror modules:
cd /home/pi/MagicMirror/modules git clone https://github.com/BrianHepler/MMM-WeasleyClock cd MMM-WeasleyClock npm install
Modify your config.js file to include the module.
{
module: "MMM-WeasleyClock",
position: "middle_center",
config: {
uniqueId: "demo",
},
},
Your configuration needs to contain a unique identifier that will separate your module from all of the other modules (namely mine). This unique ID will be entered both in the module and OwnTracks app on your phone. If you do not enter a unique ID, everyone who uses the same ID will be able to see your movements.
{
module: "MMM-WeasleyClock",
position: "middle_center",
config: {
uniqueId: “MovieFamily”,
locations: ["School", "Work", "Jail", "Mortal Peril", "Bar", "Home"],
people: ["Harry","Ron","Hermione",”Ginny”],
},
},
See the full list of options.
OwnTracks is a free application for your mobile phone. Go to the Google Play Store or the iTunes store and search for OwnTracks. Install the app and then open it, just like you were installing Candy Crush.
Once the app is open, click on the menu in the upper left and select Preferences at the bottom.

Press the Connection option and then the Mode option to switch to MQTT. Click Accept to return.

Configure the Host menu with the following values. Host=weasleymirror.duckdns.org, Port=8883. ClientID can be any unique value. Do not use websockets. Click Accept to return.

Configure the Identification values. The fields in the OwnTracks app do not exactly match up to the module's terminology. So here is what you put in each field:

In the Security submenu, turn on TLS. Leave the rest of the fields blank. Click Accept to return.

Finally, configure the client to use a clean session. (basically, have no memory of previous connections)
Click Accept to return.

Once everything is complete, you can go back to the Preferences menu and click on the Status menu item and see Connected at the top.

Whew! At this point, you are connected to my MQTT server, but your phone doesn't know anything about the locations you specified in the config.js. Specifying a location in OwnTracks is currently rather cumbersome, but it's worth it when you're done.
You need to create Regions in OwnTracks that match to the locations you wish to display in your Weasley Clock.
In order for the module to work, the OwnTracks app will need to know the location of each location you're displaying in the module. So you'll need:
Note: The locations can be different for each phone. For example, my wife and I both have "Work" configured on our phones, but we have different long/lat configured. As our respective phones enter the different regions, they each report that we have entered "Work" to the mirror.
In the OwnTracks app, opent he menu and click on Regions. Click on the "+" button to add a new region. Enter the name of the location and the longitude & latitude. Add a radius to define the area that the phone will consider to be that location. 250 meters is a good starting point.

These are the options to configure the module. Configuring the OwnTracks application will be handled below.
| Option | Description |
|---|---|
| uniqueId | Description: The unique identifier shared between your instance of the MMM-WeasleyClock module and your OwnTracks apps. This value must also be set in the OwnTracks app in the Username field. (Capitalization is important!)
Default: "notunique" Note: Leaving this unchanged will allow everyone else with this module to see your locations on their cell phones. |
| locations | Description: An array of location names. These are the possible locations that the module will display. They must match the names of the regions you define in the OwnTracks application. (Capitalization is important!)
Default: ["Home","School","Work","Mortal Peril","Jail","Food"] Note: There are two additional locations that are reserved: "Traveling" and "Lost". They will be included automatically. |
| people | Description: An Array of names. Each one will be represented by a hand on the clock. Each OwnTracks app must be configured with one of these names in the Device ID field. (Capitalization is important!)
Default: ["Harry","Ron","Ginny"] |
| colorCycle | Description: An array of color names that will be used for the hands.
Default: ["blue","green","yellow","purple","red","white","gray"] |
| radius | Description: The radius of the circle that defines the positioning of the locations around a central point. Adjust this to tighten up or expand your clock size.
Default: 85 Note: Has no effect on the table display. |
| hubDisplacement | Description: The space between the center point and the beginning of each hand.
Default: 5 |
| sounds | Description: Turns on or off the sound that plays when the hands move position. Sound does not play in table mode.
Default: true |
| debug | Description: Turns on the debug messages logging in the node console. You can see this via an SSH connection & `pm2 log 0`
Default: false Note: I'm a bit verbose. |
| host | Description: The URL of the MQTT server (aka, the message broker). This is where the module will listen for messages from OwnTracks.
Default: weasleymirror.duckdns.org |
| mirrorUser | Description: If you are running your own MQTT server with password authentication, you can specify the username that the module uses to log in here.
Default: null |
| mirrorPass | Description: If you are running your own MQTT server with password authentication, you can specify the password that the module uses to log in here.
Default: null |
| port | Description: The network port used to connect to the MQTT server.
Default: 8883 |
| disableEncryption | Description: Set to true if you're running your own MQTT server without TLS.
Default: false |
Owntracks is a free mobile app that will track your location and send updates to a MQTT server. These steps will get your phones to use my MQTT server. All of these steps are to be taken on your mobile phone.
Regions = Locations in your module configuration. The way this works is that when your cell phone/table enters a defined region, it publishes a notification to the MQTT server. To get it to work, you have to define for your phone what regions correspond to what name. It is important to note that each region can be defined differently for each device. For example, you and your spouse can have different regions called "Work".
Note: Two names are reserved by the module: Traveling and Lost.
Unfortunately, the new versions of OwnTracks requires you to specify longitude & latitude when defining regions. So you can define these regions the hard way or the harder way.
Start with the list of locations that you defined in the locations parameter in the module configuration. "School", "Home", "Mortal Peril", etc. Using your favorite mapping website, look up the longitude & latitude for each location and write it down.
Start with the list of locations that you defined in the locations parameter in the module configuration. "School", "Home", "Mortal Peril", etc. Just straight up travel to each of these locations. Home, School, Bar, etc should be pretty easy. "Mortal Peril" could get interesting.
You don't have to use my MQTT server. You are welcome to set up your own. I have a separate page on how to set up Mosquitto on your Magic Mirror so you can keep your data to yourself.
The basic operational flow goes like this:
I am hosting an MQTT server for this module at weasleymirror.duckdns.org. You are welcome to set up your own server or use mine. I can't see your messages, but I can see if you connect successfully. By default, the module is configured to use my server.
I've written up some advice to help over at the Developer's Notes. I've also included some debugging tips.
| Back | FazBrowse Home | New Git URL |