In this lecture, we are going to implement the necessary functionality in the note read flow so that
we can get the which it is necessary to calibrate the pump a threshold.
And I've already created the new components of the flow.
You are updated version through the integration for and it's this part of the flow here.
This is the new part of the flow.
But what I'll do is I'm going to delete.
The flow, our vision for and then continue from Vision three, just make sure that there are no missing
bits and pieces in the way that I implement it.
So I'm going to start first by exporting vision through which the current flow situation for version
three of the flow.
Copy that to the clipboard and go back into the burger menu.
Choose import, paste the chasten file.
Select new flow and import.
Right now, I'm going to do a rename as soon as the notification gets out of the way, rename this into
a version for.
Right, and enable it.
Click, click on the enable button.
All right, so I want to add the new part of this movie down here.
We can call it a Lou.
I'm going to make a little bit of room.
They did down there and of course, the first thing that I'm going to add is this the numerical import
widget, this note here, this implements the widget.
And in it, what I want to do is to set the range of values that this widget would allow us to select.
So because we are talking about analog input, that is Timbits in a number of bits, we've got a range
of zero to one thousand and twenty three.
And it's going to be tedious to change your values.
If you want, I'll make it 10.
I'm going to give it an appropriate name.
Let's call this threshold and call the name of the node as well.
Pump Threshold's.
That's the label that will appear in the dashboard.
Also going to set up tooltip think this is useful.
I say that this sets a row limit, the value of which is turned on.
So lets you hover your mouse over the widget.
You'll see this message for information for the user and the position of this node widget.
I'm going to put it into a new group.
Which belongs in the terrorism tab, and I will call this group.
The threshold should be a bit more specific to set the threshold.
OK, with six is enough.
All right, so let's make let's give this a width of six and the rest is all good.
So I'm going to click on Done and there's this note.
This first note implemented.
Then what I want to do is whatever the user selects.
This has to go into a flow variable because we will need to take that into account in our pump operation
function when the function is making a decision here of whether to start the pump or not.
So at the moment, this is a fixed five hundred.
But once we have the ability to set arbitrary threshold instead of 500, we will need to use the actual
threshold that the user has said.
So we'll replace that with a flow variable.
And while I'm here, I'm just going to set it right now or change make the necessary change right now.
And what I want to do is to get a flow, get the value stored in flow variable with name, soil humidity
threshold.
OK, like this, so no fixed value or get the life soil humidity threshold from this low.
OK, this is good.
Close the dialogue and let's continue now with another function.
We to put a new function here so that we can actually set the threshold.
So I'm going to go in here.
I'm just going to copy the code.
So don't type it and make typos.
This is going to be the flow set function, which sets the flow variable.
So you're committed to a threshold with whatever value has been passed to the function node from the
pump threshold, numerical input node.
And we don't really care too much about what is return to serve.
I'm just going to return message.
But just to be good actually with this and consistent, I'm just going to return the message paillard
actually I'm going to return the whole message this fine so that we can set something useful after this
note, such as a debug node for the name.
Can you call these things cept.
Humidity know.
Humidity threshold, to be more specific
like this.
And click, OK, now, the next thing that I want to do here is to use an empty outmoded.
This one here, so that any value that the user sets for the threshold is sent to the ISP 32 controller
via the security broker.
The next thing that I want to do here is to use it and get it out nood so that when the user changes
the threshold in the red dashboard, this information is sent to the speaker to via the broker, so
that the sketch running on the ESB 32 can take this arbitrary value into account when it sends an update
to the flow.
And I'm going to show you the necessary change that we need to make in the USA to sketch in the next
election so that it can read this number and use it.
So for now, I'm going to configure the integrity out node and give it a name first.
And now we are going to create a new topic, the liquidity broker, which is going to beat this.
So the soil humidity threshold, as usual, let's go for quality of service zero and click on Turn Connect
these two together.
And we could also welcome here here to put in a new debug node so that we can see.
I said, I'm tired of you.
It should be concise, the current humidity.
Threshold.
Right back in here in the threshold node, I think just make sure that everything is correct here.
Yup, everything looks good.
Now I can publish this flow.
And check it out here.
Here's a new group, you can see that here's a widget that allows me to change and set the threshold.
But the problem here is that it starts at zero.
So obviously now for me to set this widget to five hundred, I have to keep clicking on the up arrow
and just not a very good user interface.
And I'm just going to refresh and can feed staes.
But if I restart the whole note read service, this is going to go back to zero and I'm going to retain
its value.
So before I actually marked these modifications as complete, there's one more thing that I need to
do, and that is to use and inject node to inject a initial value into the threshold node.
So let's go inside here inside the inject to give it a name first.
Let's say set the default threshold and this is going to be a number.
And let's start with five hundred our values, a reasonable first number.
And then because I want this to actually happen without me having to click on this button to enable
it just connected to right now I have to actually triggered by clicking on this button here, but I
want this number to be injected into the threshold node pretty much as soon as I deploy or I start this
flow.
So I'm going to go down here and click on inject once after, let's say, zero point four.
Make it one second just to begin with.
And that's it.
We only need to inject it once and then we have done with this.
So check this out if I'm going to make this a little bit more delay to demonstrate how this works or
make that five seconds.
So what I'll do is I'm going to deploy this flow and have a look at what happens to this number right
here about five seconds later.
So deploy and see.
There you go.
So now it's set automatically to a much better value of five hundred.
All right, so this works.
So I will change this with five point one seconds after we deploy the flow.
This value will be reset.
OK, so that's about it.
With the modifications necessary in the flow itself to give us the widget.
One last thing I'll do here is actually change the positioning of the groups so that.
The threshold set books is closer to the left side are the way I see it, is for the user interface
components that require input or offer input options to the user.
Go to the left and then the rest of the readings go into the right side.
So let's move this say up here and redeploy, OK?
And it's better the flow works now.
We can actually test it.
I'll turn on the power supply.
And let's set.
The threshold to say six hundred and.
Try to increase.
The humidity.
And it works.
For turn it down a little, said to.
Five seventy.
We need to actually trigger the function by changing the name.
She did not pick it up automatically, that just because on the flow, the value is said to below the
needle value.
So the threshold value is below the needle value unless I trigger the function to work this function
to work, which only happens after it gets input from the security broker.
We are not going to get any decisions about the pump state.
So this is a normal operation.
OK, so it works, but I still love the game.
But I also want to make a small change in the history theory to sketch so that this new threshold value
is taken into account by the EPA to show that it does not sent any updates to the flow which would trigger
the function here unless the soil humidity threshold from the sensor is above the threshold.