Complete Computing Environment: Homehub

Table of Contents

INPROGRESS Homehub

BCS is a great project, but it's sorely limited by battery life; any processing I can move off of the BCS and in to a central compute hub is more battery life for the system as a whole. Homehub is, essentially, a project to create a Rules Engine that uses Matrix RPC to pass messages between different parts of my life. Turn my lights on when I am opening the door, trigger a "code red" scenario when Pagerduty SMSs me, ping me when I have an calendar event to attend, allow me to schedule events from my BCS or via SMS.

(provide 'cce-homehub)

Minor Mode

(define-minor-mode cce-server-minor-mode
  "Minor mode for providing CCE affordances for the Body Computing System
\\{cce-server-minor-mode-map}"
  :global t
  :init-value nil
  :lighter "[SERVER]"
  :keymap nil
  (if cce-server-minor-mode
      (cce/disable-server-mode)
    (cce/enable-server-mode)))

(add-to-list 'desktop-minor-mode-table '(cce-server-minor-mode . nil))

(defvar cce-server-minor-mode-map
  (let ((map (make-sparse-keymap)))
    map)
  "Keymap for `cce-server-minor-mode'")

(defun cce/enable-server-mode ()
  (run-hooks 'cce-server-minor-mode-hooks)
  (setq cce-mode 'server))

(defun cce/disable-server-mode ()
  (setq cce-mode nil))

(defvar cce-server-minor-mode-hooks nil
  "Hooks to run once the SERVER minor mode is enabled")

(add-hook 'after-cce-hook
          (lambda ()
            (cce/with-any-domain '("hypervisor01")
                                 (cce-server-minor-mode 1))))

Sico: Emacs Personal Assistant

Sico is my Matrix Personal Assistant. He is basically a pattern matcher, but being able to run simple Elisp from remote places opens up the ability to offload heavy processing from my Body Computing System to a place with more horsepower.

(add-to-list 'cce-server-minor-mode-hooks
             (lambda ()
               (add-to-list 'load-path "/home/rrix/Projects/sico/")
               (require 'sico)
               (setq matrix-homeserver-base-url "https://matrix01:8448")
               (sico-start)))

Join only one room for now, my public hangout space; there will be a 1:1 room that I will probably customize over this at some point.

(setq sico-rooms '("!leoRhHBUbgPbbYocCt:whatthefuck.computer"))
(setq sico-users '("@rrix:whatthefuck.computer"))
(setq sico-connection-string "This is Ishikawa. Standing by for orders, Major.")

Sico Actions

  • Capturing Notes

    This is the capture template that I am using for Sico right now, very simple and straight-forward. It's the built-in capture feature.

    (setq sico-capture-note-regexp "^Note:[[:space:]]\\(.*\\)")
    (setq sico-listeners '(("^Note:[[:space:]]\\(.*\\)" . sico-capture-note)))
    (eval-after-load "org-capture"
      (lambda ()
        (add-to-list 'org-capture-templates
                     '("A" "Automatic note taking using Sico"
                       entry
                       (file org-default-notes-file)
                       "* %c :NOTE:NOEXPORT:"
                       :immediate-finish t))))
    
  • Ping/Pong Connection test
    (add-to-list 'sico-listeners '("^ping$" . sico-ping-pong))
    
    (defun sico-ping-pong (con room-id event)
      "Capture a note from EVENT."
      (let* ((content (matrix-get 'content event))
             (body (matrix-get 'body content))
             (user-id (matrix-get 'sender event)))
        (when (member user-id sico-users)
          (matrix-send-message con room-id
                               (format "%s: Pong!" user-id)))))
    
  • Agenda in Matrix
    (add-to-list 'sico-listeners '("What is my agenda" . sico-agenda))
    
    (defun sico-agenda (event)
      "Capture a note from EVENT."
      (let* ((content (matrix-get 'content event))
             (body (matrix-get 'body content))
             (user-id (matrix-get 'sender event))
             (room-id (matrix-get 'room_id event)))
        (when (member user-id sico-users)
          (save-excursion
            (condition-case nil
                (org-agenda-list)
              (error nil))
            (let* ((buffer  (current-buffer))
                   (text-string (with-current-buffer buffer
                                  (buffer-string)))
                   (html-string (with-current-buffer buffer
                                  (htmlize-region-for-paste (point-min) (point-max)))))
              (matrix-send-event room-id "m.room.message"
                                 (list (cons "msgtype" "m.text")
                                       (cons "format" "org.matrix.custom.html")
                                       (cons "body" text-string)
                                       (cons "formatted_body" html-string))))))))
    
  • Things I want to add
    • Dump day's agenda to room
    • Capture to my miniblog and publish it
    • Search for org-mode entries
    • Simple time clocking system
    • Push sauron events
    • Evaluate arbitrary sexp
    • Capture BBDB entries and add facts to existing ones

DONE Don't send a connection string if it is nil   NOTE NOEXPORT

System Components

INPROGRESS RPC layer

DONE Research messaging systems

  • DONE ELKstack
  • DONE Matrix.org

  • DONE Kafka

  • DONE MQTT

  • DONE Alljoyn

  • DONE Graviton

  • DONE Meshblu

DONE Deploy Matrix

INPROGRESS Create an mcat program

  • Pulls from stdin and pushes to a matrix room
  • Cats a matrix room to stdout

PLANNING Ruleset Engine

INPROGRESS Intelligent light switch

DONE Purchase a 1N4001 diode OR 74AHCT125 level converter   PURCHASE @ADAFRUIT @RADIOSHACK

DONE Ansible-ize

NEXT blog about lightrix

  • NEXT screen cast explaining the system and code?

NEXT Rebuild on top of Raspbian and solve networking woes

WAITING Generic push messaging infrastructure

WAITING Intelligent DLNA Renderer

WAITING Intelligent music players

NEXT matrix bot to run commands from a yaml file

WAITING Intelligent thermostat

WAITING Intelligent Alarm Clock

ICEBOX Morning Sounder

  • Note taken on [2014-05-07 Wed 00:10]

    This is an interesting project. Small hardware box which talks to you:

    • media01 to pull morning alarm music
    • huginn to read the morning news and weather
    • Timed warnings for when we have to leave to catch various transits
  • DONE Make a Mopidy Ansible role

  • NEXT Find/design raspi case with room for speaker pack and wifi stick
  • NEXT Get Huginn text only reports generated every morning
  • NEXT Set up a neat web interface to cron/atd to do that shit for me at a given time
  • NEXT TTS to read the news from Huginn and play tunes

WAITING Room sensors

Author: Ryan Rix

Created: 2017-05-19 Fri 13:29

Validate XHTML 1.0