ha-frontend/src/more-infos/more-info-camera.html

59 lines
1.2 KiB
HTML

<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id='more-info-camera'>
<template>
<style>
:host {
max-width:640px;
}
.camera-image {
width: 100%;
}
</style>
<img class='camera-image' src="[[computeCameraImageUrl(hass, stateObj, isVisible)]]"
on-load='imageLoaded' alt='[[computeStateName(stateObj)]]' />
</template>
</dom-module>
<script>
Polymer({
is: 'more-info-camera',
properties: {
hass: {
type: Object,
},
stateObj: {
type: Object,
},
isVisible: {
type: Boolean,
value: true,
},
},
imageLoaded: function () {
this.fire('iron-resize');
},
computeStateName: function (stateObj) {
return window.hassUtil.computeStateName(stateObj);
},
computeCameraImageUrl: function (hass, stateObj, isVisible) {
if (hass.demo) {
return '/demo/webcam.jpg';
} else if (stateObj && isVisible) {
return '/api/camera_proxy_stream/' + stateObj.entity_id +
'?token=' + stateObj.attributes.access_token;
}
// Return an empty image if no stateObj (= dialog not open) or in cleanup mode.
return 'data:image/gif;base64,R0lGODlhAQABAAAAACw=';
},
});
</script>