To Be or Not ecobee…

There’s no question here

To the uninitiated, the ecobee is a cloud-first smart thermostat that utilizes remote sensors to attempt to optimize your home’s temperature based on room occupancy. A novel idea, especially if your thermostat is located near warm windows or the front door like ours, but I believe we can do a whole lot better!

Taking a Look at Ecobee

First, let’s discuss the initial cost you will incur before you even get the system installed. These things are fairly pricey – around $250 for the thermostat and one sensor – and it gets more expensive if you have a lot of rooms. Assuming you want sensors in your bedroom, living room, office, kids’ rooms, dining room and family room, you’re looking at $500 to ensure comfort in any room of your home.

Alright, you just dropped a good chunk of change on your brand new smart climate control, time to install it! Do you have an older home like we do? You’re HVAC system probably does not include a C-wire – not to worry, the system comes with a power-extender kit, which only requires a little rewiring inside your furnace control panel. Assuming you haven’t electrocuted yourself, the main unit is now mounted on the wall where your old thermostat was – unless you decided to go all-out and run wires to a new more optimum location (hope you have some fish tape…).

You’re not done yet, it’s time to place the remote sensors around your house. Make sure to choose locations such that the sensor can see the room, won’t be artificially affected by sun through windows and, most importantly, receive fairly consistent motion when the room is occupied. Why? Well, unlike occupancy sensors – which can detect if a person is in the room regardless of motion, these remote sensors rely on a motion-timeout mechanism; basically, if the sensor will only report occupancy if it detects motion within a certain timeframe. You might want to rethink putting that sensor where you primarily watch movies or television, if your comfort settings are not set correctly, 2 hours into your 15th viewing of Avatar it may just switch to away mode.

Finally, your system is installed, set up and keeping your house comfortable – but this wouldn’t be a very smart thermostat if it didn’t prepare your home for optimum comfort on your way home, now would it? Well, it’s a good thing the companion app utilizes geofencing to preemptively switch to home mode on your way back from 4 hour trip to IKEA! Let’s just hope you live alone or always travel with your family, since this feature is limited to one user without the help of 3rd party applications like Life,360 or AFAIK.

If a Company like Ecobee Has These Issues, What Can I Do?

Problem 1: Cost

This is an easy one, go to Amazon and look for a thermostat that integrates with your home’s smart protocols – Zigbee, Z-Wave, Thread/Bluetooth, Wi-Fi – you’ll find thousands of options. Make sure to read the reviews and find a quality thermostat, we have a GoControl GC-TBZ48 which I found on Amazon a few years ago for around $115 but seems to run about $150 now. Don’t forget eBay, you can find used or near-new units even cheaper.

Problem 2: Installation/No C-Wire

If you have no C-Wire, there are plenty of battery-powered options to avoid scary electrical work out there as well. The unit linked above can operate off of the 24VAC transformer in your furnace, as well as the 6V provided by 4 AA batteries included with the unit.

Problem 3: Remote Sensor Cost

Like Problem 1, you’ll find a plethora of options for temperature and motion sensors for whatever protocols your home uses on Amazon. If you have a lot of Philips Hue products, the Hue Motion Sensor provides motion and temperature readings and can be found cheap on eBay. If your protocol of choice is Z-Wave, I recommend Aeotec make reliable devices that are highly configurable, including 3 and 6 sensor devices – however, they cost about as much as the ecobee remote sensors, so check out Monoprice for white-label Z-Wave devices to save some cash. If you look around, you’ll find a decent device that fits your price point.

Problem 4: Lack of Motion

Unfortunately, there’s no universal solution to solving the lack of motion issue; there are, however, plenty of DIY solutions. A simple solution: the Aeotec sensors have configurable sensitivity, reporting thresholds, alert timeout and motion time out settings – adjusting these can virtually eliminate the lack of motion issue. Serious DIYers might look into using Time-of-Flight sensors to keep track of people entering and exiting a room, similar to this Instructables project. For a fool-proof method, some cheap webcams, or even Raspberry Pi 0 Ws with camera modules, and TensorFlow or OpenCV can literally detect people and faces if you don’t mind installing cameras around your house – and facilitate a future project I’d like to take on to pause/play the movie based on the number of faces/people changing in the room.

Problem 5: Geofencing

The single-user geofencing “feature” of ecobee is a non-issue to most home automators. I’m going to assume you either have GPS tracking set up if not, checkout Home-Assistant + Companion Mobile App with zones and proximity, it’s fairly user friendly and has most of this built in.

Let’s See How a We Can Do Better

Following Agile practices, let’s create some feature stories, a feature story usually includes a title, statement of intent, acceptance criteria list and possibly stretch goals. Below are some cards describing the features I would like to implement in our comfort system

