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!
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!
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...
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
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.
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?
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?
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?
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
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?
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
@@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 :)
@@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 !
@@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 :)
@@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.
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.
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.
First, I appreciate your content very much. I watch all of your videos. However, why do you, and most RUclipsrs, 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.
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?
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 RUclips 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
@@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 😅
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
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!
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!
I agree with you Jose! seems worth looking into python!
When you integrate without a limit don't forget to add your "+ C"
Very good explanation. Syntax looks simpler than templating, or at least more similar to what I'm used to.
Thanks Filipe!
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...
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...
Hi Robin! Think that you can create any home assistant service with python!
Hi, great video. How would you go about makin API calls for example energieprices? Where would you store the data?
another great video! :) and I love Python. Did not know I can use it in HA :) Thanks!
Happy to help!
Extremely powerful hidden gem and easy to follow tutorial. Fantastic job!
Thanks Boomsig!
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
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.
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?
Because Python is much more powerful you can write fewer lines of code to achieve something the sky is the limit !
very cool. thanks for sharing! this is powerful for python programmers. which is a lot of people.
Thanks Frank!
This is an awesome feature. Python is very powerful language
It is! Thanks Jc dock!
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?
Hi Max, I think you can, think of the inputs you need for your function and the output
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?
Personal preference is key, the more complex the piece of code it might be easier to write it in Python , consider future expandability also!
Great video!!! Thanks! 😁
Thanks Antonio!!
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
"This involves no programming knowledge"
*starts subliminally teaching how to program so people don't think they need to program*
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?
Figured it out - has to be created in the python_scripts folder
Hey Andrew! Glad you figured it out :) is it all working now?
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
Hi Okan! Is your HA externally exposed?
@@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 :)
@@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 !
@@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 :)
@@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
Another good tutorial !
Much appreciated buddy!
Thanks!
Thanks Catfish for your support!!
Perfect👌
Thanks a lot!
You want to make sure current_brightness is not 0, or you'll get a divide by zero error.
Good shout Mike!
Are we able to do network calls with services?
API calls? Made another video about that :)
@@SmartHomeMakers nice. Time to binge watch. It's also applicable to services?
Gee I can finally get rid of the annoying nodered
Great news!
Super.
Thanks JAZ!
@@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.
@@jazautomation I know really cool!
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.
Agree with what you mentioned :)
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.
Yep YAML is just good for configurations
First, I appreciate your content very much. I watch all of your videos. However, why do you, and most RUclipsrs, 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.
Thanks Larry for your honest feedback! I will run a poll on the channel to decide if we got with white screen or black!
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?
@@cjrivo Thanks Jan for your take
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 RUclips 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
Just something simple non coders can pickup on
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
@@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 😅
@@AndreaGhensi I didn’t get much sleep either with a new born :)
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
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
@@DavidNijman I am thinking the same but I was just wondering if there may have been a different driver behind it
Indeed, I had tried that in my 5 scripts video! Some people can write python and run locally so debug, many find coding scary