My Scene Workflow

I wanted to share something I have been working on to make setting up scenes easier.

While I really like being able to specify every nuance of a scene, sometimes it is easier to set things up the way you want by eye, perhaps using native tools like the hue app, or HA tools to set and adjust specific colors and brightness, rather than making adjustments to a scene file and having to restart HA many times to get it right. To facilitate this, I have written a program called scenegen that will query HA for the current state of various devices and spit out a scene file suitable for pasting into configuration.yaml or standalone scene files.

If anyone wants to take a look and give me any feedback you can find it here:

23 Likes

Wow. Justā€¦ wow! Almost overwhelmed with the functionality. This will be a HUGE time saver for guys like me who have scenes already set up in Wink or Hue that we can now call up and then capture for use and finessing in HA.

Iā€™m definitely going to check this out as soon as I can get my new Pi and iBeacons set up.

Thanks for sharing your hard work with us. This looks well thought out and documented.

1 Like

niceā€¦

had to install configparser:
sudo pip install configparser

and run as python3

python3 scenegen.py http://localhost:8123 api-password

the crazy thing is I was going to spend the day making scenes.

Thanks!!!

1 Like

This is awesome!

1 Like

Thanks for your kind words :slight_smile: Let me know how it works for you and if you have any suggestions fro improvement!

This is SIMPLY AWESOME!!!

1 Like

this is the sort of thing that i think HASS is ready for - the fruit that assists with configuring your home.

Makes it so much easier for newbies to use!

well done!

1 Like

wow ā€¦ i tried . but complaining
~/.homeassistant# ./scenegen.py http://192.168.2.203:8123 > my_new_scene.yaml
./scenegen.py: line 5: syntax error near unexpected token newline' ./scenegen.py: line 5: ā€™

but i dont know what is the API key is ā€¦ i am not using any API key for my home assistance

Try adding a random key - the tool expects the api key, so is getting confused. Iā€™ll look at making the key optional in the next update.

Try:

 ./scenegen.py http://192.168.2.203:8123 xxx > my_new_scene.yaml

Hopefully HA will just ignore the key.

OK, I pushed an update - the key is now optional and you specify it with ā€˜-k KEYā€™ - docs have been updated to reflect this.

hi
thank you so muchā€¦ i tried i am geting the same messageā€¦ i went to ur side and download the latest scenegen.py file

root@paranee2-Aspire-5736Z:~/.homeassistant# ./scenegen.py http://192.168.2.203:8123 adsfsafassfsaf > my_new_scene1.yaml
./scenegen.py: line 5: syntax error near unexpected token newline' ./scenegen.py: line 5: ā€™
root@paranee2-Aspire-5736Z:~/.homeassistant# ./scenegen.py http://192.168.2.203:8123 > my_new_scene.yaml
./scenegen.py: line 5: syntax error near unexpected token newline' ./scenegen.py: line 5: ā€™

root@paranee2-Aspire-5736Z:~/.homeassistant# ./scenegen.py http://192.168.2.203:8123 -k adsfsafassfsaf > my_new_scene1.yaml
./scenegen.py: line 5: syntax error near unexpected token newline' ./scenegen.py: line 5: ā€™

Can you edit the text above to use codeblocks please? The quotes in the text are being munged by the forum and I am not sure exactly how to read the error message.

I am not sure quite what is happening though as line 5 is just an import statement. How did you download it?

I finally got around to trying this and got the following error. Iā€™ve attached as a yaml file as the codeblock formatting in here is always extremely trying for me. If you have any tips on that as well (beside going from line to line and putting in spaces), Iā€™d appreciate it.

error.yaml (2.5 KB)

Also, my API password used an exclamation point in it which prevented me from running it at all until I changed it so you may want to check that.

Edit: Forgot to sanitize my API password! Duh. Also should mention that I am running the script on the same Pi that HA is on.

OK, figured out my problem and Iā€™m going to post what I found here for anyone new to thisā€¦

  1. Make sure you set the perms to 755. I did this when I set it up initially but just thought it bore mentioning for anyone new to the Pi.
  2. I ran the example show in the readme exactly. Which was the whole problem; the example uses https:// but my setup is not SSL yet (this was actually one of the reasons I moved from WIndows to the Pi, to set up SSL with Letā€™s Encryptā€¦ but got sidetracked with other cool stuff. :sunglasses:) . So as soon as I realized this I correctly went http:// and immediately got the correct output.

I felt kinda dumb for not seeing this right away, but I thought I would post it for other Pi noobs like myself to help out. Sharing trumps ego. :wink:

Love this script - thanks bud!

1 Like

Glad you figured it out - hope scenegen saves you some time :slight_smile:

1 Like

Just wanted to say thanks for scenegen - brilliant. Not had time to play with it fully but first try worked great.

Excellent - glad to hear it is useful to others :slight_smile:

Iā€™m having some issues with this, but I am hoping that using the map option might help. I think my problem is that I am pulling the Hue lights from both the Wink Hub and the Hue Hub. Even though I have the Wink Hub lights hidden, Scenegen was using them instead of the proper lights and it resulted in colors that were completely off from what I expected. Iā€™ll let you know how it works out with the map later on today.

Also if you get a chance could you fix the API password logic to account for special characters like ā€œ!ā€?

Let me know how it works out - if it continues to be a problem I should be able to figure out how to get scenegen to honor the hidden attribute.

Regarding the password - what errors are you getting? It is likely a shell issue you can fix by putting the password in single or double quotes.

1 Like

I donā€™t remember the error off hand but Iā€™ll try the quotes, thanks.