Files
2025-12-31 13:29:33 +01:00

197 lines
6.0 KiB
Markdown

# Morse Code Blinker
A Home Assistant custom integration that blinks lights in morse code.
## Installation
### HACS Installation
**⚠️ Important Note**: HACS does not natively support integrations located in subfolders of a repository. Since this integration is in the `morse-code-blinker` subfolder of the `home-assistant` repository, HACS may not automatically detect it.
**Option 1: Try HACS (may not work)**
1. Open HACS in Home Assistant
2. Go to "Integrations"
3. Click the three dots menu (⋮) in the top right
4. Select "Custom repositories"
5. Add this repository URL: `https://git.falkvinge.net/rick/home-assistant`
6. Select "Integration" as the category
7. Click "Add"
8. If HACS finds it, click "Download" and restart Home Assistant
9. If HACS doesn't find it, use Manual Installation below
**Option 2: Manual Installation (Recommended for subfolder structure)**
### Manual Installation (Recommended)
Since this integration is in a subfolder, manual installation is the most reliable method:
1. Clone or download the repository:
```bash
git clone https://git.falkvinge.net/rick/home-assistant.git
cd home-assistant/morse-code-blinker
```
2. Copy the `custom_components/morse_code_blinker` folder to your Home Assistant `custom_components` directory:
```bash
cp -r custom_components/morse_code_blinker /config/custom_components/
```
3. Restart Home Assistant
**Alternative**: You can also download just the `morse-code-blinker` subfolder from the web interface at:
`https://git.falkvinge.net/rick/home-assistant/src/branch/master/morse-code-blinker`
## Configuration
After manual installation, add the integration to your `configuration.yaml` file:
```yaml
morse_code_blinker:
```
That's it! This integration doesn't require any configuration options - it just needs to be loaded. After adding this to your `configuration.yaml`:
1. Check your configuration:
- Go to **Developer Tools** > **YAML**
- Click **Check Configuration**
- Fix any errors if present
2. Restart Home Assistant to load the integration
**Note**: The integration will work even without adding it to `configuration.yaml` (it will be auto-discovered), but adding it explicitly ensures it's loaded and allows Home Assistant to show it in the integrations list.
## Usage
After installation, the integration provides a service `morse_code_blinker.blink` that can be used to blink any light entity in morse code.
### Service Parameters
- `entity_id` (required): The entity ID of the light to blink (e.g., `light.living_room`)
- `message` (required): The text message to convert to morse code
- `dot_duration` (optional): Duration of a dot in seconds (default: 0.2)
- `dash_duration` (optional): Duration of a dash in seconds (default: 0.6)
- `element_gap` (optional): Gap between dots/dashes within a letter in seconds (default: 0.2)
- `letter_gap` (optional): Gap between letters in seconds (default: 0.6)
- `word_gap` (optional): Gap between words in seconds (default: 1.4)
- `transition` (optional): Transition time in seconds for light on/off (default: 0 = instant). Set to 0 for LED lights to get crisp, instant on/off transitions. Use higher values for incandescent lights if needed.
### Examples
#### Using the Developer Tools
1. Go to Developer Tools > Services
2. Select `morse_code_blinker.blink`
3. Enter the following YAML:
```yaml
entity_id: light.living_room
message: "SOS"
```
#### Using Automations
```yaml
automation:
- alias: "Blink SOS on doorbell"
trigger:
- platform: state
entity_id: binary_sensor.doorbell
to: "on"
action:
- service: morse_code_blinker.blink
data:
entity_id: light.front_porch
message: "SOS"
```
#### Using Scripts
```yaml
script:
blink_hello:
alias: "Blink Hello"
sequence:
- service: morse_code_blinker.blink
data:
entity_id: light.bedroom
message: "Hello World"
```
#### Custom Timing
```yaml
service: morse_code_blinker.blink
data:
entity_id: light.kitchen
message: "FAST"
dot_duration: 0.1
dash_duration: 0.3
element_gap: 0.1
letter_gap: 0.3
word_gap: 0.7
```
#### Instant Transitions for LED Lights
For LED lights (Zigbee, Z-Wave, etc.), set `transition: 0` to get instant on/off without fade:
```yaml
service: morse_code_blinker.blink
data:
entity_id: light.led_strip
message: "SOS"
transition: 0
```
## Supported Characters
The integration supports:
- Letters (A-Z)
- Numbers (0-9)
- Common punctuation: `. , ? ' ! / ( ) & : ; = + - _ " $ @`
- Spaces (for word separation)
## Troubleshooting
### Service Returns "Unknown Error"
If you get an "Unknown error" when calling the service, check the Home Assistant logs:
1. **View Logs**:
- Go to **Developer Tools** > **Logs**
- Look for errors containing `morse_code_blinker`
- The logs will show the actual error message
2. **Enable Debug Logging** (for more detailed information):
Add this to your `configuration.yaml`:
```yaml
logger:
default: info
logs:
custom_components.morse_code_blinker: debug
```
Then restart Home Assistant and try the service again. The debug logs will show exactly what data is being received and where any errors occur.
3. **Common Issues**:
- **Missing entity_id**: Make sure you provide an `entity_id` parameter
- **Missing message**: Make sure you provide a `message` parameter
- **Entity not found**: Verify the entity ID exists (check in Developer Tools > States)
- **Entity is not a light**: The service requires a light entity that supports `turn_on` and `turn_off`
4. **Test with Minimal Example**:
Try this minimal service call first:
```yaml
service: morse_code_blinker.blink
data:
entity_id: light.your_light_entity
message: "SOS"
```
Replace `light.your_light_entity` with an actual light entity ID from your system.
## Notes
- The light will be turned on and off automatically during the morse code sequence
- The service is non-blocking but will take time to complete based on the message length
- Make sure the light entity supports `turn_on` and `turn_off` services