Skip to content

A Lovelace custom card providing a unified chat interface for real-time provisioning, editing, and technical debugging of Home Assistant configurations, accessed directly within the Dashboard.

License

Notifications You must be signed in to change notification settings

pajeronda/grok-code-fast-card

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Grok Code Fast Card

A Lovelace custom card providing a unified chat interface for real-time provisioning, editing, and technical debugging of Home Assistant configurations, accessed directly within the Dashboard.


⚠️ Important: This card requires the xAI Conversation with the Grok Code Fast service configured in Home Assistant.


Version Home Assistant License

✨ Features

  • πŸ’¬ Interactive Chat: Chat bubble style interface with conversation history
  • πŸ’Ύ Auto-save: Persistent chat history and code using localStorage
  • ⌨️ Send on Enter: Optional keyboard shortcut (configurable checkbox)
  • πŸ“Ž File Attachments: Upload and send files (text, JSON, etc.) with your prompts
  • ♻️ Code Iteration: Automatically sends current code for refinement and updates
  • πŸ‘€ Multi-User Support: Tracks user context for personalized service
  • πŸ”„ Conversation Continuity: Maintains context across multiple user devices (Laptop, Tablet, etc..)
  • πŸŒ™ Theme Support: Follows Home Assistant theme colors
  • 🎨 Responsive Design: Adapts to any screen size

πŸ”§ Requirements

Required: xAI Conversation Integration with Grok Code Fast Service

This card is specifically designed to work with the xAI Conversation integration's Grok Code Fast service:

βœ… Install the xAI Conversation integration

Without the xAI Conversation integration, this card will not function.

Home Assistant Version

  • Home Assistant 2025.10 or newer
  • Frontend with container queries support (2025.7+ recommended)

πŸ“¦ Installation

Via HACS (Recommended)

Click this badge to install xAI Conversation via HACS

Install via your HACS instance.

Click this badge to install Grok Code Fast Card via HACS

Install via your HACS instance.

Manual

  1. Open HACS
  2. Go to "Frontend"
  3. Click the three dots menu β†’ "Custom repositories"
  4. Add this repository URL: https://github.com/pajeronda/grok-code-fast-card
  5. Click "Install"

Manual Installation

  1. Download grok-code-fast-card.js from this repository

  2. Copy to /config/www/

  3. Add resource to Lovelace:

    • Go to Settings β†’ Dashboards β†’ Resources
    • Click + ADD RESOURCE
    • Enter:
      • URL: /local/www/grok-code-fast-card.js
      • Type: JavaScript Module
    • Click CREATE
  4. Refresh browser cache (Ctrl+Shift+R)

πŸš€ Usage


mode card:

immagine

fullscreen:

immagine

Add Card to Dashboard

  1. Edit your dashboard
  2. Click + ADD CARD
  3. Search for "Grok Code Fast Card"
  4. Click SAVE

Or add manually in YAML mode:

type: custom:grok-code-fast-card
theme: <your theme>

Example with panel mode:

- type: panel
    path: code
    title: GROK CODE FAST
    cards:
      - type: custom:grok-code-fast-card
        theme: <your theme>

Example with Browser mod:

action: fire-dom-event
browser_mod:
  service: browser_mod.popup
  data:
    initial_style: normal
    style_sequence:
      - normal
      - fullscreen
      - wide
    title: '(tap πŸ‘† here)'
    content:
      type: custom:grok-code-fast-card
      theme: <your theme>

Optional Configuration

The card works without configuration.

βš™οΈ Features Explained

File Attachments

Upload files to provide context for Grok:

  • πŸ“Ž Attach Button: Click paperclip icon to select files
  • πŸ–ΌοΈ Supported Types: Images (PNG, JPG, GIF), text files, JSON, YAML, code files
  • πŸ‘οΈ Preview: Attached files shown as badges with filename and size
  • ❌ Remove: Click X on badge to remove attachment before sending
  • πŸ“€ Auto-clear: Attachments cleared after successful send
  • πŸ’Ύ Storage: File metadata saved in chat history

Send on Enter

Enable the checkbox in the footer to send messages with Enter key:

  • βœ… Enter: Send message (when checkbox enabled)
  • βœ… Shift+Enter: Always adds new line (regardless of checkbox)
  • βœ… Unchecked: Enter adds new line normally

