Git Product home page Git Product logo

scenegen's Introduction

SceneGen

Scenegen is a scene generation tool for Home Assistant home automation software. It creates scenes by example, by reading the current states of devices and outputting a corresponding scene. Scenegen is written in python using Home Assistant's RESTFul API so can be run from anywhere. It currently supports lights and switches only.

To set up SceneGen and install it locally, run the following from a shell in the checkout:

$ make

Then the script can be run locally from the checkout:

$ ./bin/scenegen --help

See the Home Assistant documentation for full usage instructions and documentation.

Exporting Multiple Scenes

Use the $ make export target to aid in exporting multiple scenes to YAML on the filesystem. This can be useful for "exporting" scenes from an integration, such as SmartThings, to native Home Assistant themes:

$ make EXPORT_ALL_SCENES=true URL=https://home-assistant.example.com:8123 TOKEN=... EXPORT_SCENE_DIR=../path/to/scenes export

If you don't want to export all the scenes, you can create a .scenes file in the EXPORT_SCENE_DIR listing one scene per line to export and remove the EXPORT_ALL_SCENES option.

Beyond these options, the export* targets in Makefile can be used as a reference or starting point to automate exporting multiple scenes.

scenegen's People

Contributors

acockburn avatar artmg avatar nikdoof avatar robbiet480 avatar robotdad avatar rpatterson avatar wolph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scenegen's Issues

Fixed Issue, Wanted to share

So I was having constant issues trying to run the python commands, was getting missing module errors and general errors, but finally figured out my error was in the syntax.

Instead of entering "./scenegen.py https://some url -k some api key"

I had to first cd into the scenegen folder ("cd scenegen")

Then run the following command

sudo python scenegen.py https://some url -k some api key

Maybe this was just an issue for me, but thats what got it working

Issue authenticating with LLAT

I am trying out scenegen, but following prevailing wisdom on Authentication I have created a Long Lived Access Token (LLAT) in my profile instead of a system-wide API-key. I get Error 111 Connection refused

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I will try tweaking the code to use the HTTP Header Authorization: BEARER as per https://developers.home-assistant.io/docs/en/auth_api.html#example-python to see if this resolves it, otherwise I might have to use the old api-key approach for now (and slap my own wrist ;)

Only brightness and state get retrieved (missing Color etc.)

Hi,

during my last attempts on using scenegen it stopped to capture the color from my bulbs (mixture of Tradfri and Hue on Hue hub - if that matters). Only state and brightness were retrieved.
A few months ago it worked fine (I did a git pull yesterday before using scenegen).

Thanks!

Feature Suggestion: Integration inside Home Assistant

It would be cool to integrate a tool like this one inside homeassistant.

Being able to do a snapshot of the state and restoring it in a second time is a great feature and I've seen it in commercial ha software.

Capture white_value

It would be nice to also capture the white_value attribute when present. We mix white with rgb colors a lot.

Getting scenegen to work

@Larrytx commented on Sep 12, 2019, 1:41 AM UTC:

I have been struggling to get scenegen to work. Even though I have been developing for Windows and the web for over two decades, I find Linux and Home Assistant incredibly frustrating, so any help anyone might give will be most appreciated. I have carefully tried to follow each step in the ecosystem documentation, when I run scenegen, this is what I get:

pi@raspberrypi:/scenegen $ ./scenegen.py https://192.168.1.104:8123
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 453, in wrap_socket
    cnx.do_handshake()
  File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1915, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error
    _raise_current_error()
  File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_record', 'wrong version number')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 357, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 459, in wrap_socket
    raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.1.104', port=8123): Max retries exceeded with url: /api/states (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./scenegen.py", line 102, in <module>
    main()
  File "./scenegen.py", line 82, in main
    states = get_states(args.url, args.key)
  File "./scenegen.py", line 25, in get_states
    r = requests.get(apiurl, headers=headers)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='192.168.1.104', port=8123): Max retries exceeded with url: /api/states (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])")))
pi@raspberrypi:/scenegen $

Once again any guidance will be most appreciated.

This issue was moved by frenck from home-assistant/home-assistant.io#10348.

It doesn't capture color

It seems to be always capture the same color, regardless of what color mode I specify on the commans

Not getting it to work, Error

I get this error:

Traceback (most recent call last):
  File "./scenegen.py", line 3, in <module>
    import requests
ImportError: No module named 'requests'

I run Hass.io and installed scenegen on an other Pi an run it with this command:

~/scenegen$ ./scenegen.py https://192.168.1.10:8123 -k xxxxxxx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.