Use my link bit.ly/SmartHomeMakersDCMar22 and check out the first chapter of any DataCamp course for FREE to unlock new career opportunities and become data fluent today!
@jjcarrion22 жыл бұрын
This is super powerful!! I didn't know how to integrate this kind of scripts into home assistant and I think that with this, there is no limit, thanks for this tutorial!
@SmartHomeMakers2 жыл бұрын
I agree with you Jose! seems worth looking into python!
@TomTheDutchy Жыл бұрын
Hi, great video. How would you go about makin API calls for example energieprices? Where would you store the data?
@Donly1pt2 жыл бұрын
Very good explanation. Syntax looks simpler than templating, or at least more similar to what I'm used to.
@SmartHomeMakers2 жыл бұрын
Thanks Filipe!
@lwizinski2 жыл бұрын
So many times I've said, I know how to do what I want to do in Python, but I don't get how to do in HA...
@RobinDeBecker2 жыл бұрын
My first steps creating something from scratch in Python. Need to have a closer look at it as I do not use smart bulbs, but smart dimmable wall switches...
@SmartHomeMakers2 жыл бұрын
Hi Robin! Think that you can create any home assistant service with python!
@KrastyoKrastev2 жыл бұрын
another great video! :) and I love Python. Did not know I can use it in HA :) Thanks!
@SmartHomeMakers2 жыл бұрын
Happy to help!
@boomsig90692 жыл бұрын
Extremely powerful hidden gem and easy to follow tutorial. Fantastic job!
@SmartHomeMakers2 жыл бұрын
Thanks Boomsig!
@uSlackr2 жыл бұрын
this is fabulous! Question - when might I use a a service like this vs a script? Is it simply a matter of being able to use a real scripting language vs yaml?
@SmartHomeMakers2 жыл бұрын
Because Python is much more powerful you can write fewer lines of code to achieve something the sky is the limit !
@FrankGraffagnino2 жыл бұрын
very cool. thanks for sharing! this is powerful for python programmers. which is a lot of people.
@SmartHomeMakers2 жыл бұрын
Thanks Frank!
@MagicJF Жыл бұрын
Question: ¿Are this scripts being interpreted on HA server, or is there some sort of C++ translation and compiling into the sensors/ESP devices? In short, I would like to know if the automation scripts will keep running if internet service goes down.
@mikeb15782 жыл бұрын
i want to control a group of lights and only the lights that are on. but it seems not the full api is available. no expand etc etc. or do you know a way? i hate the yaml stuff. it is cumbersome. so my question is how to implement dimming of a helper group of lights. but only dim the lights that are off. i implemented it in a script but can not get it to work in python script
@Max-ph5in2 жыл бұрын
Can you slowly dim a pir triggered zigbee light (say in the toilet) so that as the later it gets, the dimmer it gets? I've tried some static dimming while the light is not 'ON'. But it looks like it needs to be on to change the value in the light?
@SmartHomeMakers2 жыл бұрын
Hi Max, I think you can, think of the inputs you need for your function and the output
@AntonioVillanuevaB2 жыл бұрын
Great video!!! Thanks! 😁
@SmartHomeMakers2 жыл бұрын
Thanks Antonio!!
@austenpsmith2 жыл бұрын
Would there be any benefit in using python over the yaml interface for something like this or would this really be for something more complex or just personal preference?
@SmartHomeMakers2 жыл бұрын
Personal preference is key, the more complex the piece of code it might be easier to write it in Python , consider future expandability also!
@zigajamnik2 жыл бұрын
Hi, i receive an error when trying to run this script. what is wrong? ERROR (SyncWorker_14) [homeassistant.components.python_script.light_fading.py] Error executing script: Not allowed to access HomeAssistant.service
@jcdock2 жыл бұрын
This is an awesome feature. Python is very powerful language
@SmartHomeMakers2 жыл бұрын
It is! Thanks Jc dock!
@thebaldfox2 жыл бұрын
Another good tutorial !
@SmartHomeMakers2 жыл бұрын
Much appreciated buddy!
@Hookbeak2 жыл бұрын
Confused here - services.yaml doesn't exist in my home assistant - i created one but it's not picked up by anything. can you explain where services.yaml is supposed to be and how to make that entire section work?
@Hookbeak2 жыл бұрын
Figured it out - has to be created in the python_scripts folder
@SmartHomeMakers2 жыл бұрын
Hey Andrew! Glad you figured it out :) is it all working now?
@catfish98732 жыл бұрын
Thanks!
@SmartHomeMakers2 жыл бұрын
Thanks Catfish for your support!!
@okanerdem2 жыл бұрын
Thanks for the great video. I've a question for another topic. I'm using MFA for homeassistant. Each login, i have to use code to login. There is a way to add trusted device? I tried some of things but i could not. On my iphone devices it's not needed. I can login without any code
@SmartHomeMakers2 жыл бұрын
Hi Okan! Is your HA externally exposed?
@okanerdem2 жыл бұрын
@@SmartHomeMakers First of all thanks for the answer, How can i to be sure for this? Normally i'm trying to logon from local network (192.168.1.x) if i enabled mfa on HA, i have to write security code for each login. I've a vpn server in home and for remote access will connect by vpn but right now trying from local network :)
@SmartHomeMakers2 жыл бұрын
@@okanerdem Thank you for watching! The reason I was asking was your risk profile is if MFA was worth the potential hassle in your case. If you can access HA outside your network / away from home or not. I haven’t seen a way to add trusted devices at this moment !
@okanerdem2 жыл бұрын
@@SmartHomeMakers Actually the main point of my question is that, if i connected to local network, there is a way/solution to pass mfa code? Because always i have to login with mfa pass. What i want to do, if i connected to my homenetwork, I don't want to have to do any validation. For example, i'm using synology nas with mfa but i login with mfa only first login. It's not needed to login again with mfa authentication code if i conneted with same device and with same network but if i open the synology web browser with hidden mode on chrome (for example) it's asking again authentication code. I want to use same with HA. But for HA, I have to write pascode for each login. But strange, on my mobile phone, i can login directly without any passcode. Sorry for my bad english, I may have mis-phrased :)
@SmartHomeMakers2 жыл бұрын
@@okanerdem It makes sense what you are saying don't worry about the English. I don't have MFA turned on so can't really help
@amirhoseinakbarzadeh50882 жыл бұрын
Perfect👌
@SmartHomeMakers2 жыл бұрын
Thanks a lot!
@thngzys2 жыл бұрын
Are we able to do network calls with services?
@SmartHomeMakers2 жыл бұрын
API calls? Made another video about that :)
@thngzys2 жыл бұрын
@@SmartHomeMakers nice. Time to binge watch. It's also applicable to services?
@jazautomation2 жыл бұрын
Super.
@SmartHomeMakers2 жыл бұрын
Thanks JAZ!
@jazautomation2 жыл бұрын
@@SmartHomeMakers I really like your more advance topic. That video was perfect. I thought you needed appdaemon to write python script and I did not feel really ready for that yet.
@SmartHomeMakers2 жыл бұрын
@@jazautomation I know really cool!
@mikeerdely72482 жыл бұрын
You want to make sure current_brightness is not 0, or you'll get a divide by zero error.
@SmartHomeMakers2 жыл бұрын
Good shout Mike!
@NoProblem762 жыл бұрын
Gee I can finally get rid of the annoying nodered
@SmartHomeMakers2 жыл бұрын
Great news!
@threepe010 ай бұрын
While this is useful, what you’re doing is writing a script… so you don’t have to write a script. Nerds, including myself here, get way too excited about doing things other places/other ways. But sometimes it’s easy to lose sight of when you’re just moving the problem. If you’re smart, your code is reusable… almost like 🤔 templates.
@SmartHomeMakers10 ай бұрын
Agree with what you mentioned :)
@espressomatic2 жыл бұрын
Python = scripting, so this isn't better than a script, it *IS* a script. But... It's not YAML - thank god. YAML sucks. There's nothing out there today or yesterday that I can think of that's worse than YAML.
@SmartHomeMakers2 жыл бұрын
Yep YAML is just good for configurations
@larryo44802 жыл бұрын
First, I appreciate your content very much. I watch all of your videos. However, why do you, and most KZbinrs, do everything in DARK mode? I can barely make out anything on my screen, much less follow the code examples. Please look at one of your videos and consider using a white screen. Thanks.
@SmartHomeMakers2 жыл бұрын
Thanks Larry for your honest feedback! I will run a poll on the channel to decide if we got with white screen or black!
@cjrivo2 жыл бұрын
Because dark mode is superior and easier on the eyes. At least most programmers think this. I am watching this video in a phone, with far from max brightness, and see just fine. If you can’t make out the code, maybe you need to increase the quality of the video?
@SmartHomeMakers2 жыл бұрын
@@cjrivo Thanks Jan for your take
@AndreaGhensi2 жыл бұрын
If this is what you learn in the datacamp course, please stop using it! It works, but it's ugly, and tere's too much ugly code out there! It's fine if you keep it for yourself, but not if you publish it in a KZbin video. - while loop that only decrement the variable should be replaced by a for loop - indentation should be 4 spaces (if someone pastes you code in other copied code, error would happen) - use f-strings instead of string concatenation
@SmartHomeMakers2 жыл бұрын
Just something simple non coders can pickup on
@SmartHomeMakers2 жыл бұрын
I disagree code doesn’t need to be perfect for a YT video it isn’t a production system, happy to publish an improved version of the code Andrea
@AndreaGhensi2 жыл бұрын
@@SmartHomeMakers I understand this is not production code, but the problem is the users that see your code will use it/base their code(and code style) on it, thinking is good code. This propagates bad coding practices, and github is full of it! It's not your fault, but you'll end up being a part of it. Sorry if I sound too harsh, maybe I shouldn't watch coding videos early in the morning 😅
@SmartHomeMakers2 жыл бұрын
@@AndreaGhensi I didn’t get much sleep either with a new born :)
@danielhitch2 жыл бұрын
Is there a reason why you chose python over a while loop or a repeat until in a home assistant automation and script? www.home-assistant.io/docs/scripts/#while-loop
@DavidNijman2 жыл бұрын
Probably he's using it as an example to show what you can do with Python scripts, not to replace home assistant automation and scripts
@danielhitch2 жыл бұрын
@@DavidNijman I am thinking the same but I was just wondering if there may have been a different driver behind it
@SmartHomeMakers2 жыл бұрын
Indeed, I had tried that in my 5 scripts video! Some people can write python and run locally so debug, many find coding scary
@vulvamare2 жыл бұрын
I am new here ... but now, well ... now I'm not leaving !!