Comfort on Demand

As a smart-home owner
I would like the house to be comfortable when I get home
so that I do not have to wait be comfortable

Acceptance Criteria

  • Home mode is set when a family member is within a certain radius from home and traveling towards home
  • Do nothing if someone is home and climate is set to home mode
  • Return climate to away mode if family member leaves the radius or travels away from home

Stretch Goal ACs

  • Set home mode based one calendar event end time and ETA from event to home

Sensor Calibration

As a smart-home owner
I would like to adjust the sensor readings for calibration or offset
so that temperature readings are reliable

Acceptance Criteria

  • Sensor readings are offset by a specified calibration value

Stretch Goal ACs

  • Adjust offset based on sun or detected light levels

Room Priority Ranking

As a smart-home owner
I would like areas to be ranked by traffic levels
so that high-traffic areas have a greater impact than low-traffic areas

Acceptance Criteria

  • Sensors have a base weight used for averaging
  • Sensors have an adjusted weight when an area is triggered for averaging

Stretch Goal ACs

  • Adjust weights based on historical traffic data

Personalized Comfort

As a smart-home owner
I would like the climate adjust based on the preferences of guests
so that my guests are more comfortable

Acceptance Criteria

  • Guests can specify a preferred temperature or fan settings
  • Climate adjusts when a guest with preferred climate settings arrives
  • Climate reverts back when guest with preferred climate settings departs

Stretch Goal ACs

  • When multiple preferred climate guests are present, climate adjustments are averaged if needed

Climate on Demand

You may have guessed, but we run Home-Assistant, amongst other projects, in our home. Robbie Trencheny created a wonderful mobile application for iOS that has grown and been forked for Android systems. Using some of the native integrations we can easily create a ruleset to achieve our goal of arriving home to a comfortable client.

To follow in our footsteps, you’ll need to have Home-Assistant setup and running with the following integrations configured:

  • mobile_app – This allows the Companion Mobile App to communicate with the Home-Assistant server
  • person – Create a person entity for each person you which to track and tie it to the device_tracker added via mobile_app with succinct names like “Dad” or “Mom”
  • zone – You will want to set up a “Thermostat” zone with a decent radius to act as the threshold for determining if a user is heading home or not
  • proximity – Set up a proxy entity for each person you wish to determine the proximity to zone.home, using a naming convention such as “Home Dad” or “Home Mom”
  • group – Create a group entity that contains all of the person entities above
  • climate – The appropriate integration for your smart thermostat

Here is a very basic example configuration file to get you going, add the appropriate configuration for your thermostat for your home:

## configuration.yaml
...

mobile_app:

person:
  - name: Dad
    id: dad123
    device_trackers:
      - device_tracker.dad
  - name: Mom
    id: mom321
    device_trackers:
      - device_tracker.mom

group:
  family:
    name: Family
    entities:
      - person.dad
      - person.mom

zone:
  - name: Thermostat
    latitude: !secret latitude_home
    longitude: !secret longitude_home
    radius: 1700  # Just over a mile
    icon: mdi:thermostat

proximity:
  home_dad:
    zone: home
    devices:
      - person.dad
    tolerance: 50
    unit_of_measurement: mi
  home_mom:
    zone: home
    devices:
      - person.mom
    tolerance: 50
    unit_of_measurement: mi
    
automation: !include_dir_list automations
# automations/prepare_climate_home.yaml
# This assumes your thermostat supports preset modes, if not adjust service call appropriately, i.e. climate.set_temperature
name: Prepare Climate Home Mode
trigger:
# Trigger automation when Mom or Dad enter the Thermostat Zone
  - platform: zone
    entity_id:
      - person.mom
      - person.dad
    zone: zone.thermostat
    event: enter
condition:
# Only run automation if no one is home and the person that triggered the 
# automation is heading towards from Home
  - condition: not
    conditions:
      - condition: state
        entity_id: group.family
        state: home
  - condition: template
    value_template: "{{ is_state_attr('proximity.home_' + (states.person | selectattr('entity_id', 'eq', trigger.entity_id) | map(attribute='entity_id') | map('replace', 'person.', '') | list | first), 'dir_of_travel', 'towards') }}"
  - condition: state
    entity_id: "{{ trigger.entity_id }}"
    state: "Thermostat"
action:
# Set the thermostat to home mode
  - service: climate.set_preset_mode
    data:
      entity_id: climate.thermostat
      preset_mode: home
