1
00:00:00,180 --> 00:00:08,400
Let's continue to extend the terrorism patrol vision, one slow to be able to receive input from the

2
00:00:08,490 --> 00:00:12,810
consumer and then based on that input, decide whether to turn the pump on or off.

3
00:00:13,410 --> 00:00:21,690
And I just remind you that in the Adreno slash is pithily to sketch, we are publishing information

4
00:00:21,690 --> 00:00:29,880
or the value of the soil humidity sensor, the tumour to the soil humidity topic, which I've highlighted

5
00:00:29,880 --> 00:00:30,290
here.

6
00:00:30,690 --> 00:00:39,570
So I'm going to copy the topic because we need it immediately in our kitty in.

7
00:00:41,830 --> 00:00:42,370
Noad.

8
00:00:44,510 --> 00:00:52,250
So that this is the topic to which we'll subscribed to receive information about this, so your community

9
00:00:52,730 --> 00:01:00,790
is confident going for a zero here of quality of service, and I'll call this note, get humidity.

10
00:01:02,510 --> 00:01:06,620
So I should say soil humidity, good soil humidity.

11
00:01:06,650 --> 00:01:07,220
All right.

12
00:01:07,460 --> 00:01:11,140
Let's add a widget to the user interface.

13
00:01:11,540 --> 00:01:13,190
Let's use the gauge.

14
00:01:13,490 --> 00:01:21,080
And I'd like to place the widget in a new group called Soil Humidity.

15
00:01:21,530 --> 00:01:31,640
So let's go in it and create a new group and they will go in the terrarium tab as well.

16
00:01:31,640 --> 00:01:32,600
And I'll call that.

17
00:01:34,380 --> 00:01:41,160
Soil humidity like this with six is fine.

18
00:01:41,700 --> 00:01:45,930
All right, so there goes there, there's going to be a tide gauge.

19
00:01:51,800 --> 00:01:59,820
For the label, let's give it the label of soil humidity for real value.

20
00:02:00,410 --> 00:02:04,330
I'm OK with the value format and don't worry about the units.

21
00:02:04,340 --> 00:02:05,670
The range is important.

22
00:02:05,680 --> 00:02:13,610
It goes from zero to one thousand and twenty three since we have a 10 bit analog to digital converter

23
00:02:14,390 --> 00:02:21,830
and can copy the soil humidity to the name of the node as well.

24
00:02:22,280 --> 00:02:26,520
Let's deploy and see what we have going to go into the dashboard.

25
00:02:26,540 --> 00:02:33,740
Here's the raw humidity and I should be able to just turn the knob of the particular mirror and you

26
00:02:33,740 --> 00:02:35,900
can see that it is being updated.

27
00:02:36,500 --> 00:02:37,150
Excellent.

28
00:02:37,940 --> 00:02:47,270
I'm going to move the dashboard to the side so you can see what is happening on the Adreno or on the

29
00:02:47,290 --> 00:02:50,210
E.S.P 32 and the values match.

30
00:02:50,720 --> 00:02:50,920
I see.

31
00:02:50,960 --> 00:02:55,910
If I move the consumer again, you can see that it's matching.

32
00:02:58,440 --> 00:03:00,260
So you can stop this crawl here.

33
00:03:00,270 --> 00:03:06,570
Notice that the value that was sent in, I know that because I've got the printout from the debugger

34
00:03:06,570 --> 00:03:14,610
here is one fifty four, which is the value that was sent over to the to the flu.

35
00:03:15,790 --> 00:03:21,180
But the most current value is one hundred and sixty one, which is not the same as what was sent and

36
00:03:21,180 --> 00:03:23,360
received by no read.

37
00:03:23,850 --> 00:03:30,150
But the difference between one fifty four and one sixty one is less than 10 and therefore the latest

38
00:03:30,150 --> 00:03:34,310
one, which is 161, was not sent over to note read.

39
00:03:34,560 --> 00:03:41,700
So that way in a way, throttle controlling how many updates the E.S.P 32 will be sending to no greater

40
00:03:41,700 --> 00:03:44,040
think the value 10 is appropriate for this.

41
00:03:45,240 --> 00:03:45,810
All right.

42
00:03:48,060 --> 00:03:55,140
So now that we are getting so your humidity values from the ECB to we can actually use them to control

43
00:03:55,140 --> 00:03:56,490
the pump, so.

44
00:03:58,350 --> 00:04:03,630
To do this, we're going to use a function, so let's pick a function.

45
00:04:06,600 --> 00:04:08,400
You connected.

46
00:04:10,610 --> 00:04:14,990
To show your humility to the integrity in Noad.

47
00:04:16,030 --> 00:04:24,220
To move things around a little, to make space, and then from here, I want to connect it directly

48
00:04:24,220 --> 00:04:29,680
to the pump state, but I'm not going to do that yet because I want to rethink a little bit about how

49
00:04:29,680 --> 00:04:37,990
many times I want to update my E.S.P 32 and change the state of the pump again, just like I'm throttling

50
00:04:37,990 --> 00:04:44,800
the amount of messages or updates that are coming from the HP 32 to the node rate flow.

51
00:04:44,830 --> 00:04:52,450
I also want to do a bit of throttling of updates from the flow itself to the E.S.P 30 to talk more about

52
00:04:52,450 --> 00:04:53,060
it in a moment.

53
00:04:53,710 --> 00:04:59,540
Let's go inside the functional and at a bit of JavaScript, but give it a name.

54
00:04:59,560 --> 00:05:03,280
Call it pump operation.

55
00:05:03,820 --> 00:05:04,250
Oops.

56
00:05:08,470 --> 00:05:15,160
And then inside of JavaScript, I want a bit of code that will do a bit of testing of the value that

