Controlling Shelly WiFi Relay via MQTT

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to project 5 mqtd advanced now in this project i have another mqtt client to explain how this can be used in home automation so this is the client i'm using as a shelley wi-fi relay so if you see on my table i can show you this blue device is a small device this is a shelley wi-fi relay what it means it can be controlled using a wi-fi signal so you can turn this really on and off and i just want to show you here because i'm not connecting this device on my table this is just just want to show you the size but but this device is already connected to the lamp which you can see on my back so this lamp is controlled by a shelley wi-fi relay so i've connected this device in the bottom of this lamp so this lamp i'm going to turn on and off using mqtt signal and how amazing is that so to first explain you about this mqtt client how does it work so this wi-fi relay has its own web server inside it so once you turn on this relay there's a documentation how you can activate wi-fi signal inside how you can link this relay to your wi-fi in your home network that's what i have done so if i show you its interface it's kind of like this so this wifi relay has its own ip address which is 192.168.0.112. so when i open that i see interface of my relay now in this relay i can directly turn it on using the switch so you have a switch on the top so if i press this it will activate the relay on my back and you can see that the lamp is on i hope you can see that because i have to darken my room to show the luminance because the lamp inside is not that strong so this is just a corner lamp in my room and i can turn it off directly from this interface but that's not it you can also control it using mqtt and how you can do that i go to my internet and security and then you will see advanced developer settings and here if you go bottom you enable mqtt okay in this case so as i told you this is a client it needs broker details so i'm going to put broker details of my mqtt broker which is inside my raspberry pi so what i'm going to do is i put the ip address of my raspberry pi if you know it's 192.168.8.0.149 and the port address of mqtt here that's it and you put user name node red and password code and compile which i use in my mqtt broker that said all you have to do is and i will start the clean session and quality of service i put as two now once i do that i have to know which topics are associated with that so let me show you with a diagram so once you define your mqttd client so mqtt client which is my relay here and this is from shelley and that's a wi-fi relay i'm gonna put wi-fi here so the shelley needs broker detail so i enter broker details once i do that this is important to mention here so from raspberry pi broker details i have to enter in this client and here i can say here is my program this is raspberry pi so i push this details inside and maybe i'll make a shape oh big shape sorry for the scaling of my diagram this is just for explanation okay nothing to do with the size of the devices so once the connection is established once it is connected what happens this client automatically publish some topics the clients this shelley relay tells the broker i have some specific topics which you should use to turn me on and off okay this is provided by the client itself and how do i know which topic is that this is defined in their manual so if i open this shelly one i'm using this shelly one device and mqtt so it says shelley1 use the following topics where model is either shelley1 or shelley1pm so i have a topic named shelly's and then the model number of my shelly1 and then its specific device id that's how you differentiate which relays that then relay zero this is going to tell me the status if it's on or if it's off or what is the power but this comes in shelley with pm i'm not using that and then to give the command this is the topic with an extra command next to it it accepts on and off or toggle so i'm going to show you my interface now so this is my broker this is the node-red in my broker so this is my topic which is giving me a feedback and i have made two time stems to control it so if you notice the topic this topic is same as this topic so instead of model i have my model shelley1 and the device id i have my device id here rest is the same and how to get this device id now that's the question so you go to your shelly device and maybe go to settings maybe device id is here so this is the device id only this one not that one just copy that and put it here that's device id quality of service too and if you see i've connected this to mqtt broker 1883 all right so this topic is going to give me a feedback and to control the device i have slash command the same topic but slash command so to control i have to publish to read the feedback i have to subscribe so that's subscription that's publishing so let's see our debug node and i will turn this one on so now to turn it on it says you have to send on and off so on and off it is going as a string so payload is on as a string topic is nothing payload off is going as a string as well so i press on and you will see on the back the lamp is on and you can see a feedback the shelley limp is on if i sent off lamp is off on my back and i get a feedback shelly length is off how easy is that so we just need the topics now i can also show you i can also do the same with my mobile phone so let me activate my recording wait a second recording is activating and i open my app so you can see in this app i have already defined topics for subscribing and publishing so this feedback is a feedback it's uh subscribing so if i turn it on again from the desktop i get a feedback that lamp is on and the another one is also reading that it's on already so in my app now if i press the switch shelly lamp off it will turn off my lamp and i get a feedback as well and this behind these two uh rectangle in my phone is the status of the topic so if i show you shelly lamp and i go to edit you can see i've put the same status shelley shelley one device id relay zero slash command enable publishing and on off i've defined some colors on off i have also defined some colors quality of services too save and here in the feedback if you see inside i have just defined the feedback as same in my note redex box now desktop that is also relate 0 and press save so this is how you can also control the lamp using your mobile phone using mqtt as a base of complication so this was from my mobile phone coming back to my screen now you can imagine what we have seen in this video we have used mqtt client like a mobile phone or i can also use my impurity box here to read write the messages you can use as much client you want so signal from mqa decline from the mobile phone is going to the broker and the broker is publishing the topic which is going to my shelley wi-fi relay so here everything is why mqtt there is no wiring between my raspberry pi and the shelley relay it's let's see that in the next video because i'm going to interface even spheres you do the wi-fi relay see you in the next video thank you you
Info
Channel: Rajvir Singh
Views: 4,076
Rating: undefined out of 5
Keywords: mqtt, what is mqtt, mqtt projects, iiot, iot, mqtt iiot, mqtt iot, link mqtt with plc, connect plc to mqtt, mqtt course, mqtt lessons, mqtt tutorials, codeandcompile, shelly relay, shelly wifi relay, shelly smart devices, shelly, wifi relay, relay with wifi
Id: od-k9UGgMd8
Channel Id: undefined
Length: 9min 52sec (592 seconds)
Published: Fri May 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.