Skip to content

Commit

Permalink
Add support templates in ptz
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Oct 12, 2024
1 parent 7583761 commit 41dfe90
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/webrtc/www/webrtc-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,12 @@ class WebRTCCamera extends VideoRTC {
</div>
`);

const template = JSON.stringify(this.config.ptz);
const handle = path => {
const data = this.config.ptz['data_' + path];
if (!data) return;
const [domain, service] = this.config.ptz.service.split('.', 2);
if (!this.config.ptz['data_' + path]) return;
const config = template.indexOf('${') < 0 ? this.config.ptz : JSON.parse(eval('`' + template + '`'));
const [domain, service] = config.service.split('.', 2);
const data = config['data_' + path];
this.hass.callService(domain, service, data);
};
const ptz = this.querySelector('.ptz');
Expand Down

0 comments on commit 41dfe90

Please sign in to comment.