# automations/prepare_climate_away.yaml
# This assumes your thermostat supports preset modes, if not adjust service call appropriately, i.e. climate.set_temperature
name: Prepare Climate Away Mode
trigger:
# Trigger automation when Mom or Dad leave the Thermostat Zone
  - platform: zone
    entity_id:
      - person.mom
      - person.dad
    zone: zone.thermostat
    event: leave
condition:
# Only run automation if no one is home and the person that triggered the 
# automation is heading away from Home
  - condition: state
    entity_id: group.family
    state: home
  - condition: template
    value_template: "{{ is_state_attr('proximity.home_' + (states.person | selectattr('entity_id', 'eq', trigger.entity_id) | map(attribute='entity_id') | map('replace', 'person.', '') | list | first), 'dir_of_travel', 'away_from') }}"
  - condition: state
    entity_id: "{{ trigger.entity_id }}"
    state: "not_home"
action:
# Set the thermostat to away mode
  - service: climate.set_preset_mode
    data:
      entity_id: climate.thermostat
      preset_mode: away

Summarizing the Configuration Above

The first automation will set the home mode if a user enters the Thermostat radius and direction of travel is towards home, as long as no one is home already.

The second automation will set the away mode if a user leaves the Thermostat radius and direction of travel is away from home, as long as no one is home still.

Definition of Done

  • ✓ : Home mode is set when a family member is within a certain radius from home and traveling towards home
  • ✓ : Do nothing if someone is home and climate is set to home mode
  • ✓ : Return climate to away mode if family member leaves the radius or travels away from home

Sensor Calibration

# sensors/temperature_calibrations
sensor:
  - platform: template
    # Creates a sensor that is always 1 degree lower than what the kitchen temperature report
    kitchen_calibrated_temperature:
       name: Calibrated Kitchen Temperature
       value_template: "{{ (states.sensor.kitchen_temperature.state | int) - 1 }}
       icon: mdi:thermometer
       unit_of_measurement: "\u2109"
       device_class: temperature
   ...

Summarizing the Configuration Above

By utilizing the template sensor, you are able to apply any transformation to the reported sensor values you wish. In the example above, it is creating a new sensor that will always be 1 degree lower than the device’s reported temperature.

Definition of Done

  • ✓ : Sensor readings are offset by a specified calibration value

Room/Area Ranked Priority

Using a simple weighted-average algorithm fulfills this requirement. Each room or temperature sensor can have a default weight, as wells a triggered weight; the triggered weight will be used when the occupancy/motion sensor associated with this temperature reading detects motion. You can accomplish this with the Template Sensor integration, or you can utilize something like AppDaemon and use Python to calculate this.

# sensors/temperature_ranking
platform: template
sensors:
  thermostat_internal_offset:
     name: Thermostat Internal Offset
     value_template: "{{ climate.thermostat.attributes.offset }}"
     icon: mdi:thermometer-plus
     unit_of_measurement: "\u2109"
     device_class: temperature
  thermostat_actual_temperature:
     name: Thermostat Internal Offset
     value_template: "{{ (states('sensor.thermostat_temperature') | float) - (states('sensor.thermostat_internal_offset') | float) }}"
     icon: mdi:thermometer-lines
     unit_of_measurement: "\u2109"
     device_class: temperature
  average_temperature:
   name: Average Home Temperature
   value_template: |
     {%- set weights = 
       {
         "sensor.kitchen_temperature": {
           "weight": 0.8
           "triggered_weight": 1.2
           "triggered_by: {
             "entity_id": "binary_sensor.kitchen_motion"
             "state": "on"
           }
         },
         "sensor.living_room_temperature: {
           "weight": 1.0,
           "triggered_weight": 2.1
           "triggered_by: {
             "entity_id": "binary_sensor.living_room_motion"
             "state": "on"
           }
         },
         ... # Add all sensors and their weight data here
       } -%}
       {%- set ns = namespace(temperature=0.0, total_weight=0.0) -%}
       {%- for sensor, weight_data in weights.items() -%}
         {%- if 'triggered_weight' in weight_data and 'triggered_by' in weight_data and is_state(weight_data['triggered_by']['entity_id'], weight_data['triggered_by']['state'])  -%}
           {%- set ns.temperature = ns.temperature + (states(sensor) | float) * (weight_data['triggered_weight'] | float) -%}
           {%- set ns.total_weight = ns.total_weight + (weight_data['triggered_weight'] | float) -%}
         {%- else -%}
           {%- set ns.temperature = ns.temperature + (states(sensor) | float) * (weight_data['weight'] | float) -%}
           {%- set ns.total_weight = ns.total_weight + (weight_data['weight'] | float) -%}
         {%- endif -%}
       {%- endfor -%}
       {{ None if ns.total_weight == 0.0 else (ns.temperature / ns.total_weight) }}
     icon: mdi:thermometer
     unit_of_measurement: "\u2109"
     device_class: temperature
