@eohjsc/react-native-smart-city 0.3.17 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -22,8 +22,8 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
22
22
|
|
|
23
23
|
// eslint-disable-next-line no-unused-vars
|
|
24
24
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
25
|
-
const [value, setValue] = useState();
|
|
26
25
|
const valueDefault = 28;
|
|
26
|
+
const [value, setValue] = useState(valueDefault);
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
@@ -40,15 +40,12 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
42
|
if (!config) {
|
|
43
|
-
setValue(valueDefault);
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
const configValue = configValues[config];
|
|
48
47
|
if (configValue !== null && configValue !== undefined) {
|
|
49
48
|
setValue(configValue);
|
|
50
|
-
} else {
|
|
51
|
-
setValue(valueDefault);
|
|
52
49
|
}
|
|
53
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
51
|
}, [JSON.stringify(configValues)]);
|
|
@@ -55,7 +55,6 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
const triggerAction = useCallback(async () => {
|
|
58
|
-
setTempIsOn((prev) => !prev);
|
|
59
58
|
switch (sensor?.device_type) {
|
|
60
59
|
case DEVICE_TYPE.ZIGBEE:
|
|
61
60
|
if (action_on_data && action_off_data) {
|
|
@@ -75,11 +74,10 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
75
74
|
}
|
|
76
75
|
break;
|
|
77
76
|
case DEVICE_TYPE.LG_THINQ:
|
|
77
|
+
setTempIsOn((prev) => !prev);
|
|
78
78
|
if (action_data) {
|
|
79
79
|
await doAction(action_data, JSON.stringify({ value: !isOn }));
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
updateStatusFromPusher();
|
|
83
81
|
break;
|
|
84
82
|
default:
|
|
85
83
|
if (action_data) {
|
|
@@ -98,6 +96,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
98
96
|
}
|
|
99
97
|
break;
|
|
100
98
|
}
|
|
99
|
+
updateStatusFromPusher();
|
|
101
100
|
if (sensor?.is_managed_by_backend) {
|
|
102
101
|
configuration?.config &&
|
|
103
102
|
sensor?.device_type !== 'GOOGLE_HOME' &&
|
|
@@ -130,7 +129,13 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
130
129
|
if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
|
|
131
130
|
watchMultiConfigs([configuration.config]);
|
|
132
131
|
}
|
|
133
|
-
}, [sensor, configuration.config]);
|
|
132
|
+
}, [sensor, configuration.config, getIsOnValue]);
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (sensor?.device_type !== DEVICE_TYPE.LG_THINQ) {
|
|
136
|
+
setTempIsOn(getIsOnValue());
|
|
137
|
+
}
|
|
138
|
+
}, [getIsOnValue, sensor?.device_type]);
|
|
134
139
|
|
|
135
140
|
const Component = useMemo(() => {
|
|
136
141
|
return getComponent(actionGroup.template);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../configs';
|
|
2
|
+
import { Colors, Constants } from '../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 16;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 126;
|
|
3
8
|
|
|
4
9
|
export default StyleSheet.create({
|
|
5
10
|
container: {
|
|
@@ -71,6 +76,10 @@ export default StyleSheet.create({
|
|
|
71
76
|
margin: 0,
|
|
72
77
|
padding: 0,
|
|
73
78
|
},
|
|
79
|
+
wrapItemStyle: {
|
|
80
|
+
height: heightItem,
|
|
81
|
+
marginVertical: 0,
|
|
82
|
+
},
|
|
74
83
|
camera: {
|
|
75
84
|
width: 1,
|
|
76
85
|
height: 1,
|