Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint capability to lock type #25359

Merged
merged 7 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,22 +747,25 @@ export default class HomeAssistant extends Extension {
break;
}
case 'lock': {
assert(!endpoint, `Endpoint not supported for lock type`);
const state = (firstExpose as zhc.Lock).features.filter(isBinaryExpose).find((f) => f.name === 'state');
assert(state?.property === 'state', "Lock property must be 'state'");
assert(state?.name === 'state', "Lock expose must have a 'state'");
const discoveryEntry: DiscoveryEntry = {
type: 'lock',
object_id: 'lock',
/* v8 ignore next */
object_id: endpoint ? `lock_${endpoint}` : 'lock',
Koenkk marked this conversation as resolved.
Show resolved Hide resolved
mockProperties: [{property: state.property, value: null}],
discovery_payload: {
name: null,
/* v8 ignore next */
name: endpoint ? utils.capitalize(endpoint) : null,
command_topic_prefix: endpoint,
command_topic: true,
value_template: `{{ value_json.${state.property} }}`,
state_locked: state.value_on,
state_unlocked: state.value_off,
/* v8 ignore next */
command_topic_postfix: endpoint ? state.property : null,
},
};

discoveryEntries.push(discoveryEntry);
break;
}
Expand Down
Loading