# automations/thermostat_offset.yaml
name: Set Thermostat Internal Offset
trigger:
  - platform: state
    entity_id: sensor.average_temperature
action:
  - service: mqtt.publish
    data:
      topic: "OpenZWave/1/command/setvalue/"
      payload_template: '{ "ValueIDKey": 12345, "Value": {{ ((states('sensor.average_temperature') | float )
                               - (states('sensor.thermostat_actual_temperature') | float)) | round('half') }} }'

Summarizing the Configuration Above

First, we define some Template Sensors to facilitate the arithmetic and automations that follow. Since our automation will adjust the internal offset of the thermostat so that the reported temperature of the thermostat is actually the weighted average temperature, we need to know what the “actual” thermostat temperature is without the offset applied and, for ease of use, what the thermostat’s current offset is. Now that we have these two sensors (sensor.thermostat_internal_offset, sensor.thermostat_actual_temperature), we can use the values of these entities to calculate what the offset should be every time the average temperature sensor changes. Now, it doesn’t really matter where in your house the thermostat is mounted, because the temperature it’s reporting is ignored and, effectively, replaced with what we have calculated to be the temperature in the house based on occupancy and weights (or “rank” if you prefer).

Definition of Done

  • ✓ : Sensors have a base weight used for averaging
  • ✓ : Sensors have an adjusted weight when an area is triggered for averaging

Personalized Comfort

If you are like us, you want your friends and guests to be comfortable in your home – or maybe your significant other prefers the house a little cooler than you do. Personalized comfort allows you to accommodate some of the common requests you may receive, such as:

  • “I run hot, can we kick the AC up a bit?”
  • “It’s stuffy in here, is it ok if I turn on the fan?”
  • “I prefer natural light, would you mind if I opened the blinds?”
# customization.yaml
person.bob:
  target_temp: 72
person.jim
  fan_speed: low
person.annie
  window_coverings: open
# automations/personal_comfort.yaml
name: Personal Comfort Settings
trigger:
  - platform: state
    entity_id:
      - person.bob
      - person.jim
      - person.annie
action:
  - choose:
    - conditions:
      - condition: template
        value_template: >-
          {{ state_attr(trigger.entity_id, "target_temp") != None }}
        sequence:
          - service: climate.set_temperature
            data:
              entity_id: climate.thermostat
              temperature: "{{ (states.input_number.target_temperature.state | int) if is_state(trigger.entity_id, "not_home") else (state_attr(trigger.entity_id, "target_temp") | int) }}"
    - condition: template
        value_template: >-
          {{ state_attr(trigger.entity_id, "fan_speed") != None }}
        sequence:
          - service: fan.set_speed
            data:
              entity_id:
                - fan.living_room
                - fan.guest_room
              # Not bothering to reset when they leave
              speed: "{{ state_attr(trigger.entity_id, "fan_speed") | int }}"
    - condition: template
        value_template: >-
          {{ state_attr(trigger.entity_id, "window_coverings") != None }}
        sequence:
          - service: "cover.{{ 'close' if is_state(trigger.entity_id, 'not_home') else state_attr(trigger.entity_id, "window_coverings") }}_cover
            data:
              entity_id:
                - cover.living_room_blinds
                - cover.family_room_blinds
    default: []

Summarizing the Configuration Above

The example presented is fairly basic, covering only one preference per person. If the guest has a temperature preference it will adjust the thermostat, if the guest has a preference on air circulation it will adjust the specified fans to meet their request, if they have a preference for the blinds to be open it will open the specified blinds. When they leave, it returns to original state.

Definition of Done

  • ✓ : Guests can specify a preferred temperature or fan settings
  • ✓ : Climate adjusts when a guest with preferred climate settings arrives
  • ✓ : Climate reverts back when guest with preferred climate settings departs

Stretch Goals

If you like the ideas presented in the cards above under stretch goals, or can think of other improvements over the ecobee, I challenge you to implement your solution and share it with the world!

Let There Be Light! Comfort Color Lighting…

As you read through this post, watch the videos, see what all we’ve done – it’s only natural to ask “Jeez, how much did this cost?” Well, let me answer that now so we can focus on the content: you do not want to know. Links below seem to break on the regular, find the videos and more here: https://www.icloud.com/sharedalbum/#B1A59UlCq1m3Dr

HEADS UP: If you use “Hey Siri” in your home, you may want to turn the volume down before playing the videos below, and on a personal note: James, fuck you and your phrases used in https://saladbowl.fun

Introducing: Comfort Color Lighting, Automated