Chat History

  • πŸ’¬ Bubble-style chat interface
  • πŸ‘€ User messages align right (blue background)
  • πŸ€– Grok responses align left (card background)
  • πŸ“‹ All text is selectable and copyable
  • πŸ“Ž File attachments shown as badges in user messages
  • πŸ’Ύ Auto-saves to localStorage

Code Editor

  • ✨ Syntax highlighting for Jinja2/YAML
  • πŸ”’ Line numbers enabled
  • πŸ“ Auto-height on desktop, fixed on mobile
  • πŸ“‹ One-click copy button
  • 🎨 Follows Home Assistant theme
  • ♻️ Code Iteration: Current code automatically sent with each request for refinement

Conversation Continuity

  • πŸ”„ Context Preservation: Each response includes a unique ID
  • 🧠 Memory: Previous response ID sent with next request
  • πŸ’¬ Natural Flow: Grok remembers conversation context
  • πŸ‘€ User Tracking: Maintains separate conversations per user

πŸ“ Example Prompts

Try these with the Grok Code Fast service:

Basic prompts:

  • "Create an automation to turn on lights when motion is detected"
  • "Fix this template: {{ states('sensor.temp') * 2 }}"
  • "Make a template sensor for average temperature from 3 sensors"
  • "Help me create a script to announce weather via TTS"
  • "Generate a Lovelace card config for displaying energy usage"
  • "Create a binary sensor that checks if it's nighttime"

With file attachments:

  • Upload screenshot: "Explain what this error means and how to fix it"
  • Attach JSON file: "Parse this API response and create sensors for each value"
  • Send image: "Create an automation based on this state machine diagram"
  • Upload config file: "Review this automation and suggest improvements"

Code iteration:

  • First: "Create a motion light automation"
  • Then: "Add a condition to only work at night"
  • Then: "Also add a delay before turning off"
  • (Card automatically sends current code for context)

πŸ› Troubleshooting

Card not showing

  • βœ… Check resource is loaded: Settings β†’ Dashboards β†’ Resources
  • βœ… Verify file exists at /config/www/community/grok-code-fast-card/grok-code-fast-card.js
  • βœ… Clear browser cache (Ctrl+Shift+R or Cmd+Shift+R)
  • βœ… Check browser console (F12) for errors

No response from Grok

  • ❌ Most Common: xAI Conversation integration not installed
  • βœ… Verify integration: Settings β†’ Devices & Services β†’ look for "xAI Conversation"
  • βœ… Check service exists: Developer Tools β†’ Services β†’ search "grok_code_fast"
  • βœ… Check Home Assistant logs for integration errors

Chat not saving

  • βœ… Ensure browser localStorage is enabled
  • βœ… Check no browser extensions are blocking storage
  • βœ… Private/Incognito mode may block localStorage
  • βœ… Check browser console for storage errors

File attachments not working

  • βœ… Check file size (large files may cause issues)
  • βœ… Verify file type is supported (images, text, JSON, YAML, etc.)
  • βœ… Check browser console for file reading errors
  • βœ… Ensure browser supports FileReader API

Conversation context lost

  • βœ… Verify xAI Conversation integration supports conversation memory
  • βœ… Check browser console for service call logs
  • βœ… Clear localStorage and restart conversation if corrupted

Formatting issues

  • βœ… Ensure Home Assistant 2025.1+
  • βœ… Update to latest Home Assistant version
  • βœ… Test in different browser (Chrome/Firefox/Safari)
  • βœ… Check if browser supports CSS container queries

🀝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ‘€ Author

Pajeronda

⭐ Support

If you find this card useful:

  • ⭐ Star the repository
  • πŸ› Report bugs via Issues
  • πŸ’‘ Suggest features via Discussions
  • πŸ“’ Share with the Home Assistant community

πŸ”— Related Projects

Legal Notes

  • API Usage: This integration requires an active xAI account and a valid API key. Use of the xAI API is subject to xAI's terms of service.
  • Trademarks: xAI, Grok, and related logos are registered trademarks of xAI Corp. This project is an unofficial integration developed by @pajeronda and is not affiliated with, sponsored by, or endorsed by xAI Corp.

Made with ❀️ by Pajeronda β€’ v1.0.2 β€’ Updated 2025-11-19


About

A Lovelace custom card providing a unified chat interface for real-time provisioning, editing, and technical debugging of Home Assistant configurations, accessed directly within the Dashboard.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published