mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Allow unpairing devices using any adapter
This commit is contained in:
parent
361eaaf1bc
commit
c56b9c6fbe
@ -1,5 +1,9 @@
|
|||||||
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
|
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
|
||||||
|
|
||||||
|
## 0.1.10 (28.07.2025)
|
||||||
|
|
||||||
|
- Allowed unpairing of devices using any adapter.
|
||||||
|
|
||||||
## 0.1.9 (28.07.2025)
|
## 0.1.9 (28.07.2025)
|
||||||
|
|
||||||
- Added icon.
|
- Added icon.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
||||||
name: Futurehome
|
name: Futurehome
|
||||||
version: '0.1.9'
|
version: '0.1.10'
|
||||||
slug: futurehome
|
slug: futurehome
|
||||||
description: Local Futurehome Smarthub integration
|
description: Local Futurehome Smarthub integration
|
||||||
url: 'https://github.com/adrianjagielak/home-assistant-futurehome'
|
url: 'https://github.com/adrianjagielak/home-assistant-futurehome'
|
||||||
|
@ -265,22 +265,52 @@ export function haPublishDevice(parameters: {
|
|||||||
parameters.thingsplexUsername &&
|
parameters.thingsplexUsername &&
|
||||||
parameters.thingsplexPassword &&
|
parameters.thingsplexPassword &&
|
||||||
parameters.vinculumDeviceData.fimp?.address &&
|
parameters.vinculumDeviceData.fimp?.address &&
|
||||||
(parameters.vinculumDeviceData.fimp?.adapter === 'zigbee' ||
|
parameters.vinculumDeviceData.fimp?.adapter
|
||||||
parameters.vinculumDeviceData.fimp?.adapter === 'zwave-ad')
|
|
||||||
) {
|
) {
|
||||||
const deleteCommandTopic = `${topicPrefix}/delete/command`;
|
const deleteCommandTopic = `${topicPrefix}/delete/command`;
|
||||||
|
|
||||||
|
const rawAdapterName = parameters.vinculumDeviceData.fimp?.adapter;
|
||||||
|
|
||||||
|
let adapterName: string;
|
||||||
|
switch (rawAdapterName) {
|
||||||
|
case 'zigbee':
|
||||||
|
adapterName = 'ZigBee';
|
||||||
|
break;
|
||||||
|
case 'zwave-ad':
|
||||||
|
adapterName = 'Z-Wave';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
adapterName = rawAdapterName
|
||||||
|
// Split the string by underscores
|
||||||
|
.split('_')
|
||||||
|
// Capitalize each word
|
||||||
|
.map(
|
||||||
|
(word) =>
|
||||||
|
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(),
|
||||||
|
)
|
||||||
|
// Join words with spaces
|
||||||
|
.join(' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let adapterServiceAddr = `pt:j1/mt:evt/rt:ad/rn:${rawAdapterName}/ad:1`;
|
||||||
|
if (rawAdapterName === 'zwave-ad') {
|
||||||
|
adapterServiceAddr = 'pt:j1/mt:evt/rt:ad/rn:zw/ad:1';
|
||||||
|
}
|
||||||
|
|
||||||
components[`${topicPrefix}_delete_button`] = {
|
components[`${topicPrefix}_delete_button`] = {
|
||||||
unique_id: `${topicPrefix}_delete_button`,
|
unique_id: `${topicPrefix}_delete_button`,
|
||||||
platform: 'button',
|
platform: 'button',
|
||||||
entity_category: 'diagnostic',
|
entity_category: 'diagnostic',
|
||||||
name:
|
name: `${adapterName}: Unpair Device`,
|
||||||
parameters.vinculumDeviceData.fimp?.adapter === 'zigbee'
|
|
||||||
? 'ZigBee: Unpair Device'
|
|
||||||
: 'Z-Wave: Unpair Device',
|
|
||||||
icon: 'mdi:delete-forever',
|
icon: 'mdi:delete-forever',
|
||||||
command_topic: deleteCommandTopic,
|
command_topic: deleteCommandTopic,
|
||||||
} as any;
|
} as any;
|
||||||
handlers[deleteCommandTopic] = async (_payload: string) => {
|
handlers[deleteCommandTopic] = async (_payload: string) => {
|
||||||
|
if (parameters.demoMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const token = await loginToThingsplex({
|
const token = await loginToThingsplex({
|
||||||
host: parameters.hubIp,
|
host: parameters.hubIp,
|
||||||
@ -294,14 +324,8 @@ export function haPublishDevice(parameters: {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
address:
|
address: adapterServiceAddr,
|
||||||
parameters.vinculumDeviceData.fimp?.adapter === 'zigbee'
|
service: rawAdapterName,
|
||||||
? 'pt:j1/mt:cmd/rt:ad/rn:zigbee/ad:1'
|
|
||||||
: 'pt:j1/mt:evt/rt:ad/rn:zw/ad:1',
|
|
||||||
service:
|
|
||||||
parameters.vinculumDeviceData.fimp?.adapter === 'zigbee'
|
|
||||||
? 'zigbee'
|
|
||||||
: 'zwave-ad',
|
|
||||||
cmd: 'cmd.thing.delete',
|
cmd: 'cmd.thing.delete',
|
||||||
val_t: 'str_map',
|
val_t: 'str_map',
|
||||||
val: {
|
val: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user