As you know, or should by now, I put a lot of pride into being efficiently lazy: automating repetitive tasks, communication, and my life to an extent some might consider insane (I prefer eccentric, potato-potato). About a year ago, my partner/boyfriend/fiancé, let’s call him Alan, and I stayed a weekend at our good friend’s who recently started adding Philips Hue lighting to his house; this weekend with friends sparked something deep in Alan’s soul, turning to me “I need this in my life” – and thus began our journey to not just be more comfortable in our home, but to turn our home into our sanctuary, into an immersive experience of unto which we could not have imagined possible at the time.

I’ll be the first to admit, I never really thought much of color – sure I have a preference for dark themed user interfaces just like any sane software engineer, selecting the “Darcula” radio button is enough for me; automating my lights simply meant replacing the light switches with smart ones. When I introduced Alan to Pycharm as an alternative to Sublime, he was blown away by the Ansible/YAML plugins and extensions that he instantly dropped Sublime as his editor of choice – and spent the next day or two tweaking the color schemes, asking my opinion between two indiscernible grays looked best as the editor background.

Side note, his need for perfect color schemes in his life seemed like a waste of time to me at first, but I have truly grown to appreciate how the varying tones in color can really affect you – I still can’t bring myself to spend the time to tweak my editor colors so I simply use the themes he lovingly creates from scratch.

Understanding Alan’s affinity for color and its effects on mood and focus, we can now appreciate the super-human patience and effort that he has put in; turning our house into a home, our living room into an immersive theatre better than any AMC or Alamo, and practically removing the need for an alarm to wake up in the morning – all through the use of comfort color lighting.

Energy, Mood and Adaptive Lighting

For the uninitiated, adaptive lighting is an algorithm that brings the awe of the sun rising, the beauty of a wonderful setting sun, the tranquility of a clear night sky into your home through the color and temperature of lights in your home. As the day starts, gentle and beautiful sunrises throughout our home – slowly transitioning from a comfortable, yet dim, twilight to a beautiful sky blue and hints of orange – awakened every day to the artificially created beauty of nature, regardless of what the weather is outside these walls. As the day rolls on, and the sun starts to set, the sky blue darkens, the hints of orange now prominent, the tint of red as the sun’s rays pass over the atmospheric scattering effect so prominent during the day. Soon, below the horizon, twilight starts to set in – the sky a dark backdrop sprinkled with fuchsia from the few photon particles that pass tangentially over our planet as the sun sinks deeper and deeper. With gratitude for his lighting work, I rarely wake In the mornings grumbling anymore, instead, the comfort color lighting makes me feel inspired and energized – though that still doesn’t seem to curb my intake of caffeine, that’s a whole other thing.

Time of Day Comfort Lighting Scenes

Enter Your Favorite Movie, No VR Headset Required

We all seem to have that person in our life: the self-proclaimed audiophile who can’t stand for anything less than 7.2 Atmos surround, the purist nitpicking digital artifacts due to compressed video streams, those who scoff at televisions that don’t upscale to the point of being able to see every pore on an actor’s face. Well, we are those people, and then some. Before the world shut down in response to an invasion from microscopic organisms hell-bent on world domination, most people went to movie theaters to get a taste of immersive sound and visuals – and spend $10 on a bag of Skittles. Let me introduce you to the Philips Hue Sync Box, one of the most amazing devices to enter the home entertainment market, and one of the worst smart devices ever made. When it comes to being a smart device, it’s the equivalent of the most intelligent goldfish at Petsmart – the app is slow, has wireless connection issues and requires a dedicated Hue Hub for each Sync Box in your home. Thankfully, the REST API served on the device is responsive and intuitive – a great addition to your home automation system. If it’s one of the worst smart devices ever made, how can it be such an amazing home entertainment device? Good question. Simply wire your set-top boxes to any of the 4 HDMI inputs on the Sync Box and the output to your stereo or television – and now up to 10 Hue (or Hue Compatible) lights synchronize with the image displayed on your television, or create a visualizer for music. Not long ago, the light strips by Philips Hue could only be set to one color for the whole strip – but now you can get a Gradient Light Strip sized for your television…. words cannot compete with seeing it in action:

Video Mode with Mad Max
Fury Road Dust Storm Battle
Video Mode with Rango
Crossing the Road with Rango
Video Mode with Music and Visualizer
This is the Game Room with a Hue Play Gradient Light Strip
Music Mode with Music
Opiuo canceled their 2020 show, experience it in your living room

Setting the Mood

Check back later for mood lighting and scenes!

But Wait, There’s More!

