Skip to content
Snippets Groups Projects
Commit c9ce1087 authored by jkerdreu's avatar jkerdreu
Browse files

Added lamp


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1870 b32b6428-25c9-4566-ad07-03861ab6144f
parent c5662b8e
Branches
No related tags found
No related merge requests found
<lamp>
<div class="lamp">
<div class="{stateClass}">{ light }</div>
<button class="button ripple" name="btn_on" onclick={ btn }>ON</button>
<button class="button ripple" name="btn_off" onclick={ btn }>OFF</button>
</div>
<script>
this.addr = opts.xaal_addr
this.light = '__';
this.stateClass = 'state-unknow';
receive(data) {
state = data['attributes']['light']
if (state == true) {
this.light = 'ON'
this.stateClass = 'state-on'
}
else {
this.light = 'OFF'
this.stateClass = 'state-off'
}
this.update()
}
btn(e) {
if (e.target.name =='btn_on')
sio_send_request(this.addr,'on',{})
if (e.target.name =='btn_off')
sio_send_request(this.addr,'off',{})
}
</script>
<style>
.state-on {
color: var(--color3);
font-weight: bold;
padding: 8px;
}
.state-unknow, .state-off {
color: var(--color1);
font-weight: bold;
padding: 8px;
}
</style>
</lamp>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment