This integration allows Home Assistant to connect to an IRC server, enabling bidirectional communication between IRC and Home Assistant.
- Connect to IRC servers (with or without SSL)
- Send and receive messages
- Trigger automations based on IRC messages
- Send messages to IRC from Home Assistant
- Automatic reconnection on connection loss
- Open HACS in your Home Assistant instance
- Go to the "Integrations" section
- Click the three dots in the top right corner and select "Custom repositories"
- Add this repository:
https://github.com/sofagris/hairc - Click "Add"
- Search for "IRC" in the HACS store
- Click "Install" on the "Home Assistant IRC" integration
- Restart Home Assistant
- Copy the
haircdirectory to yourcustom_componentsdirectory in Home Assistant - Restart Home Assistant
Add the following to your configuration.yaml:
# Example configuration
hairc:
server: irc.example.com
port: 6697
nickname: yourbot
channel: "#yourchannel"
ssl: true
password: yourpassword # OptionalYou can send messages to IRC using the hairc.send_message service:
# Send a message when bot joins channel
automation:
- alias: "IRC Welcome Message"
trigger:
platform: event
event_type: hairc_connected
action:
service: hairc.send_message
data:
message: "Home Assistant at your service. Type !help for list of commands"# Example automation for sending messages
automation:
- alias: "Send IRC message when light turns on"
trigger:
platform: state
entity_id: light.living_room
to: "on"
action:
service: hairc.send_message
data:
message: "The living room light was turned on!"
channel: "#mychannel" # Optional, uses default channel if not specifiedIRC messages trigger the hairc_message event. You can create automations based on these events:
# Example automation for reacting to IRC messages
automation:
- alias: "Turn on light when someone writes 'light on' in IRC"
trigger:
platform: event
event_type: hairc_message
event_data:
message: "light on"
type: public
action:
service: light.turn_on
target:
entity_id: light.living_room# Example of complex automation
automation:
- alias: "Handle IRC Commands"
trigger:
platform: event
event_type: hairc_message
condition:
condition: template
value_template: >
{% set message = trigger.event.data.message %}
{% set sender = trigger.event.data.sender %}
{{ message.startswith('!') }}
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.event.data.message == '!status' }}"
sequence:
- service: hairc.send_message
data:
message: >
Status:
Light: {{ states('light.living_room') }}
Temperature: {{ states('sensor.temperature') }}°C
- conditions:
- condition: template
value_template: "{{ trigger.event.data.message == '!help' }}"
sequence:
- service: hairc.send_message
data:
message: >
Available commands:
!status - Show home status
!help - Show this help textThe integration sends the following events that can be used in automations:
Triggered when a message is received in the IRC channel.
Event data:
message: The message textsender: The sender's nickchannel: The channel the message came fromtype: "public" or "private"
Triggered when the bot connects to the IRC server.
Triggered when the bot disconnects from the IRC server.
Sends a message to an IRC channel.
service: hairc.send_message
data:
message: "Hello from Home Assistant!"
channel: "#mychannel" # OptionalThe IRC sensor has the following attributes:
messages: The last 10 messages received in the channelconnected: Connection status (true/false)
If you encounter issues:
- Verify the server address and port are correct
- Try with
ssl: falseif you have SSL issues - Enable debug logging for the integration:
logger:
default: warning
logs:
custom_components.hairc: debugContributions are welcome! Please create a pull request with your changes.