Here’s the lighting we use around our house

  • Living Room
    • TV Backlight: Hue Gradient Light Strip
    • Under TV: Hue Light Strip
    • Couch Light: Hue Light Strip + Extension
    • Behind Speakers: Hue Play Bars
    • Ceiling Fan: Hue Ambiance Bulbs
  • Game Room
    • TV Backlight: Hue Gradient Light Strip
    • Closet: Hue Light Strip + Extension
    • Ceiling Light: Insteon On/Off Switch
  • Entry Room
    • Mantel: Hue Light Strip
    • Floor Lamp: Hue Color Bulbs
  • Kitchen
    • Hall Light: Hue Play Bar
    • Ceiling Light: Insteon On/Off Switch
  • Dining Room
    • Ceiling Fan: Hue Ambiance Bulbs
  • Hallways:
    • Ceiling Light: Hue Being Ambiance Fixture
  • Bathrooms:
    • Vanity: Hue Ambiance Bulbs
    • Ceiling: Hue Ambiance Bulbs
  • Bedroom
    • TV Accents: Hue Play Bars
    • Headboard Accents: Hue Play Bars
    • Ceiling Fan: Hue Ambiance Bulbs
  • Dance Studio
    • Nanoleaf Panels
  • Exterior
    • Wall Sconces: Hue Appear Ambiance Fixtures
    • Walkway: Hue Calla Ambiance Fixtures

Keep up to date as we add lighting, scenes, and effects to our home: https://www.icloud.com/sharedalbum/#B1A59UlCq1m3Dr

Unsung Heroes of Forums

Here’s to those who provide closure

I don’t even need to ask if you’ve been there, I know you have, we all have. So, let’s take a moment and give thanks to those amazing human beings that, even though they solved their own issue, took the time to provide the solution and especially those who can explain how they arrived there! We solute you: the Heroes of Forums!

Our Complete Network Overhaul

We had been having issues with our network: some spotty WiFi, laggy connections, etc. When the ethernet cable that runs from the server rack, around the basement, through the office ceiling, around the living room baseboard to the 8-port switch under our television – providing the oh-so-necessary bandwidth for 150Mbps of uncompressed mindblowing video and 7.2 Atmos surround sound – had an embolism. Yes, the ethernet cord just croaked. We tested the wall jacks, replaced them, tested the terminal ends, tried new last-mile cables… the cable tester showed a short between pins 1 and 2, confirmed with the multimeter. This is not a cable you can replace with a fish tape – disappearing into finished ceilings, running through walls. Let’s just say, we were pretty pissed.

We had new network gear sitting around for about a month now, procrastinating the installation as we knew it was going to be frustration, or at minimum a full day’s undertaking. With the network issues and our most precious of Cat6 runs dead, there really wasn’t much excuse not to. So, yesterday, we yanked the EdgeSwitch 48, EdgeSwitch 16 POE, the pFSense box, the who-knows-how-old dell connect switch, and similarly aged Linksys switch and racked up our new UniFi Switch 48, UniFi Switch 24, UniFi Switch 8 POEs, and the neat (in theory) UniFi Dream Machine Pro. While my partner was running the new Cat6 cables in the cabinet, I set to running 1/2″ raceway from the server rack out to the living room on the ceiling so we can get our 4K fix – when I hear cursing from the basement.

Turns out one of our storage nodes decided to report degraded disks. I’m not 100% sure on what the issue is or how he resolved it – I know very little of CephFS and didn’t want to distract from his repair work. So I cleaned up a bit around the house until the issue was resolved… but wouldn’t you know it – yeah, yesterday was a game of whack-a-mole-tech-problems – now that the storage array was back online, none of the machines could mount the volumes. Exhausted, pissed, frustrated, and pretty much falling asleep – he decides to give up for the night and wants to watch a movie. After mixing up some delicious Moscow Mules, he passes out 4 minutes into the movie but I’m wide awake.

Enter Teagan, P.I.

There were a million possible causes for the volumes failing to mount. My first hunch was the firewall, though before he gave up my partner listed numerous networking services (that I’d never heard of before) that the UniFi Dream Machine might be blocking. Our storage array consists of 4 nodes, 3 of which are fairly new, 12 bay, 16 core beasts but the other one, the same one that reported errors earlier, is a tiny little 1U box that is attached via SAS to a dumb disk shelf (CEPH01) – in fact, it only has 2Gbps ethernet while the others have 4 Gbps. Knowing this is important to understanding the first hypothesis: journalctl reported connecting to CEPH02 but losing connection and attempting CEPH01 followed by the connection timing out completely. Seems reasonable to assume CEPH01 was causing the timeout. So, I did the cabling, redid the LAGG assignments on the switches, reset the router – nothing.

