Skip to content

Commit 78e854a

Browse files
committed
fix(device): Convert entity registry id into entity id to fix device action
1 parent 1bb18b2 commit 78e854a

File tree

2 files changed

+58
-34
lines changed

2 files changed

+58
-34
lines changed

README.md

+52-34
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@
44

55
[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]
66

7-
_Companion Component to [node-red-contrib-home-assistant-websocket](https://github.com/zachowj/node-red-contrib-home-assistant-websocket) to integrate Node-RED with Home Assistant._
8-
9-
## Features
10-
11-
- Create and update entities from Node-RED
12-
- binary sensor
13-
- button
14-
- number
15-
- select
16-
- sensor
17-
- switch
18-
- text
19-
- Disable and enable Node-RED flows from Home Assistant UI
20-
- Create Home Assistant webhooks and handle them in Node-RED
21-
- Use Device triggers and action from Node-RED
7+
_Companion Component to [node-red-contrib-home-assistant-websocket](https://github.com/zachowj/node-red-contrib-home-assistant-websocket) for seamless integration of Node-RED with Home Assistant._
8+
9+
## Overview
10+
11+
The Node-RED Companion Integration bridges Node-RED and Home Assistant, allowing you to manage Home Assistant entities and automations directly from Node-RED. This integration enhances your smart home automation setup by enabling dynamic interaction between these two powerful tools.
12+
13+
## Key Features
14+
15+
- **Entity Management:**
16+
- Create and update Home Assistant entities from Node-RED, including:
17+
- Binary Sensors
18+
- Buttons
19+
- Numbers
20+
- Selects
21+
- Sensors
22+
- Switches
23+
- Text fields
24+
- **Flow Control:**
25+
- Enable or disable Node-RED flows directly from the Home Assistant UI.
26+
- **Webhooks:**
27+
- Create and manage Home Assistant webhooks, with handling in Node-RED.
28+
- **Device Automation:**
29+
- Utilize device triggers and actions within Node-RED for advanced automation capabilities.
2230

2331
## Minimum Requirements
2432

@@ -27,34 +35,44 @@ _Companion Component to [node-red-contrib-home-assistant-websocket](https://gith
2735

2836
## Installation
2937

30-
### HACS
38+
### Option 1: HACS (Home Assistant Community Store)
3139

32-
Install via [HACS](https://hacs.xyz) (Home Assistant Community Store)
40+
To install via HACS:
3341

34-
1. Go to HACS -> Integrations -> "+ Explore & Download Repos"
35-
1. Find "Node-RED Companion".
36-
1. Open the search result and click "Download this Repository with HACS".
37-
1. Refresh your browser window (bug in HA where it doesn't update the integration list after a reboot)
38-
1. From "Settings" in the Home Assistant sidebar, select "Devices and Services", click the blue [+ Add integration] button (in bottom right of the page) and search for "Node-RED", and install it. [![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=nodered)
42+
1. Navigate to HACS -> Integrations -> "+ Explore & Download Repos".
43+
2. Search for "Node-RED Companion".
44+
3. Click on the result and select "Download this Repository with HACS".
45+
4. Refresh your browser (due to a known HA bug that may not update the integration list immediately).
46+
5. Go to "Settings" in the Home Assistant sidebar, then select "Devices and Services".
47+
6. Click the blue [+ Add Integration] button at the bottom right, search for "Node-RED", and install it.
48+
[![Set up a new integration in Home Assistant](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=nodered)
3949

40-
### Manual
50+
### Option 2: Manual Installation
4151

42-
1. Using your tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
43-
1. If you do not have a `custom_components` directory (folder) there, you need to create it.
44-
1. In the `custom_components` directory (folder) create a new folder called `nodered`.
45-
1. Download _all_ the files from the `custom_components/nodered/` directory (folder) in this repository.
46-
1. Place the files you downloaded in the new directory (folder) you created.
47-
1. Restart Home Assistant
48-
1. Refresh your browser window (bug in HA where it doesn't update the integration list after a reboot)
49-
1. From "Settings" in the Home Assistant sidebar, select "Devices and Services", click the blue [+ Add integration] button (in bottom right of the page) and search for "Node-RED", and install it. [![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=nodered)
52+
For manual installation:
53+
54+
1. Access your Home Assistant configuration directory (`configuration.yaml` location).
55+
2. If it doesn’t already exist, create a `custom_components` directory.
56+
3. Within `custom_components`, create a new folder named `nodered`.
57+
4. Download all files from the `custom_components/nodered/` directory in this repository.
58+
5. Place these files in the newly created `nodered` directory.
59+
6. Restart Home Assistant.
60+
7. Refresh your browser window.
61+
8. From "Settings" in the Home Assistant sidebar, select "Devices and Services", click the blue [+ Add Integration] button, search for "Node-RED", and install it.
62+
[![Set up a new integration in Home Assistant](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=nodered)
5063

5164
## Configuration
5265

53-
Once installed and added via Home-Assistant Integrations all configuration is done from within Node-RED.
66+
Once the Node-RED Companion Integration is installed and added via Home Assistant Integrations, all further configuration is managed from within Node-RED.
67+
68+
## Contributing
69+
70+
Contributions are welcome! If you're interested in contributing, please review our [Contribution Guidelines](CONTRIBUTING.md) before submitting a pull request or issue.
5471

55-
## Contributions are welcome!
72+
## Support
5673

57-
If you want to contribute please read the [Contribution guidelines](CONTRIBUTING.md)
74+
If you find this project helpful and want to support its development, consider buying me a coffee!
75+
[![Buy Me a Coffee][buymecoffeebadge]][buymecoffee]
5876

5977
---
6078

custom_components/nodered/websocket.py

+6
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,18 @@ async def websocket_device_action(
9999
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
100100
) -> None:
101101
"""Sensor command."""
102+
102103
context = connection.context(msg)
103104
platform = await device_automation.async_get_device_automation_platform(
104105
hass, msg["action"][CONF_DOMAIN], DeviceAutomationType.ACTION
105106
)
106107

107108
try:
109+
if "entity_id" in msg["action"]:
110+
entity_registry = async_get(hass)
111+
entity_id = entity_registry.async_get(msg["action"]["entity_id"]).entity_id
112+
msg["action"]["entity_id"] = entity_id
113+
108114
await platform.async_call_action_from_config(hass, msg["action"], {}, context)
109115
connection.send_message(result_message(msg[CONF_ID]))
110116
except InvalidDeviceAutomationConfig as err:

0 commit comments

Comments
 (0)