57
00:05:15,250 --> 00:05:20,100
the flow has received from the consumer against the threshold.

58
00:05:20,620 --> 00:05:22,300
So start with.

59
00:05:23,740 --> 00:05:25,030
A pump state.

60
00:05:31,500 --> 00:05:38,340
Viable in its initial values are going to be zero, so this is the value that the function will be sending

61
00:05:38,460 --> 00:05:46,260
to its output, to the liquidity out pump, which is the same kind of values that we have manually entered

62
00:05:46,260 --> 00:05:53,300
in the manual pump control widget, or I never got a statement.

63
00:05:53,340 --> 00:06:01,400
So if the payload is arbitrarily, choose the value.

64
00:06:01,420 --> 00:06:02,250
Five hundred.

65
00:06:02,280 --> 00:06:10,020
So if the value stored in the payload coming from the soil committed to node is over five hundred,

66
00:06:11,160 --> 00:06:11,670
then.

67
00:06:14,730 --> 00:06:16,050
Make pump state.

68
00:06:21,280 --> 00:06:29,620
One in this will turn on the pump or else the pump should be Xebra.

69
00:06:36,310 --> 00:06:43,960
All right, and then for the return message, because it is connected to all this will be connected

70
00:06:43,960 --> 00:06:49,270
to another node, I want to create a payload that would.

71
00:06:51,130 --> 00:06:55,750
And the value of this payload will be pump state.

72
00:06:58,210 --> 00:07:07,720
All right, so this should be OK to close in the moment of truth very soon to make sure it works.

73
00:07:07,750 --> 00:07:08,170
All right.

74
00:07:13,370 --> 00:07:19,280
To move these away, just make a bit of space now, as I was saying, I want to do thermal control so

75
00:07:19,280 --> 00:07:23,650
that I don't update the expected to unnecessarily.

76
00:07:23,660 --> 00:07:32,120
I only want to update the security when there is a change in the pump status that the pump operation

77
00:07:32,120 --> 00:07:33,520
function is calculating.

78
00:07:33,890 --> 00:07:37,100
So to do that, I'm going to use another widget.

79
00:07:38,950 --> 00:07:46,510
Which is up here, it's CRB widget, and with the IBM widget, I am able to publish only changes of

80
00:07:46,510 --> 00:07:48,760
whatever the operation note is sending.

81
00:07:49,300 --> 00:07:55,750
So this is going to block unless the value is different, the new values different, the previous value

82
00:07:55,750 --> 00:07:58,020
and it's going to forward the payload in that case.

83
00:07:58,660 --> 00:08:01,540
So give it a name update.

84
00:08:01,990 --> 00:08:09,580
The pump state changed, right.

85
00:08:10,600 --> 00:08:13,300
And connect this output.

86
00:08:14,610 --> 00:08:25,270
To the kitty out widget again to reposition the widgets like that.

87
00:08:26,700 --> 00:08:33,330
Now that's one more thing that I also want to implement or change, actually, and I want the pump state

88
00:08:34,020 --> 00:08:42,420
outputs both in the dashboard and the Dipak one to be connected to my igby node because that's now in

89
00:08:42,420 --> 00:08:47,470
control of changes and that's in control of telling the utility what to do with the motor.

90
00:08:47,850 --> 00:08:53,490
So I'm going to delete these two wires and reconnect them to the other node.

91
00:08:55,640 --> 00:09:03,200
And of course, I want the pump control widget to directly control the state anymore.

92
00:09:03,380 --> 00:09:08,550
I want this to also pass through the R, b, e note like that.

93
00:09:10,160 --> 00:09:10,730
All right.

94
00:09:13,170 --> 00:09:14,890
That appeared to make it look a little better.

95
00:09:15,330 --> 00:09:22,510
So this should be good to go now and to test, so let's deploy and try it out.

96
00:09:22,530 --> 00:09:29,490
I'm going to move the consumer to reach a value above five hundred and see if the motor starts.

97
00:09:42,030 --> 00:09:44,900
So nothing happened with Emoto, which see what is happening here.

98
00:09:51,240 --> 00:09:51,920
Nothing.

99
00:09:52,440 --> 00:09:53,990
Let's see why not.

100
00:09:54,600 --> 00:10:06,780
Five, five, six, nine, OK, so nothing happens with the Wynnum changing the value of the matter.

101
00:10:06,800 --> 00:10:07,870
What about the gun control?

102
00:10:07,890 --> 00:10:08,520
Does it work?

103
00:10:10,640 --> 00:10:18,040
Pinkerton is working, so let's go back to Oslo and see why the pump control is not working.

104
00:10:19,600 --> 00:10:28,120
So we know that the venues are updating correctly because we can see the state of the soil humidity

105
00:10:29,830 --> 00:10:34,260
gauge changing that something is happening in here.

106
00:10:36,880 --> 00:10:38,410
And of course, there is a typo.

107
00:10:38,420 --> 00:10:44,380
So notice that there is a payload incorrectly spelled, so she'd be like that.

108
00:10:44,830 --> 00:10:56,350
All right, let's try again to deploy and move the matter to above five hundred and that it's working.

109
00:10:58,330 --> 00:10:59,250
Turn it off.

110
00:11:02,180 --> 00:11:02,790
Perfect.

111
00:11:02,960 --> 00:11:08,450
And the switch is also working, right?

112
00:11:10,430 --> 00:11:11,750
So that's pretty good.

113
00:11:11,780 --> 00:11:13,490
Let's move on to the next lecture.

114
00:11:13,500 --> 00:11:18,990
We will do a recap of what we've done in this section and prepare for the next iteration of.
