Skip to content

Commit 634d9ef

Browse files
committed
Add null check.
1 parent 27d2f8f commit 634d9ef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

iot-devices/models/animals.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ function randomWalk(state, deviceId, lng, lat) {
236236
let moveFactor = 6;
237237
const weather = myCache.get('weather');
238238

239-
if (weather === 'raining' || state.o.includes(ANIMAL_STATUS.ILL)) {
239+
if (
240+
weather === 'raining' ||
241+
(state.st && state.st.includes(ANIMAL_STATUS.ILL))
242+
) {
240243
moveFactor = 8;
241-
} else if (state.o.includes(ANIMAL_STATUS.IN_CALF)) {
244+
} else if (state.st && state.st.includes(ANIMAL_STATUS.IN_CALF)) {
242245
moveFactor = 7;
243246
}
244247

0 commit comments

Comments
 (0)