fix 6
This commit is contained in:
@@ -1661,7 +1661,8 @@
|
||||
value="50"
|
||||
class="brightness-slider"
|
||||
id="slider-group-${group.id}"
|
||||
oninput="updateGroupBrightnessDisplay('${group.id}', this.value)">
|
||||
oninput="updateGroupBrightnessDisplay('${group.id}', this.value)"
|
||||
onchange="setGroupBrightness('${group.id}', this.value)">
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="group-card-actions">
|
||||
@@ -1692,6 +1693,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Set group brightness immediately when slider changes
|
||||
async function setGroupBrightness(groupId, brightness) {
|
||||
try {
|
||||
const response = await fetch(api(`/groups/${groupId}/set`), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
action: {
|
||||
type: 'power',
|
||||
payload: {
|
||||
power: 'on',
|
||||
brightness: parseInt(brightness)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Request failed');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
const publishedCount = result.execution_plan.filter(p => p.status === 'published').length;
|
||||
|
||||
console.log(`Group ${groupId} brightness set to ${brightness}%: ${publishedCount} devices`);
|
||||
|
||||
addEvent({
|
||||
action: 'group_brightness',
|
||||
group_id: groupId,
|
||||
brightness: brightness,
|
||||
device_count: publishedCount
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to set group brightness:', error);
|
||||
showToast(`Fehler beim Setzen der Helligkeit: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Execute group action
|
||||
async function setGroup(groupId, power, buttonElement) {
|
||||
const allButtons = buttonElement.parentElement.querySelectorAll('button');
|
||||
|
||||
Reference in New Issue
Block a user