Added lighting preset recall on backend and frontend, fixed things in other scripts - things should *mostly* be working now
This commit is contained in:
parent
61a8aa8ebc
commit
d00651a66c
14 changed files with 851 additions and 74 deletions
|
@ -70,9 +70,9 @@ async function setLecture(pos?: String) {
|
|||
let command = '0'
|
||||
if (roomState.value == 0) {
|
||||
command = '1'
|
||||
} else if (roomState.value == 1) {
|
||||
command = '0'
|
||||
} else { return }
|
||||
} // else if (roomState.value == 1) {
|
||||
// command = '0'
|
||||
// } else { return }
|
||||
publishMQTTMsg((topicPref + 'set/power'), command)
|
||||
publishMQTTMsg((topicPref + 'platno/goto'), command == '1' ? 'DOWN' : 'UP')
|
||||
publishMQTTMsg((topicPref + 'lift/move/' + (command == '1' ? 'down' : 'up') ), '1')
|
||||
|
@ -100,12 +100,15 @@ watch (roomStatus, (_, _newState) => {
|
|||
if (!_newState) { return }
|
||||
let allOn = _newState.proj_power && _newState.platno_state == 'DOWN' && _newState.lift_state == 'DOWN'
|
||||
let allOff = !_newState.proj_power && _newState.platno_state == 'UP' && _newState.lift_state == 'UP'
|
||||
let anyUnknown = _newState.lift_state == 'UNKNOWN' || _newState.platno_state == 'UNKNOWN'
|
||||
if (allOn) {
|
||||
roomState.value = 1
|
||||
} else if (allOff) {
|
||||
roomState.value = 0
|
||||
} else if (anyUnknown) {
|
||||
roomState.value = 3
|
||||
} else {
|
||||
roomState.value = 2
|
||||
roomState.value = 2
|
||||
}
|
||||
}, {immediate: true})
|
||||
|
||||
|
@ -119,7 +122,8 @@ watch (roomStatus, (_, _newState) => {
|
|||
<h3 v-if="roomState == 1">AKTIVNO</h3>
|
||||
<h3 v-else-if="roomState == 0">PRIPRAVLJENOST</h3>
|
||||
<h3 v-else-if="roomState == 2">POČAKAJTE</h3>
|
||||
<h3 v-else="roomState == 1">NAPAKA</h3>
|
||||
<h3 v-else-if="roomState == 3">NEZNANO STANJE</h3>
|
||||
<h3 v-else>NAPAKA</h3>
|
||||
<button style="" @click="setLecture(props.position)" :disabled="roomState == 2">
|
||||
{{ roomState == 1 ? 'UGASNI' : (roomState == 0 ? 'PRIŽGI' : '...') }}
|
||||
</button>
|
||||
|
|
|
@ -14,8 +14,11 @@ const props = defineProps({
|
|||
const topicstrs = [ //TODO everything else
|
||||
props.room + '/projectors/' + props.position + 'platno/status',
|
||||
props.room + '/projectors/' + props.position + 'platno/status',
|
||||
props.room + '/lucke/preset/current',
|
||||
]
|
||||
|
||||
const lastPreset = ref("-1")
|
||||
|
||||
const subscriptions =
|
||||
topicstrs.map(topic => {
|
||||
// console.log('subbing to', topic)
|
||||
|
@ -31,6 +34,8 @@ function handleIncomingMQTT(topic: string, msg: string) {
|
|||
//console.log(topic.split('/'))
|
||||
let typ = topic.split('/')[4]
|
||||
handlePlatnoStatus(msg)
|
||||
} else if (topic.includes('current')) {
|
||||
lastPreset.value = msg
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +83,8 @@ function publishMQTTMsg(topic: string, msg: string) {
|
|||
const publishPrefix = ref(props.room + '/')
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -101,12 +108,13 @@ const publishPrefix = ref(props.room + '/')
|
|||
<div style="display: flex; gap: 1rem;">
|
||||
<div>
|
||||
<h4>Lučka presets</h4>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'A')"A>Plchldr A</button>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'B')"A>Plchldr B</button>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'C')"A>Plchldr C</button>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'D')"A>Plchldr D</button>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'E')"A>Plchldr E</button>
|
||||
<button @click="publishMQTTMsg(publishPrefix + 'lightpresets/set', 'F')"A>Plchldr F</button>
|
||||
<h5>CURRENT SCENE: {{ lastPreset }} -- TODO MAKE BUTTON LIGHT UP</h5>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '1')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', '1')"A>1</button>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '2')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', '2')"A>2</button>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '3')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', '3')"A>3</button>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '4')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', '4')"A>4</button>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '9')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', 'E')"A>Plchldr E</button>
|
||||
<button :class="{currentlySelectedPreset: (lastPreset == '9')}" @click="publishMQTTMsg(publishPrefix + 'lucke/preset/recall', 'F')"A>Plchldr F</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -121,4 +129,8 @@ button {
|
|||
margin: 0.1rem;
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
.currentlySelectedPreset {
|
||||
background-color: orange;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue