Drowning In Garbage

I love the convenience of Amazon.  Time is what I have in shortest supply.  Having a stream of the things that I need or want showing up on my door step at the click of a button is enormously valuable to me.  But I am nonetheless horrified at the growing ratio of packaging to product.  And I imagine that the last mile logistics companies shifting from a small number of large deliveries (to retail stores) to a large number of small deliveries (to end-consumer homes) does not help the per-util carbon footprint.  I found myself thus despondent when I received my ostensibly eco-friendly rechargeable batteries delivered by themselves in an ungodly amount of non-biodegradable packaging this evening.  It didn’t even register on my brain that there was a recycling label on the bag before it went into the trash and I suspect that even when this stuff is theoretically recyclable the vast majority of it goes into landfills.  Ugh.

 

Analog Device Automation

I’ve got three Marpac white noise generators distributed around my bedroom.  It is a mild nuisance to have to walk around the room and switch each one’s state at the boundary of a sleep session.  And so I acquired an Aeotec “Smart Switch” for each one of them and an Aeotec “Minimote” to operate them under the yoke of my growing Home Assistant driven Z-Wave network.

I was a little bit muddled by the Minimote’s setup until I realized that you can use it either as a primary or secondary Z-Wave controller and it was the latter I wanted which entailed pressing the “Learn” button as opposed to the “Include” button when joining it to the existing network.  The other configuration was to set it to “Scene” mode vs “Group” mode, the former giving you two distinct “scenes” per button with a short and long press.

I only made one configuration change to the Smart Switches out of the box.  Specifically, I configured parameter 81, “Configure the state of the LED”, to “When the state of the Switch changes, the LED will follow the status (on/off) of its load, but the LED will turn off after 5 seconds.”  This provides useful visual telemetry without leaving you with glowing orbs in the room you’d like to be dark for sleeping.

There were some other bumps along the way…

The switches had some identity crises at the outset.  I started with node id 14, added one that became 19, and added another that became 21.  14 then disappeared and, I think, came back as 22.  Now 14, 19, and 22 seem to be the healthy ones and 21 is AWOL.  Things seem to work now, but I was a bit perplexed for a while, and not sure what exactly happened.  I would probably have to have been tracking raw device identifiers to truly understand.  Maybe I can do that forensically later.

Initially I imagined just using a single “scene” on the Minimote and invoking the “switch.toggle” service, but this was not fault tolerant, the failure mode being that if a hiccup in command distribution prevented all devices from receiving a broadcast then a subsequent toggle command would cause a subset of the switches to be on and a subset off.  Ugh.  So I’m consuming both of the “scenes” of one of the buttons to do an explicit “switch.turn_on” or “switch.turn_off” command.

Lastly, occasionally, as captured in the below video (listen closely and you hear two of the three devices switch off immediately), there is a bit of delay between button-press and response, but generally it is immediate.  This has me developing the suspicion that I am getting some network congestion. I modified configuration parameter 111, “Group 1 Interval”, to 60 for all of my MultiSensor devices to get them to submit reports every minute instead of what appeared to be an hourly out-of-the-box configuration.  Now I am getting the reports I want but possibly congestion once per minute.  Maybe I need a lower reporting frequency and some staggering?  I also note that this upped frequency sabotages having set the bedroom-located MultiSensors’ parameter 81, “LED report”, to “Disable” to prevent obnoxious blinking in response to the motion sensor, because the LED will also blink whenever it sends its period report.  UGH.  I ended up using the l337 hack of putting electrical tape over the LED in those devices.

group:
  smart_switches:
    name: "Smart Switches"
    entities:
      - switch.aeotec_zw096_smart_switch_6_switch
      - switch.aeotec_zw096_smart_switch_6_switch_2
      - switch.aeotec_zw096_smart_switch_6_switch_4
automation:
  - alias: Start White Noise
    trigger:
      platform: event
      event_type: zwave.scene_activated
      event_data:
        entity_id: zwave.aeotec_dsa03202_minimote
        scene_id: 1
    action:
      service: switch.turn_on
      entity_id: group.smart_switches
  - alias: Stop White Noise
    trigger:
      platform: event
      event_type: zwave.scene_activated
      event_data:
        entity_id: zwave.aeotec_dsa03202_minimote
        scene_id: 2
    action:
      service: switch.turn_off
      entity_id: group.smart_switches

 

Feline Loss Prevention

Bringing together a Raspberry Pi, Home Assistant, and an Aeotec ZWave Stick, Door/Window Sensor, and Siren, I’ve got the beginnings of something practical: an audio alert that will fire with escalating intensity when a door is left ajar long enough to risk a curious animal wandering out of the house.

The configuration is a little bit copy-pasta and a little bit inconsistent. I don’t yet know how much cleaner it can be with Home Assistant’s native faculties. That is a project for future Andrew. Today’s exercise was an exploration of the art of the possible.

automation:
  - alias: Rear Door Ajar Alarm Initiation
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'on'
      for:
        seconds: 5
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 5 - Low Volume"
  - alias: Rear Door Ajar Alarm Escalation
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'on'
      for:
        seconds: 10
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 4 - Low Volume"
  - alias: Rear Door Ajar Alarm Panic
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'on'
      for:
        seconds: 15
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 3 - Low Volume"
  - alias: Rear Door Ajar Alarm Termination
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'off'
    action:
      - service:   switch.turn_off
        entity_id: switch.aeotec_zw080_siren_gen5_switch
  - alias: Front Door Ajar Alarm Initiation
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor
      to: 'on'
      for:
        seconds: 10
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 5 - Low Volume"
  - alias: Front Door Ajar Alarm Escalation
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor
      to: 'on'
      for:
        seconds: 30
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 4 - Low Volume"
  - alias: Front Door Ajar Alarm Panic
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor
      to: 'on'
      for:
        seconds: 60
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   13
          parameter: 37
          value:     "Sound 3 - Low Volume"
  - alias: Front Door Ajar Alarm Termination
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor
      to: 'off'
    action:
      - service:   switch.turn_off
        entity_id: switch.aeotec_zw080_siren_gen5_switch

Moar Home Automation

cat .homeassistant/configuration.yaml

group:
  den_lights:
    name: "Den Lights"
    entities:
      - light.hue_color_lamp_16
      - light.hue_color_lamp_18
      - light.hue_color_lamp_22

automation:
  - alias: Handle Back Door Open
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'on'
    action:
      - service:    light.turn_off
        entity_id:  group.den_lights
        data:
          transition: 3
      - service: zwave.set_config_parameter
        data:
          node_id:   12
          parameter: 40
          value:     "Fade out and fade in (Red)"
  - alias: Handle Back Door Open Alarm Reset
    trigger:
      platform:  state
      entity_id: binary_sensor.aeotec_zw112_door_window_sensor_6_sensor_2
      to: 'off'
      for:
        seconds: 5
    action:
      - service: zwave.set_config_parameter
        data:
          node_id:   12
          parameter: 40
          value:     "Fade out and fade in (Green)"

Order Of Operations

I’m all for justice and equality.  But can we agree that the following is a crappy algorithm for an organization to follow?

  1. receive allegations about employee misconduct
  2. punish employee
  3. thoroughly investigate veracity of allegations

Justice delayed is justice denied, but so, too, is justice rushed.

From the Washington Post

Minnesota Public Radio said it has retained an outside law firm to conduct an “independent investigation” into the allegations [about Garrison Keillor]. The station will stop distributing and broadcasting “The Writer’s Almanac,” a show Keillor still produced after retiring from “A Prairie Home Companion.” The latter show, which will be renamed, has been hosted by Chris Thile since Keillor’s retirement.

Shouldn’t the “independent investigation” have been given time to run its course before taking such drastic and public measures?  Let us have “speedy and public trials … by … impartial jur[ies]”, not mob justice, not witch hunts.

Home Monitoring Inaugural Foray

I have for some time been obsessive about instrumenting the software systems I build professionally.  I figure I might as well bring that level of rigor to my home’s function.  A colleague suggested that I look into sensors created by AeoTec and automation orchestrated by Home Assistant.  To that end I purchased a Raspberry Pi 3 to run HA, a Z-Stick to bridge the various devices to it, a Multi Sensor 6, and a Door/Window Sensor 6.  Those devices arrived last week and I spent a little time this weekend contriving to reach a “Hello, World” level of sophistication.

The following is essentially a collection of notes on the steps required and my reactions along the way, not a meaningful synthesis which will probably require several more weekends of tinkering to reach.

After booting up Raspbian, the following got me to a basic level of function (can’t promise there aren’t some ordering or redundancy issues):

 

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install python3-pip python3-dev
  4. sudo pip3 install –upgrade virtualenv
  5. sudo apt-get install python-virtualenv
  6. virtualenv –python=/usr/bin/python3.4 $HOME/homeassistant
  7. source $HOME/homeassistant/bin/activate
  8. pip3 install –upgrade homeassistant
  9. $HOME/homeassistant/bin/hass
  10. sudo apt-get install libudev-dev
  11. reboot
  12. [unplug/replug Z-Stick]
  13. ls -ltr /dev/tty* | tail -n 1
    • crw-rw—- 1 root dialout 166, 0 Nov 25 18:16 /dev/ttyACM0
  14. vi .homeassistant/configuration.yaml
    • zwave:
      • usb_path: /dev/ttyACM0

