PHAD: A Replacement for Pi-Hole’s Chronometer (and also PADD)

Pi-Hole is an amazing DNS based ad blocker. One of its ancillary features is it’s text-based “Chronometer” mode. If you invoke pihole with the “-c” option you will see a display like the following that refreshes automatically:

While this Chronometer is handy it’s still rather lacking in the information it provides. A drop-in replacement called PADD has been available for a while that provides significantly more data about your Pi-Hole’s activity. While PADD is a huge leap over the built-in Chronometer functionality I felt that it was also a little lacking. Many people run Pi-Hole on Raspberry Pi’s (not surprising given its name), and many people who use Chronometer or PADD use a TFT LCD screen, many of which are actually touchscreens.

It occurred to me that a highly customizable text display that leverages the features of LCD touchscreens would be a very powerful tool to complement Pi-Hole. The result of this thought is PHAD, the Pi-Hole Alternate Display. PHAD is a python app that uses the highly popular Jinja2 template engine to make it possible to create custom displays. PHAD also supports cycling between multiple templates by tapping on the Pi-Hole’s touchscreen or on a timed schedule.

For more details on installing and using PHAD see the projects README file over on GitHub.

Pi-Hole on a Raspberry Pi 3

Just a few notes on my setting up Pi-Hole on a Raspberry Pi 3:

  • I used NOOBS to initially install Raspbian linux (jessie)
  • I wanted to set up 2 of them, one on my internal network and one on my DMZ, so I bought/configured two of everything.
  • It’s then an easy process to run the Pi-Hole installation command found on the projects home page
  • I have a PoE switch and was hoping to use that to power the  Pi instead of having an additional power supplies & cables running everywhere. I found this handy PoE splitter that provides the necessary power to the Pi. It’s working like a charm!
  • I was also interested in having a display on the Pi, so I bought a pair of these TFT displays and these enclosures that work nicely with them.
  • To get the TFT display to work you need to install the driver found in LCD-show-170703.tar.gz by following the instructions found here.
  • After the drivers are installed the Pi reboots and the display should start working.
  • To display the Pi-Hole stats I’m using the chronometer2 script.
  • To select the appropriate font size for the display:
    pi@pi-hole:~ $ sudo  dpkg-reconfigure console-setup

    • Encoding: UTF-8
    • Character Set: Guess optional character set
    • Font for the console: Terminus
    • Font size: 8×14
  • To prevent the display from going to sleep add ‘consoleblank=0’ to the end of /boot/cmdline.txt

Modifications to chronometer2

I like the basic concept of chronometer2 quite a bit, but I felt it could be improved upon slightly. For example, I don’t use my pi-hole as a DHCP server, so the few lines of the display showing it’s disabled is just wasted screen real estate as far as I’m concerned. I would much rather see the top client, top domain, and top advertiser that the original chronometer displays. I also wanted an easy way to be able to restart the chronometer2 display on my TFT display that didn’t require rebooting the whole Pi. When I’m tinkering with the chronometer2 script it’s annoying to keep rebooting the Pi and causing brief DNS outages on my network.

Given these thoughts I decided to make some tweaks to the script. Having spent years as a software developer I had one other small detail that I kept in mind – I didn’t want to change the default behavior in any way. So if you’re using the existing chronometer2 script and just drop my version into place on your pi-hole then you won’t see any difference unless/until you start playing with the new parameters I added. Without further ado, the parameters I added include:

    • -f | –format <format_string>
      This option lets you customize the display by being able to change the order of items that are displayed or even removing them. Each section of the display has been assigned an arbitrary letter. You just specify a format string in the order in which you want items displayed:

      a : Logo
      b: Pihole Information
      c: Pihole Statistics
      d: Network Details
      e: DHCP Information
      f: System Information

      The default formatting string is simply ‘abcdef’, so if you don’t specify a custom format string then chronometer2 will use this value, which means the display will look exactly like the one you’re used to. If, like me, you don’t want to display the DHCP details then you would simply include ‘-f abcdf’ on the command line, leaving ‘e’ out of the format string.

 

  • -t | –top
    This will tell chronometer2 to include the top client/domain/advertiser information in the Statistics section of the display
  • -p | –pid <filename>
    This will write the PID (process ID) of chronometer2 to the specified file, making it easy to kill the script if you ever need to.

