 Hey. Hey, how's it going? Hello again. Yeah, I haven't seen you for a while. Yeah, we missed last week. Good old calendaring issues. Yeah, time. Not that anybody on the internet knows that because someone hasn't posted our previous video. So it's pretty much like we've been gone for a month at this point. It is true. It's true. That is coming and this is going to be a good follow up to it. Yeah. So the last video, which will be posted by the time you're watching this, was looking at a pull request in the home assistant skill, a relatively easy one, but just to look at the process of reviewing a pull request. And in particular, in that video, we reviewed the code through the web browser so that we knew that there was nothing bad in there before we pulled the code down onto our device. Yeah. We took a look at a lot of some of the features that you can actually use when you're doing code review inside of the GitHub platform specifically. And we just kind of gave some tips about writing some good code and giving some good feedback. And so I think in this this one, we're really looking to pull down the code and actually start trying to work with a specific pull request to test it. And once we do that, Tony, I promise we'll get around to actually pushing your pull request into the branch. It will happen as soon as we get through the series. Yes. Bear with us. Yes. Cool. So maybe we should just jump straight into it and we're back. Yeah. So this is the PR that we were looking at last week. Magic of the Internet. Yeah. So as a quick refresher, it's a change that improves checking the availability of entities in Home Assistant. And so in Home Assistant world, an entity can be a light or a thermostat or any number of different things. So we've checked the code. We know it's safe. We now want to pull it down onto our device, right? Yep. That's all right. So the code for this pull request, it still lives in Tony 763's account. So it's not in the Microsoft AI skill-Home Assistant repository. It's in Tony 763. So if you mouse over Tony's name there, or actually, if you just click on it, it should take you through to his fork of the repository. And you'll see that we're on the Branch Patch 3, which is where he's done that work. So that's what we're going to try and get down to our device. So what have we got on our device at the moment? We've got Minecraft Core that's sitting in here. And then in Minecraft Core, we've got our skills directory. I know you normally go to Opt. I get lazy. So we've got the Home Assistant skill here. And that's basically it. Aside from that, we've installed the skill IoT control and the Home Assistant. And that's pretty much stock. Yeah. So if we switch into the Home Assistant directory, what we're looking for at the moment. So as I said, Tony's code lives in his fork. So we actually need to add his fork as a remote repository to our skill here on our machine. So we can have a look at what remotes we have already by doing git remote. And you can see we've got origin, which would be the Minecraft original one. And we've got a stratus fork, which I think was when we were doing something. We were actually pushing through one of the changes that I needed. Although that's a good question. I don't remember. Yeah. No, we fixed the... Anyway, we did some bug fixes. Yeah. So in that case, we added a fork for your account. And now we're going to do the same for Tony's. So it's fairly simple to do that. We just have to go back and get the URL for his account, or for his fork, I should say. So it'll be everything up until tree. So we do git remote, add, and then we need an alias for his... Yeah, Tony, and then space, or Tony fork, sure. And then the URL. So the URL, it has to have, obviously, the domain, the author, and then the repository, Minecraft dash home assistant. But the rest of that URL, that was the branch that it was on. So this will add the fork so we can hit enter. And then we want to fetch everything from that fork. Tony. Yeah, that's it. So that's going to go and have a look at everything that's on his fork that's not, that we don't already have. So you can see there's a whole range of feature branches that he's been working on. Tony's been doing a huge amount of work on home assistant. So again, a big thanks to Tony for all that work recently. And the one that we're after today was patch three, right? Yep. So then we can get, check out patch three. So because patch three was unique, you know, there weren't any branches called patch three in the in the Microsoft AI version or in your fork. Then it just assumed that you wanted it from Tony. If there were other people who had also, you know, had a patch three branch, then it probably would have failed and said, you know, I'm not sure which upstream project you want that from. And so then, you know, you can tell it which one, but it should give you some description about what you need to do. It's got some relatively good indicators of like, you know, what's going wrong and how you can fix it. But that's it for this one, because it was such a simple change. It's only code changes. Then that has changed the code that is in our directory on the device. So if we, we could check that if we, what could we do? Is it in the init top? I can't remember where that was staged. Yeah. We could, we could, we could grep init.py for the, for the name of that method, which was we could just look for good point. Why don't instead of using our memory, why don't we just go over here and actually how to what we were looking for. So over in the commits, actually we want to take a look at, apparently I just changed the wrong button. I wanted the file change because that'll give me something to look for, check availability. All right, your private method. So yes, there you go. Yeah. So we can, we can confirm this. It's definitely the code has changed on our class. And microft, even if you have microft running, it will detect that the code has changed in that skill and it will reload the skill. So you don't, shouldn't need to do anything, anything extra for that. If it's a, if it's a larger change or there have been changes in the requirements for the skill, you know, that, that's often one of the big ones. So, you know, if a Python package has changed, then you might need to run, if install dash our requirements.text to, to make sure that all the requirements listed there are, are in fact installed. But for this one was nice and simple. So yeah, now we can, now we can actually test it, right? We need to start my craft and this will go with all. Sure. And then we want to do the, oh, you know what? I should have activated my, my V on and then I can do, take a look at my CLI and we have problem. Mm. Perfect. Indeed. So where is this? Yeah. So this is in the home assistant. And what is our problem? Return result underline function line 121, 122. There we go. So we, we probably want to go and this is just going to be a little bit easier in the web browser. So it's complaining about this, but it's most likely it looks like it looks like it might be one character short of an indent. Oh, yeah, I see what you're saying right there. Yeah. Well, let's give that a, let's give that a test. Yeah, let's, I don't know if you've got tabs or anything in your terminal. Oh yeah, I can do that. What I do this. Yeah, perfect. Make that a little bigger. And so maybe, maybe you have the CLI running in the top. Sure. You'll be able to see then once we make the change to the init.py file, it will, well, that's going to be hard. We'll figure it out. Yeah, you just might be able to see the saving for, but that's fine. If you do, what is it? Control shift underscore the line, I think. Or just jump. If you do control shift underscore, then you should be able to type in the line number 122. Yeah. Oh, he's got a space. That's why I couldn't find my search. All right. Yeah. Yeah, there it is. So if we, yeah, so it's definitely missing one. So we've written that out and it looks like there was another red line. Failed to load. Return false 123. Maybe instead of the CLI, we should do a, just follow the skills log out. But that might be a bit of a secret on the small screen. Well, it's not that small. It's just for you people on the internet to be able to actually read my screen. Yeah. Yeah. Well, and it's because the, the Microsoft CLI has that huge input area. So, but if we do tail dash F and then on bar log, mycroftskills.log. So this is, I actually use this quite often instead of the CLI, because particularly when you're only caring about the skills output, it's a nice, easy way of seeing just that. I just triggered mycroft. I got the little boodooop that it's listening to. It hurt me. Mycroft. All right. So 123. So on 123, return false. That guy right there. Yeah. I'm not even sure what that. Okay. Yeah. All right. So this either needs to come all the way in. So it lines up with the rest of the block. Yeah. Because yeah, that meant that this ended the if statement. Yeah. Yeah. Yeah. I would also, maybe I should double check this, but generally I only use the, the triple quote doc string format for actual doc strings. And if I'm just doing comments in, in a function, then I'll just use the comment. The octothorpe. Sorry, the octothorpe. Oh man. That's a call back there. I used to work with a person that got so angry that people didn't call it an octothorpe. I mean, no. Yeah. Yeah. I mean, it kind of bothers me when people call it a hashtag, because I'm like, it's neither of those things. It's neither a hash nor a tag, right? Like hashtag is literally the tag. It's definitely not hashtag. It's definitely not. But there are people that call it hashtag. I'm like, it's not a hashtag. Like there's so many things you could call this. It's not a hashtag. Is it? Anyway, I'm not, let's not. The intent handle is not defined. I wonder if it's, if it's importing intent file handler and not intent handler. Yes. So, I'm surprised that's, it'll be because, so this is, this is probably related to, that there have been a bunch of updates to this recently. And so this change is working off an older version of the code and doesn't have some of those bug fixes in it. But yeah, we can just add intent underscore handler in that list of imports from Mycroft. Just in case there is another one in there that's, we need a comma after intent file handler. Thank you. The end of my day. This is what their program is all about. Absolutely. Well, it didn't blow up this time. So that's a thing. Hooray! So the, I'm assistant has a, a bunch of mocked tests. So actually do Mycroft dash skill test runner. I think then just opt Mycroft skills and then home assistant. I think that should do it. Just the top level? Yeah, just the top level. Like so. From memory. All right. Well, we don't need to make code changes. I'm going to close this and get rid of that. Yeah. Here we go. Moment of truth. Ran 20 tests. Okay. Yeah. So we can, we can, this shows us that at the very least, it hasn't significantly broken anything, you know, everything is still working as expected. But we probably haven't got any tests specifically in for this method either. So, so to really test this thing, you know, we'd need to hook up a home assistant device and, and then, you know, make an entity available and perform some action on it. And then, and then remove the edge, like leave the entity in home assistant. But make it unavailable and then, and then try and perform the same action and see what happens. All right. So we ran through the automated testing just to make sure that worked. And then off camera, we went to try and get a device that would actually be unavailable. And what we discovered is my device names were not necessarily always being recognized by the home assistant skill. So we went and got a simplified one. And I just have a plug on my desk that's normally for my tea kettle. And so I just, I don't have any flashy displays for you, but we'll be able to show you when a device is offline. So I'm just going to, I'm going to unplug it right now. And well, first I'll show you here that it's actually on. So there's my tea kettle in the UI. And I'm going to just going to unplug this right now. And we already know that it takes up to 60 seconds for home assistant to detect, depending on the polling interval. So if I came back over here and I told it- Just to be clear, that was all one, that was all one entity. Yeah. That was one entity. So if I wanted to do turn on tea kettle here, it says it's turned it on. And the reason why the skill is misreporting that, even though the plug is literally right here, is that home assistant hasn't quite timed out yet. So it's still polling in the background to avoid flapping and stuff like that. Now it's just become unavailable. And so we should be able to test Tony's new skills because, or his addition to the skill. Because previously, if the device was unavailable, there was no feedback for an unavailable device. So in theory, I should try and do this, turn on the tea kettle. And now we get the tea kettle is unavailable. So with this, we can say that, yes, the skill that, the home assistant skill has been upgraded to handle an unavailable entity. Now it doesn't solve the problem of the skill itself, not being able to find the entity, depending on how you've named it. We had all kinds of problems with it. I have about, I probably have about, I don't know, I want to say 80 entities in my home assistant. And even though I only have one thing that has the word desk in it, and happens to be my desk light, it was turning on my bed light for whatever reason. We changed it to lamp, and every once in a while, it wouldn't find the desk lamp. And so there's some work to be done in this skill, still with the entity matching. But with regards to this pull request, I think that we can say that this pull request does exactly as it was intended to. Yeah, yeah, yeah. So even though, so the, the previous to this change, if the tea kettle had been registered inside the skill as an entity, you know, that exists, then it would have just continually tried to turn on and off the tea kettle. But now it actually detects whether or not it has become unavailable, even though the entity does exist in home assistant. So that's awesome. Yeah, I think the whole naming thing is an interesting thing with home assistant too, because often when you're setting them up, if you're not doing it in the context of Minecraft, you're not, you're not thinking about how should I name this entity so that it's easily callable by voice. You're just, you know, I mean, personally, you know, most of us, that are developers would probably calling things like tea dash kettle dash 001 or, you know, maybe not maybe you don't have multiple tea kettles, but like, you know, lantern light 001, lantern light underscore 002 or whatever. And so, yeah, in the skill, we need to work on how we, how we convert those sorts of things into more human readable, human expressible formats. Yeah, that particularly bit me, like you can see here in the output, it says tea dash kettle, because that's actually how I name things, like my long history with Unix tells me, don't put white spaces in anything. And so none of my entities actually have white spaces in them. And that was part of the problem that we have. Like it becomes a little bit of a mouthful to say, turn on, you know, table dash kitchen dash light, right? Because I wasn't able to get some of those things to match. Sometimes it would match, and other times it wouldn't. And it wasn't clear to me why it works sometimes and not others. Hmm. And the duplicate tea kettle there, like that, that's from your home assistant, right? So the deep duplicate tea kettle, what this is, is that inside of MQTT, there is a device name and then what's called a friendly name. And they're two different fields. And for whatever reason, this is being keyed off upon here. So the, I set the friendly field and the MQTT ID to be the same. Just because and for whatever reason, that's being pulled in here. Yeah, right. Well, that's something for us to look at too. Cool. But everything here looks like it's working great. So we've reviewed the code, we gave some feedback on that. And that's been addressed already. And now we've verified that the functionality is working as we expect. The integration tests are all passing. So I think we're good to go. I think so too. So we'll wrap that up off camera and we'll come back for our outro as it were. Yeah. So that kind of wraps up the series. So in this kind of mini series that we have, we covered how you deal as a maintainer with incoming code. So taking a look at it in the web browser, making sure the code isn't going to do anything obviously malicious before pulling it down. We pulled it down to our system. We ran the mycroft unit tests on it to make sure that all of the unit tests were still passing after the new code was added. And then we took a look at home assistant. So I have an active home assistant and I simply removed a plug to make it unavailable. And tested the code again. And we verified that the code actually does what it says it's going to do with an unavailable entity. And that pretty much wraps up the whole purpose of this kind of mini series. So we'll be doing other videos moving forward, but we're always open to community feedback. We have some ideas together that we're going to keep plugging away on. But if there's anything in particular that you guys want us to cover, or you can even do some sort of Q&A, we'd be happy to answer some questions. So if we get some feedback or anything like that, it would be great for us to feel connected to the community. Yeah, for sure. Any questions you have, we're always happy to answer those. And let us know what you want us to cover, what things are dripping you up. But hopefully, as I said, hopefully this video and this little mini series can help people to review pull requests that are out there and help us to get those changes merged in more quickly and shipped out to everyone in the community. So yeah, if you want to help out, you're not sure where to start, then definitely come by the mycroft chat, the chat.microft.ai and jump into the skills or the dev channels and people in there are very friendly, so I'm sure they'll point you in the right direction. There's plenty of pull requests to take a look at. There's lots of potential new functionality. We just need to make sure that everything's safe and functional and working as described before we push that out to people. So we'd love your help. Absolutely. So I think we'll wrap this up here and we'll pick it up in the next video, whatever topic we decide to do next time. So until next time. All right, see us. Ciao.