Ultimately I was able to access the web GUI at http://localhost:8123 with USB keyboard/mouse and HDMI direct access to the Pi.

The main fiddly bit was in 12-14 where you’re figuring out the device ID of the Z-Stick and then persisting that to your HA config.  You’ll also get burned along these lines if you follow the printed instructions with the AeoTec devices which counsel you to unplug the Z-Stick as step one of putting it into “Inclusion Mode” to add devices to the network.  You actually want to be engaging “Inclusion Mode” via the HA GUI, firstly to ensure that HA acquires all information possible from the pairing process, and secondly so that the device does not pop back up under the /dev file system with a different name that does not match your config.

The Multi Sensor mostly worked out of the box with HA.  The Door/Window Sensor, however, created a fair deal of frustration.

Specifically, the latter would stay stuck in the “On” state.  The .homeassistant/OZW_Log.txt log file was somewhat elucidating of the problem in conjunction with some Googling.  Out of the box, the sensor sends a “Basic Set” event when the sensor’s state changes, but you need it to send a “Binary Sensor Report” for HA to behave as you’d expect.  Not only was figuring out the source of the trouble painful, but so was figuring out the resolution.

HomeAssistant wrote a zwcfg_0xf7a9395f.xml file that contained all of my detected devices.  Between that and a spec I found online I deduced the set_config_parameter invocation I needed to do.  Sort of.  I also had to read stack traces out of .homeassistant/home-assistant.log and do some more Googling to realize that where the docs indicated it wanted a numerical value the API actually expected what you would find in the “label” field of the ZWCFG XML.  What ultimately worked follows:

2017-11-26-174602_1824x984_scrot

The last gotcha stems from the Door/Window Sensor being a battery operated sensor as opposed to hard-wired.  This means that it spends most of its time sleeping to conserve power, waking up only when either the magnetic field changes or a scheduled time arrives.  To sync a new config immediately you’ll need to press the button on the sensor which causes it to wake immediately and perform tasks that otherwise would have waited until the next scheduled time.

The effort required to figure this out was frustrating but I was sufficiently successful this weekend that I will carry on.  I imagine acquiring a few more of each of the two sensor types and maybe some of the power flow control devices.  The next most obvious steps are to establish some triggering rules and to figure out exporting data to an off-prem cloud environment for back-up and analysis.  Oh, and I guess also playing around with the FOSCAM wireless IP camera I got, whose configuration I never reached due to bogging down on other things.

To Be Continued…

Building The Foundations Of Oppression

From the Financial Times…

The UK, France and Italy have promised to hold technology companies to account if they fail to block online terrorist or extremist content, with Emmanuel Macron, the French president, promising to “name and shame” companies that do not take robust action.

The meeting came after Mrs May and Donald Trump, the US president, discussed the need for internet companies to behave in a socially responsible way, move quickly to remove terrorist material and to stop it from appearing in the first place.

Mrs May challenged the internet companies to develop technology that would stop “evil material” appearing on the web or remove it within two hours of it appearing online. “Industry needs to go further and faster in automating the detection and removal of terrorist content online, and developing technological solutions which prevent it being uploaded in the first place,” she said.

Would this look any different, in shape if not actual configuration, from the machinery already used by totalitarian regimes to deploy pervasive and aggressive thought police against their own populations to prune “undesirable” content from the Internet?  Why should we trust all future leaders who would inherit such capabilities to use it responsibly?  How do we define what constitutes responsible use?  Why should we even trust today’s leaders when in the US they make a regular thing of demanding “apologies” for perceived insults and suppressing thought by not just butchering the funding for basic scientific research at government agencies but also redacting and possibly even destroying official records that do not fit their agenda?

If cynical realpolitik rooted in a desire to look tough on terrorism is not the base motivation, or maybe an actual desire to take things in a totalitarian direction, then heading down this path is a horrifying exercise in double-think and failure to consider secondary and tertiary effects.  The EU is certainly trying to have it both ways, on the one hand hammering Google and FaceBook for wielding their monopoly powers to unfair commercial advantage, and on the other hand demanding that they weaponize their Internet gateway status on behalf of the government.

Or maybe this isn’t double-think at all.  The most terrifying explanation is that governments are entering a negotiation with these tech behemoths with the idea of sanctioning their exploitation of their monopolies for commercial purposes if only they will consent to having their filtering powers bent to government will, a Faustian bargain if ever there were one.

God save us from a world where skynet is “automating the detection and removal of terrorist content online” and “prevent[ing] it [from] being uploaded in the first place”.  Could that possibly read more creepily?  How much ignorance of history, technology, and current events does it take to suggest such a thing seriously?  Or do they know exactly how this will end?