Why include the –pid option, you might ask? Good question! As I mentioned above, I wanted a way to be able to restart chronometer2 on my TFT display without having to reboot my Pi or doing any other tricky shenanigans. Most people set up their chronometer script to run out of /etc/profile or /home/pi/.bashrc by simply adding either ‘pihole -c’ or ‘./chronometer2.sh’ to the bottom of one of those files. Here’s how I have my .bashrc set up:

if [ "$TERM" == "linux" ] ; then
 while :
 do
   /home/pi/chronometer2.sh $(cat /home/pi/chronometer2.cmdline)
   sleep 1
 done
fi

For those of you who aren’t terribly familiar with shell scripting, here’s a breakdown of what this does:

  1. chronometer2.sh is run only if the TERM environment variable is set to “linux”. This is what my Pi sets the TERM variable to when running chronometer2.sh locally on the TFT display. When I ssh into my Pi the TERM variable is set to “xterm”, so I’m not greeted by the chronometer2.sh script starting up every time I ssh into it.
  2. chronometer2.sh is run in an infinite loop (inside the while/do/done block). So if/when the script dies for any reason it will automatically restart after a one second delay.
  3. The script gets its command line arguments by reading them from the file /home/pi/chronometer2.cmdline each time it starts up.

The file /home/pi/chronometer2.cmdline looks like this:

-f abcdf -t -p /home/pi/chronometer2.pid

I also have a command called ‘killc2’ set up in my .bashrc:

alias killc2='kill $(cat /home/pi/chronometer2.pid)'

So now whenever I want to tinker with the chronometer2 script in any way I just edit the script and/or my chronometer2.cmdline file, invoke the command ‘killc2‘, and after a short pause the script restarts on the TFT display with the new parameters and any other changes I made.

My modifications to the chronometer2 script can currently be found here. If they’re merged into the official chronometer2 project I’ll update this to point there instead.

 

Indigo Plugin for SenseME Fans Reference

Disclaimer: The API for SenseME is not published by Big Ass Solutions, and this plugin is in no way supported by them.  This plugin was written by analyzing the network traffic between the SenseME iPhone app and a Haiku fan with SenseME. There is no guarantee that this plugin will continue to work if Big Ass Solutions releases new firmware/software for the fan.

The current version of the Indigo Plugin for SenseME Fans is 0.7.0

This plugin has been tested on Haiku fans running firmware version 2.5

Installation and Basic Usage

To use this plug-in simply download this ZIP file and uncompress it on the Mac where you have Indigo installed, then double-click on the SenseME.indigoPlugin file to install it in Indigo.  Once installed, simply create a new Indigo “SenseME Fan” device.  In the device settings, enter the name of the fan and its IP address, both of which can be found in the Haiku Home smartphone app. After you launch the app click on the menu icon in the upper right corner and tap on “Rooms and Devices”. The name to use in Indigo is the name as shown in this list. Tap on the fan then choose “Network Configuration” to determine the IP address assigned to the fan.

If your internet router is capable of assigning static IP addresses to devices then I strongly suggest you do this with your fan(s). Using a static IP address will ensure Indigo can re-establish communication with it if either Indigo or the fan is restarted.  You will need the MAC address of your fan to do this, and it can be found both in the Haiku Home smartphone app or in the Device Settings of the SenseMe device once Indigo has established a connection with the fan.

Once the SenseME Fan device is created simply create actions or triggers as you would for any other Indigo device. A summary of actions and triggers is outlined below.

Triggers should fire in Indigo whenever a state change occurs in your fan, whether the state change is the result of an action performed by the Haiku Home app, by a SenseME infrared remote control, or even if a person simply enters/exits the room (triggering the fan’s motion detector).

State Value

When a SenseME fan device is enabled in Indigo the “State” column in the device display of the Indigo client will show a summary of the current state of the fan. The default value of the display is in the format of “fan_mode / light_mode“, where each mode is either “on” or “off”.

When debugging is enabled in the SenseME Fan plugin settings then the “State” column will show more detail in the format of “fan_mode / light_mode (f:fan_level, l:light_level)”.

Triggers

  • Fan (values: On/Off)
    Triggered any time the fan is turned on or off.
  • Light (values: On/Off)
    Triggered any time the optional light is turned on or off.
  • Speed (values: 0-7)
    Triggered any time the speed of the fan changes.
  • Brightness (values: 0-16)
    Triggered any time the brightness of the optional light changes.
  • Fan Motion Sensor (values: On/Off)
    Triggered when the motion sensor is enabled or disabled for the fan.
  • Light Motion Sensor (values: On/Off)
    Triggered when the motion sensor is enabled or disabled for the optional light.
  • Status String (value: string)
    Triggered any time the state of the fan changes. The string returned in this trigger matches the value shown in the “State” column of Indigo when viewing the device. See the above description of the State value for possible values of this string.
  • Smart Mode (values: ‘COOLING’, ‘HEATING’, or ‘OFF’)
    Triggered any time the Smart Mode of the fan is changed between Smarter Heating, Smaller Cooling, or Off.
  • Motion Detected (values: On/Off)
    Triggered any time the fans motion detector detects motion in the room or after the motion detector determines no motion has been detected for a period of time.
  • Whoosh (values: On/Off)
    Triggered whenever Whoosh Mode is turned on or off.
  • Sleep Mode (values: On/Off) (added v 0.7.0)
    Triggered whenever Sleep Mode is enabled or disabled on the fan.
  • Cooling Ideal Temperature (added v 0.7.0)
    Triggered any time the ideal temperature associated with Smarter Cooling changes.
  • Sleep Ideal Temperature (added v 0.7.0)
    Triggered any time the ideal temperature associated with Sleep Mode changes.
  • Indicators (values: On/Off) (added v 0.7.0)
    Triggered when the setting to enable or disable the LED indicators on the fan changes. When enabled the LED indicators flash whenever a command is received.
  • Beep (values: On/Off) (added v 0.7.0)
    Triggered when the setting to enable or disable beeping changes. When enabled the fan will beep whenever a command is received.
  • Direction, Direction Changed to Forward/Reverse (added v 0.7.0)
    There are three individual direction triggers. The Direction trigger is triggered any time the direction changes, whether forward or reverse. The Direction Changed to Forward and Direction Changed to Reverse triggers are triggered only when the direction is changed to the specified direction.

NOTE: It is possible for what you would expect to be a single event to actually trigger multiple triggers. For example, if you turn your fan on with the Haiku Home smartphone app then the Indigo plugin might trigger both the Fan trigger and the Speed trigger. This is because the fan will respond with multiple events, and the plugin will respond to each event where the state changes.

Actions

  • Turn Fan On, Turn Fan Off
    Turns the fan on or off.
  • Adjust Fan Speed
    Sets the speed of the fan. Valid values are 0-7. If the fan is currently off and the speed is set to a non-zero value then the fan will turn on. If the fan is on and the speed is set to 0 then the fan will turn off.
  • Turn Fan Light On, Turn Fan Light Off
    Turns the optional light, if installed, on or off.
  • Adjust Fan Light Brightness
    Sets the brightness of the optional light. Valid values are 0-16. If the light is currently off and the level is set to a non-zero value then the light will turn on. If the light is on and the brightness is set to 0 then the fan will turn off.
  • Turn Fan Motion Sensor On, Turn Fan Motion Sensor Off
    Enables or disables the motion sensor for the fan. When enabled the fan will automatically turn on or off based on whether the fan has detected motion in the room.
  • Turn Light Motion Sensor On, Turn Light Motion Sensor Off
    Enables or disables the motion sensor for the light. When enabled the light will automatically turn on or off based on whether the fan has detected motion in the room.
  • Send raw SenseME Command
    Use this action with caution. It will allow you to send any command you want to your fan. You must be familiar with the format of commands that the SenseME fan recognizes in order to use this properly.
  • Enable Smarter Heating, Enable Smarter Cooling
    Turns on either the Smarter Heating or Smarter Cooling features of the SenseME fan.
  • Disable Fan Smart Mode
    Turns off Smart Mode, disabling both Smarter Heating and Smarter Cooling.
  • Adjust Fan Smart Mode Min Speed
    Adjusts the minimum speed of the fan when Smart Mode is enabled. Valid values are 0-6. A value of 0 disables the minimum speed setting.
  • Adjust Fan Smart Mode Max Speed
    Adjusts the maximum speed of the fan when Smart Mode is enabled. Valid values are 1-7. A value of 7 disables the maximum speed setting.
  • Turn Fan Whoosh Mode On, Turn Fan Whoosh Mode Off
    Turns Whoosh Mode on or off. If Whoosh mode is turned on and the fan is off then the fan will turn on.
  • Set Fan Direction Forward, Set Fan Direction Reverse (added v 0.7.0)
    Changes the direction of the fan. These actions can only be applied when the fan is not running (speed is 0). Note that the fan manufacturer does not recommend using this action and instead recommends simply using a slower fan speed during the winter.
  • Set Fan Indicators On, Set Fan Indicators Off (added v 0.7.0)
    Enables or disables the fans LED indicators. When enabled the LEDs will flash each time a command is received.
  • Set Fan Beep On, Set Fan Beep Off (added v 0.7.0)
    Enables or disables the fans beep indicator. When enabled the fan will beep each time a command is received.
  • Turn Fan Sleep Mode On, Turn Fan Sleep Mode Off (added v 0.7.0)
    Enables or Disables Sleep Mode.
  • Adjust Fan Smart Sleep Ideal Temperature (added v 0.7.0)
    Adjusts the ideal temperature setting for Smart Sleep mode. Temperature units (Fahrenheit/Celsius) are set in the device settings. Fahrenheit values should be integers between 50 and 90. Celsius values should be in half degree increments between 10 and 32.
  • Adjust Fan Smart Cooling Ideal Temperature (added v 0.7.0)
    Adjusts the ideal temperature setting for Smarter Cooling mode. Temperature units (Fahrenheit/Celsius) are set in the device settings. Fahrenheit values should be integers between 50 and 90. Celsius values should be in half degree increments between 10 and 32.

Indigo Plugin for Haiku Fans with SenseME v 0.3

Version 0.3 of the Indigo plugin is now available.  This version mostly improves the internal handling of events from the fan, and also adds both state and address information to the Devices display in the Indigo GUI.

Download the plugin here.

If you have any questions, comments, suggestions, etc. please post them to the Indigo plugin forum.

Indigo Plugin for Haiku Fans with SenseME v 0.1

The Indigo Plugin for Haiku Fans with SenseME provides the ability to remotely control fans from Big Ass Solutions from within Indigo software. Currently the plugin is limited to support the following functionality:

  • Turn the fan on/off and adjust the fan speed
  • Turn the optional light, if installed, on/off and adjust its brightness
  • Turn the fan motion sensor on/off
  • Turn the light motion sensor on/off
  • Trigger actions based on changes to any of the above states

Disclaimer: The API for SenseME is not published by Big Ass Solutions, and this plugin is in no way supported by them.  This plugin was written by analyzing the network traffic between the SenseME iPhone app and a Haiku fan with SenseME. There is no guarantee that this plugin will continue to work if Big Ass Solutions releases new firmware/software for the fan.

To use this plug-in simply download this ZIP file and uncompress it, then double-click on the SenseME.indigoPlugin file to install it in Indigo.  Once installed, simply create a new Indigo “SenseME Fan” device.  In the device settings, enter the name of the fan and its IP address, both of which can be found in the SenseME smartphone app.

Once the SenseME Fan device is created simply create actions or triggers as you would for any other Indigo device.

If you are interested in learning more about the SenseME API for communicating with the fan then see this post. The source code for the plugin is also hosted on github.