Ok, so having little knowledge of CephFS – I needed to know what might be causing timeouts when mounting the remote volumes. To the Google! Here’s the thing though: the UniFi Dream Machine is fairly new, CephFS is a little niche, and combining the two? Forget it! From around 5am to almost 9am I searched for something, anything! Sure I got a few hits that seemed possible – but ended up going down rabbit holes. Then, at 8:48am (had to check my browser history), I stumble onto this post:

https://forum.proxmox.com/threads/laggy-ceph-status-and-got-timeout-in-proxmox-gui.50118

ftrojahn‘s description sounded nearly identical – except his stack is different; ProxMox not too long ago added native CephFS support to their software – if you want some experience with a decent piece of virtualization software and enterprise-level storage solution I would definitely recommend you check it out. ftrojahn not only explained the setup, issues, and attempts to diagnose the cause very well, did what few out there dare (care):

The Heroes We Need, and Deserve

It was an issue with mismatched MTU size! Do you know why this never crossed my mind? Because of this little toggle right here on the UDMPRO’s web interface:

Forum Heroes Light the Path - Mismatched Jumbo Frames caused by a toggle switch
Jumbo Frames traditionally set MTU to 9000

First, why do we care about MTU size – the default for most systems is 1500. By increasing the size of the frames, we reduce the number of packets being sent over the wire, as well as drastically reducing the ridiculous amounts of handshakes that happen between transmit and receive (if you are unfamiliar, here’s a link describing TCP handshakes). This is especially beneficial when you have terabytes of data flying around your network 24/7 like we do.

Yes, the Y-Axis has units of GB (Yes, Gigabytes!)

Ok, so Jumbo Frames are enabled, which should be 9000 – every host on our network has the MTU set to 9000 by default. Why is there still this timeout issue?

Well, I had luckily glanced at this post many hours earlier – notice the last comment, here’s the key piece:

Unfortunately, on newer Gen 2 devices, Jumbo Frames appear to be only 8184 bytes

https://community.ui.com/questions/When-you-enable-jumbo-frames-on-UDM-Pro-what-MTU-value-is-it-setting/04ceb4ec-aa5f-434d-abb3-2a14f3f6e1ed

Now, this little tidbit seems to be missing from any of the documentation I could find, so phastier you are a hero, we deserve more heroes in forums! The final challenge came down to the question: what the fuck do I do now? I love my partner, he has taught me so much about Linux, networking, DevOps – I wanted to show him all that knowledge has not gone to waste.

Making the UDMPRO My Bitch

It was time to learn what the hell MTUs really were and if any of the options on the web interface could help me. I found one: MSS Clamping – this sets the maximum segment size for TCP packets, maybe? HAHAHA NOPE! MSS tops out at 1452 – a little shy of the necessary 9000 (minus headers). Ok… time to get my hands dirty. The web interface isn’t the only way to configure this hunk of metal; in the past, my partner has made changes via SSH that are not available via the user interface. Since this device is a router and then some, I found it had 45 network interfaces – VLANs, bridges, loops, etc. While setting the MTU I found setting the MTU for the network interface is actually fairly easy: ip link set mtu 4096 dev eth0 I wasn’t about to run that command 45 times. Thankfully, /sys/class/net has an easily parsable list of the interface names.

ls -1 /sys/class/net | while read line ; do ip link set mtu 9000 dev $line ; done

With that one line, there was peace in the world… Ok not really but I was so proud of finding this solution I just had to wake him up to share the good news…

Configuring a Raspberry Pi 3b+ as a Kiosk Display

Hindsight: I should have documented this better the first time…

When we built our magic mirror, I remember thinking: “I really should document this” but I didn’t. Today, the micro-SD card that was running the Magic Mirror died, it wouldn’t boot, we couldn’t mount it, nothing. I couldn’t even find the blog posts that I had followed when we built it originally. Hanging my head in shame all I could think of was “I fucking knew this was gonna happen”. So, learn from me, make sure you document your projects, you never know when you might need to rebuild.

Supplies

  • Raspberry Pi (version depends on your needs)
  • A display with HDMI input
  • Micro-SD card reader (for installing OS on the RPi)

Decide now: Chromium or Iceweasel?

Depending on your choice of browser, that will dictate which version of the operating system you’ll use. The current version of Rhaspian (Buster), does not support Chromium but the previous version (Stretch) does.

Chromium has an execute flag --app that will hide the address bar and border and easily provide you a full-screen experience. Iceweasel on the other hand, is a little more involved. Chromium is not currently supported in Rhaspian Buster (Debian 10), though you might be able to find some workarounds. We spent a few hours trying to image some micro-SD cards with Rhaspbian Stretch but kept running into issues with the filesystem: some would fail verification, some would have the root console locked. I decided that I just didn’t care enough to dig deeper; I went with the Raspberry Pi Imager and burned Buster to a spare micro-SD card and read up on how to use Iceweasel.

