       (defun fancy-battery-powerline-face ()
         "Return a face appropriate for powerline"
         (let ((type (cdr (assq ?L fancy-battery-last-status))))
-          (if (string= "AC" type)
+          (if (and type (string= "AC" type))
               'fancy-battery-charging
             (pcase (cdr (assq ?b fancy-battery-last-status))
               ("!"  'fancy-battery-critical)

        (interactive)
        (if fancy-battery-mode
            (fancy-battery-mode -1)
          (fancy-battery-mode)))

      (defun spacemacs/mode-line-battery-percentage ()
        "Return the load percentage or an empty string."

        (let ((time (cdr (assq ?t fancy-battery-last-status))))
          (cond
           ((string= "0:00" time) "")
           ((string= "N/A" time) "")
           ((string-empty-p time) "")
           (t (concat " (" time ")")))))

      (setq-default fancy-battery-show-percentage t)
