4: Beginner's Shelly RGBW2 + MQTT + Node Red Overview

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to learn how to control this led strip using this shelley rgb w2 relay as well as node red and mqtt now if none of that makes sense to you then this is the video for you because this is all very new to me i just learned how this all worked and decided to factory reset everything so i could show you yes that's right i did factory reset everything and i kind of regret it a little bit because i am having a difficult time this is about my fifth time recording this video trying to get this shelley relay to connect so let's see if we can get that working so i am going to go into the shelly app and add a device and i've already put in my wi-fi account and password and then i'm going to choose the shelly rgbw2 as the module my phone should want to join the network so i'm going to have it join and we'll just wait and see what happens this is when it's nice to have a cup of tea in theory what's happening right now is my phone is connecting directly to the shelly and giving it my wifi's name and password so that it can join my wi-fi network and be on the same network as all my other stuff and hopefully that's what's happening oh one of the devices failed to be included so here's what i'm going to do just to test out i'm going to go to settings and connect directly to it on my phone and i'm looking at the details and i see that private address is turned off i thought that might be the problem before uh was a security feature of the iphone was trying to make it um anonymous and it wasn't happy with that for some reason but it seems to be working and if i go into the info i can see that the ip address of this shelley relay gave me was 192.168.33.2 now because i'm used to this i know i can go to 192.168.33.1 and connect to this shelly relay directly so now i'm just connected straight to this i'm not on my own wi-fi anymore but i can now turn it off turn it on and change the colors so hopefully that will help my uh setting this up manually instead so what i'm going to do all i care about is i want it to be on my wi-fi network so if i go to internet and security and wi-fi mode client i'm going to check the box next to connect the shelley device to an existing wi-fi network i'm going to choose my wi-fi network i'll hide this and then we'll save it and ideally it's going to try and connect to my wifi at home and if that does work it should kick me off of its wi-fi and put me on my own home wi-fi so if i refresh this page i should get an error message because i'm now connected back to my regular network not its little local network that looks to be the case we'll go back to the shelley app and when i go to the home screen of the shelly app it says discover devices and there's the shelley rgb w2 i'm going to add it and i'll choose my garage because that's the only room that i've set up so far and save device invalid name okay um rgb led strip one i don't know if we're allowed to do spaces we'll find out soon enough would you like to connect the shelley device to the cloud no that's kind of the whole point of this whole series is being in control of my own system okay so now that looks like it worked we just had to kind of manually kick start it and now i can turn it off and turn it back on and if i go into it i can choose the color and it appears to be working just fine and i don't know if i can change the brightness or not so now what we want to do um first off i'm going to go to [Music] settings and dc supply voltage i know i'm using a 12 volt supply so i'm going to switch it to 12 volt and power on default mode um i'm gonna say by default leave it off that way if i lose power and regain power i don't want the leds to come back on and that's it for the setting up the relay itself so now we have this working i can control it with the shelly app but we want to control it with home assistant using mqtt so we need to install an mqtt broker that's kind of like a post office uh like a little you know database of commands and statuses so it's gonna see what's the status of this and we're gonna point it to that mqtt broker and then it will also subscribe to it and receive commands so whenever we tell it hey we want you to turn off it will get that command in a split second and turn itself off and if we tell it that we want to change the color or if we ask it hey what's your color we'll be able to find all that by communicating straight to the mqtt broker so i'm going to go over here to supervisor in home assistant go to the add-on store and i'm going to search for mqtt up here it's already right here but i'll just show you if i start searching for mqtt there's the mosquito broker that's my favorite one to use because it's the only one i've ever tried and it worked so i'm going to install that and have more tea and i'm going to go ahead and go to the configuration tab of this everything looks good um logins is blank it looks like a little array right here but it's blank and the reason for that is mosquito with home assistant can use user accounts in home assistant so i'm good with this i'm going to i'm going to point out that it's operating off of port 1883 as one of the ports that it uses and that will come into play in just a little bit so i'm going to start the broker so we just installed and started mqtt so now we're going to go back into the shelly app and look at my light go to the settings and if we go down to device information it tells us what the ip address is of this on my home network so i'll go ahead and pop open a browser and type in that ip address so now that we're here and we go to the ip address of the shelly then i have the same controls as though i have it on my phone so i can change the colors and then turn it off turn it on and it seems to be working so now i'm going to go to internet and security and under advanced developer settings this is a feature that you don't get on the mobile app so if i'm under internet and security on the mobile app it goes straight from um actually it just has like five options this one has several more um but now i can enable action execution via mqtt so i'm going to put in the username and password that i set up before and the server is actually going to not be whatever this address is this is going to be my home assistant on port 1883 remember how 1883 was kind of important to me earlier it's because this is where it goes so i'm going to go to 192.168.86.117 and i'm leaving the default of two minute timeout 60 oh no the minimum reconnect timeout is two the max reconnect timeout is 60 and the keep alive is 60. no idea what those means what those mean but that's what i'm using and clean session max qos i thought i put it at 2 before so i kind of feel like i'm going to put it at two because i'm really sure that i had that before set it too we'll see if it works so the way that i'm going to test this i am going to open up a program called mqtt explorer this is a windows program i'm sure there's uh several mac apps that do the same thing just search for an mqtt client and i've already got my mosquito username and password set up so i will connect to it and as of right now i immediately connected and oh we just saw shelley's and under shelley's there's my rgb w2 so one thing that i know is this isn't a red green blue white thing if i start typing in red then i see that there's a status topic and it has red of zero green of zero and blue of 255 which makes sense because blue's all the way up and everything else is all the way down so over here on publish after a lot of trial and error i figured out instead of status we're going to change that to set we're going to make a little javascript object you could just copy and paste everything from above to here but we really don't need to if we only want to change red to 255 green to zero and blue to zero then it's easier just to type that and nothing else so if i click publish then it turns red so that means we do have the ability to control this over mqtt we're like 80 of the way there now we just need to install a way to automate mqtt commands rather than using this explorer and manually typing in the code to publish to it so we're going to go back to home assistant and go to supervisor we're going to go to the add-on store and now we're going to add on something called node red so i'm just search for node and we'll install that while that's installing we're going to have a little bit of fun if i pull up the shelly on my mqtt explorer i can see all of these settings especially like red green and blue now if i change it on my phone to be blue blue just changed in the mqtt explorer and if i wanted to i can click this little chart panel to look at red green and blue and as i change it over time you can see how it changes the levels of red green and blue each time and so this is kind of a neat program so if you are looking for one mqtt explorer for windows is pretty nifty um great for troubleshooting so now i see node-red is here and i do want to show it in the sidebar and if i click start it's not going to work there is a little bit of configuration for me because i'm not yet using um ssl on my home assistant i should it would be really good practice but i need to change ssl to false and require ssl to false now i can save that and there's a credential secret so any usernames and passwords that you save in node-red that it knows is a password it'll be encrypted so i'm just going to put some gobbledygook in here and save it again and now we will start it now because i've had this on my system before it may have credentials that it remembers from the past and those credentials will no longer work because i don't remember whatever i typed in to make it encrypted so we'll open it up oh it says bad gateway typically that's because i'm being impatient so i'm going to refresh the page and there's node red oh credentials could not be decrypted so it did remember a couple of credentials and those are invalid so what i want to do is i i tip i really just want to send an mqtt command using node red so we're going to use what's called a trigger um at least i thought it was a trigger no it's an inject we're going to inject a command um and there's probably a smarter way to do this but that's what i'm going to do and we're going to do mqtt out and i'm just going to connect these so basically when i click this it's going to send a command to this mqtt um so first off we're going to double click on the mqtt thing and we're going to choose oh that's the server that it doesn't know about localhost on port 1883. i'm going to edit this and under security do that mosquito and i hope i still have that password saved um the topic that we care about we're going to go back to mqtt explorer and i'm just going to copy this one right here and oh wait can i no and we're just going to call this um syn command and this is what took me the longest to figure out um send led strip command okay so what i actually want to do is in the timestamp instead of saying the message.payload is timestamp i want it to be a string and we're going to do one of those little brackety things and we're going set um turn to off and done so now in theory when i click this it'll um turn this off so i'm gonna hit deploy and let's see if it works so i click this and it just turned it off it worked first try oh so we just sent an mqtt command using node-red to an led strip this is absolutely the bare minimum basics of how this works but in my next video i'll dive a little bit deeper into some fun node-red scripts or sequences or whatever they're called so that we can automate some stuff in a fun way that might actually be usable in the real world so i hope this was fun and i hope this was helpful if there's something you'd like to see me do with the led strip or you have some ideas for this please comment below it really does mean a lot to me and i will read those comments and reply to them as best i can
Info
Channel: ChasingSquirrels
Views: 9,350
Rating: undefined out of 5
Keywords: Home Automation, Node Red, MQTT, Shelly RGBW2, Home Assistant
Id: Rkc2fnufhaQ
Channel Id: undefined
Length: 18min 1sec (1081 seconds)
Published: Tue Nov 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.