From 387ecacef5be2edcec1ca6a7679dcc78017d4ec5 Mon Sep 17 00:00:00 2001 From: KremeCN <3265494849@qq.com> Date: Fri, 28 Aug 2026 07:07:21 +0800 Subject: [PATCH] feat(socket): update smart socket defaults (#12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - change the default socket device name from Zigbee插座控制器 to 智能插座 - update new default scenes, in-memory defaults, and Local Experience simulation data to use the new gateway name - remove the duplicated Direct control section from the smart socket detail screen, keeping the main power control - remove the unused direct-control strings ## Data behavior - existing configured devices are not renamed - existing persisted scenes are not migrated - only newly created default content uses 智能插座 ## Verification - ./gradlew.bat :android:app:assembleDebug --no-daemon - installed on mulator-5554 - confirmed the Local Experience device card shows 智能插座 - confirmed the socket detail screen has no Direct control section or duplicate ON/OFF buttons Automated tests were not run. Reviewed-on: https://git.kimico.de/Flagship/abox-mgr/pulls/12 Co-authored-by: KremeCN <3265494849@qq.com> --- .../defaults/ABoxDefaultContentInitializer.kt | 2 +- .../abox/manager/ui/socket/SocketScreen.kt | 35 +------------------ .../src/main/res/values-zh-rCN/strings.xml | 3 -- android/app/src/main/res/values/strings.xml | 3 -- .../automation/data/RoomSceneRepository.kt | 12 +++---- .../manager/domain/InMemorySceneRepository.kt | 12 +++---- .../simulation/SimulationDeviceCatalog.kt | 4 +-- 7 files changed, 16 insertions(+), 55 deletions(-) diff --git a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/defaults/ABoxDefaultContentInitializer.kt b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/defaults/ABoxDefaultContentInitializer.kt index 416c7be..07aaf29 100644 --- a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/defaults/ABoxDefaultContentInitializer.kt +++ b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/defaults/ABoxDefaultContentInitializer.kt @@ -49,7 +49,7 @@ class ABoxDefaultContentInitializer @Inject constructor( is DomainResult.Failure -> return false } val defaults = listOf( - DeviceName("Zigbee插座控制器") to DeviceType.SOCKET, + DeviceName("智能插座") to DeviceType.SOCKET, DeviceName("温湿度传感器") to DeviceType.TEMPERATURE_HUMIDITY, DeviceName("红外控制器") to DeviceType.INFRARED, ) diff --git a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/socket/SocketScreen.kt b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/socket/SocketScreen.kt index b11ebdf..4cba870 100644 --- a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/socket/SocketScreen.kt +++ b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/socket/SocketScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll @@ -24,7 +23,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text @@ -208,42 +206,11 @@ fun SocketScreen( } } - Text( - text = stringResource(R.string.socket_direct_control), - style = MaterialTheme.typography.titleMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp), - ) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(12.dp), - ) { - OutlinedButton( - onClick = { onEvent(SocketUiEvent.SetPower(SocketPowerState.ON)) }, - enabled = state.isActionEnabled && state.powerState != SocketPowerState.ON, - modifier = Modifier.weight(1f).height(56.dp), - ) { - ABoxIcon(ABoxIconKey.POWER, "开启插座", modifier = Modifier.size(20.dp)) - Spacer(Modifier.width(8.dp)) - Text(stringResource(R.string.socket_action_turn_on)) - } - - OutlinedButton( - onClick = { onEvent(SocketUiEvent.SetPower(SocketPowerState.OFF)) }, - enabled = state.isActionEnabled && state.powerState != SocketPowerState.OFF, - modifier = Modifier.weight(1f).height(56.dp), - ) { - ABoxIcon(ABoxIconKey.POWER, "关闭插座", modifier = Modifier.size(20.dp)) - Spacer(Modifier.width(8.dp)) - Text(stringResource(R.string.socket_action_turn_off)) - } - } - Text( text = stringResource(R.string.socket_confirmation_hint), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.fillMaxWidth().padding(top = 14.dp), + modifier = Modifier.fillMaxWidth(), ) } } diff --git a/android/app/src/main/res/values-zh-rCN/strings.xml b/android/app/src/main/res/values-zh-rCN/strings.xml index 5f289f9..5e117e2 100644 --- a/android/app/src/main/res/values-zh-rCN/strings.xml +++ b/android/app/src/main/res/values-zh-rCN/strings.xml @@ -223,8 +223,6 @@ 已离线 未知状态 切换电源 - 开启插座 - 关闭插座 正在切换状态… 已于 %1$s 确认状态 @@ -361,7 +359,6 @@ 用于匹配和控制网关设备,必须与网关中的名称完全一致。 用于匹配和读取网关设备,必须与网关中的名称完全一致。 保存设备名称 - 直接控制 指令只有在网关回读到结果状态后才会确认。等待确认时可使用刷新操作。 当前读数 实时环境监控 diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 3fc5def..502a8a2 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -223,8 +223,6 @@ Offline Unknown Toggle Power - Turn ON - Turn OFF Updating socket state… Confirmed at %1$s @@ -361,7 +359,6 @@ Used to match and control the gateway device. It must exactly match the gateway name. Used to match and read the gateway device. It must exactly match the gateway name. Save device name - Direct control A command is confirmed only after the gateway reports the resulting state. Refresh while confirmation is pending. Current readings Live environment monitoring diff --git a/android/feature/automation/src/main/kotlin/com/flagship/abox/manager/automation/data/RoomSceneRepository.kt b/android/feature/automation/src/main/kotlin/com/flagship/abox/manager/automation/data/RoomSceneRepository.kt index a925617..bfd45ba 100644 --- a/android/feature/automation/src/main/kotlin/com/flagship/abox/manager/automation/data/RoomSceneRepository.kt +++ b/android/feature/automation/src/main/kotlin/com/flagship/abox/manager/automation/data/RoomSceneRepository.kt @@ -99,14 +99,14 @@ class RoomSceneRepository( private fun defaultScenes(profileId: ProviderProfileId): List = listOf( Scene( - SceneId("${profileId.value}:scene-arriving-home"), profileId, "回家模式", "开启 Zigbee 插座控制器", + SceneId("${profileId.value}:scene-arriving-home"), profileId, "回家模式", "开启智能插座", AutomationType.MANUAL, true, SceneIcon.HOME, SceneColor("#4CAF50"), - actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:arrive:socket"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.ON)), + actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:arrive:socket"), profileId, DeviceName("智能插座"), SocketPowerState.ON)), ), Scene( - SceneId("${profileId.value}:scene-leaving-home"), profileId, "离家模式", "关闭 Zigbee 插座控制器", + SceneId("${profileId.value}:scene-leaving-home"), profileId, "离家模式", "关闭智能插座", AutomationType.MANUAL, true, SceneIcon.AWAY, SceneColor("#FF8A65"), - actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:leave:socket"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.OFF)), + actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:leave:socket"), profileId, DeviceName("智能插座"), SocketPowerState.OFF)), ), Scene( SceneId("${profileId.value}:scene-temperature-alert"), profileId, "高温提醒", "室温高于 28°C 时发送提醒", @@ -118,8 +118,8 @@ class RoomSceneRepository( SceneId("${profileId.value}:scene-cooling-auto"), profileId, "高温自动降温", "当室温高于 28°C 时开启插座", AutomationType.AUTOMATIC, true, SceneIcon.THERMOSTAT, SceneColor("#26A69A"), triggers = listOf(SceneTrigger.Temperature(SceneTriggerId("${profileId.value}:cooling-temp"), DeviceName("温湿度传感器"), ComparisonOperator.GREATER_THAN, 28.0, "温度高于 28°C")), - conditions = listOf(SceneCondition.SocketPower(SceneConditionId("${profileId.value}:cooling-socket"), DeviceName("Zigbee插座控制器"), SocketPowerState.OFF)), - actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:cooling:on"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.ON)), + conditions = listOf(SceneCondition.SocketPower(SceneConditionId("${profileId.value}:cooling-socket"), DeviceName("智能插座"), SocketPowerState.OFF)), + actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:cooling:on"), profileId, DeviceName("智能插座"), SocketPowerState.ON)), ), ) } diff --git a/domain/src/main/kotlin/com/flagship/abox/manager/domain/InMemorySceneRepository.kt b/domain/src/main/kotlin/com/flagship/abox/manager/domain/InMemorySceneRepository.kt index 01db39a..0dcce70 100644 --- a/domain/src/main/kotlin/com/flagship/abox/manager/domain/InMemorySceneRepository.kt +++ b/domain/src/main/kotlin/com/flagship/abox/manager/domain/InMemorySceneRepository.kt @@ -111,7 +111,7 @@ class InMemorySceneRepository : SceneRepository { id = SceneId("${profileId.value}:scene-arriving-home"), profileId = profileId, name = "回家模式", - description = "开启 Zigbee 插座控制器", + description = "开启智能插座", type = AutomationType.MANUAL, enabled = true, icon = SceneIcon.HOME, @@ -120,7 +120,7 @@ class InMemorySceneRepository : SceneRepository { SceneAction.SocketPower( id = SceneActionId("${profileId.value}:scene-arriving-home:socket-1"), profileId = profileId, - deviceName = DeviceName("Zigbee插座控制器"), + deviceName = DeviceName("智能插座"), powerState = SocketPowerState.ON, ), ), @@ -129,7 +129,7 @@ class InMemorySceneRepository : SceneRepository { id = SceneId("${profileId.value}:scene-leaving-home"), profileId = profileId, name = "离家模式", - description = "关闭 Zigbee 插座控制器", + description = "关闭智能插座", type = AutomationType.MANUAL, enabled = true, icon = SceneIcon.AWAY, @@ -138,7 +138,7 @@ class InMemorySceneRepository : SceneRepository { SceneAction.SocketPower( id = SceneActionId("${profileId.value}:scene-leaving-home:socket-1"), profileId = profileId, - deviceName = DeviceName("Zigbee插座控制器"), + deviceName = DeviceName("智能插座"), powerState = SocketPowerState.OFF, ), ), @@ -191,7 +191,7 @@ class InMemorySceneRepository : SceneRepository { conditions = listOf( SceneCondition.SocketPower( id = SceneConditionId("${profileId.value}:cond-cooling-socket"), - deviceName = DeviceName("Zigbee插座控制器"), + deviceName = DeviceName("智能插座"), expectedState = SocketPowerState.OFF, ), ), @@ -199,7 +199,7 @@ class InMemorySceneRepository : SceneRepository { SceneAction.SocketPower( id = SceneActionId("${profileId.value}:scene-cooling:socket-1"), profileId = profileId, - deviceName = DeviceName("Zigbee插座控制器"), + deviceName = DeviceName("智能插座"), powerState = SocketPowerState.ON, ), ), diff --git a/runtime/simulation/src/main/kotlin/com/flagship/abox/manager/simulation/SimulationDeviceCatalog.kt b/runtime/simulation/src/main/kotlin/com/flagship/abox/manager/simulation/SimulationDeviceCatalog.kt index d72455d..fded0e8 100644 --- a/runtime/simulation/src/main/kotlin/com/flagship/abox/manager/simulation/SimulationDeviceCatalog.kt +++ b/runtime/simulation/src/main/kotlin/com/flagship/abox/manager/simulation/SimulationDeviceCatalog.kt @@ -29,9 +29,9 @@ class SimulationDeviceCatalog : DeviceCatalog { private fun defaultDevices(profileId: ProviderProfileId): List = listOf( DeviceDescriptor( - id = DeviceId("${profileId.value}:Zigbee插座控制器"), + id = DeviceId("${profileId.value}:智能插座"), profileId = profileId, - name = DeviceName("Zigbee插座控制器"), + name = DeviceName("智能插座"), type = DeviceType.SOCKET, ), DeviceDescriptor(