Regardless of your path, something I learned in the last few months, you can set up SSH and WPA supplicant before you even insert the card into the pi. Simply mount the boot volume of the micro-SD card on your system and run:

touch ssh

An empty file named ssh is all that is needed to enable SSH on your Raspberry Pi right from the gate! No need to dig around the basement for an old monitor and keyboard to configure, it’s remotely accessible. Speaking of remote access, write a file to the boot volume named wpa_supplicant.conf with content:

country=US # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

Replace YOUR_NETWORK_NAME with your SSID and YOUR_PASSWORD with the WiFi password for that network. Once your Raspberry Pi boots, it will automatically connect to your WiFi network and have SSH access with user pi and password raspberry. Now it’s time to configure it for your kiosk display.

First, get the preferred resolution and display modw using the tvservice command:

tvservice -d /tmp/edid_info
edidparser /tmp/edid_info | grep 'preferred mode'

This will provide you with the preferred display settings for the display connected to your Raspberry Pi. Take this information and edit /boot/config.txt:

# Always force HDMI display over DVI
hdmi_group=2
# HDMI mode as reported by the display
hdmi_mode=16

The X-Server

It’s highly recommended you create a new user for running the display as root or pi have too broad an attack vector, make sure you provide the user with a sufficiently complex password and a home directory, as it will be used by the browsers to store profile information.

adduser kiosk

Now you need access to the graphics cards, input devices, and displays in order to run your choice of browser: the X server. Install the appropriate X server for your system, along with the xinit helper package:

apt update
apt install -y xorg xinit xserver-xorg-legacy

Modify the /etc/X11/Xwrapper.config which facilitates launching the X server with or without a user with sudo privileges:

# Xwrapper.config (Debian X Window System server wrapper configuration file)
#
# This file was generated by the post-installation script of the
# xserver-xorg-legacy package using values from the debconf database.
#
# See the Xwrapper.config(5) manual page for more information.
#
# This file is automatically updated on upgrades of the xserver-xorg-legacy
# package *only* if it has not been modified since the last upgrade of that
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command as root:
#   dpkg-reconfigure xserver-xorg-legacy
needs_root_rights=yes
allowed_users=anybody

As we are building a kiosk display, we want the X server to start up without power management to prevent it from sleeping. Create a file, .xserverrc, with execute permissions in your kiosk user’s home directory:


#!/bin/sh
# Disable power management on a new X server process to prevent the display from sleeping along with ignoring tcp-based connections to it

exec /usr/bin/X -s 0 -dpms -nolisten tcp "$@"

Iceweasel Setup

Install the official iceweasel package:

apt install -y iceweasel

We will want the browser to always launch full-screen, so modify the width and height values to the values associated with the preferred display mode above and write to /home/kiosk/.mozilla/firefox/XXXXX.default-esr/xulstore.json:

{
    "chrome://browser/content/browser.xul": {
        "navigator-toolbox": {
            "iconsize": "small"
        },
        "main-window": {
            "width": "1080",
            "height": "1900",
            "screenX": "0",
            "screenY": "0",
            "sizemode": "fullscreen"
        }
    }
}

To make the browser consume all of the screen real-estate, modify the browser’s CSS /home/kiosk/.mozilla/firefox/XXXXX.default-esr/chrome/userChrome.css – create the path and file if either does not exist:


@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");


#content browser {
margin-right: -18px !important;
overflow-y: scroll;
overflow-x: hidden;
}


#content browser {
margin-bottom: -18px !important;
overflow-y: scroll;
overflow-x: hidden;
}


#content browser {
margin-left: -2px !important;
}

#content browser {
margin-top: -5px !important;
}

When the X server starts up, it will look to execute the .xsession located in the user’s home directory. This is where you will launch the browser and load the appropriate URL for your needs:

#!/bin/sh
exec /usr/bin/iceweasel --profile /home/kiosk/.mozilla/firefox/XXXXX.default-esr https://www.your.domain

Create your your_kiosk.service file in /etc/systemd/system/ and enable it via systemctl enable your_kiosk.service so that it is invoked on system startup:

[Unit]
Description=Kiosk Display
After=network-online.target
Before=multi-user.target
DefaultDependencies=no

[Service]
User=kiosk
ExecStart=/usr/bin/startx -- /usr/lib/xorg/Xorg.wrap -nocursor
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

And finally…

Make an image of your rhaspian system so you don’t have to do this again!

Raspberry Pi