whaleygeek / pyenergenie

A python interface to the Energenie line of products
MIT License
81 stars 51 forks source link

Command line shell interface #53

Open whaleygeek opened 8 years ago

whaleygeek commented 8 years ago

31 hints at what I think is a command line user interface (i.e. an "energenie shell") that can be called in from other scripts. e.g. the ability to write a simple bash script with energenie commands in it.

Things I'd like to see:

A simple command to turn a device on or off (I have a pull request that does this but it's more a copy&paste than a good example of code re-use. I won't be offended if you don't use it.) A simple command to tell if a device is on or off. (As long as the device supports this, of course.) I like the idea of these simple commands because they can then be composed into bigger scripts. For instance, I like the idea of giving friendly names to devices, so I could call:

turn_on downstairslight

Something would then map the 'downstairslight' to device ID 0x123 and call the appropriate code to turn on device ID 0x123.

This mapping of names to device IDs needn't be part of the pynergenie code - it could be separate as long as there were simple commands for it to call to do the actual device switching.

whaleygeek commented 8 years ago

This is partly implemented in the setup_tool.py that I am working on on the device_classes branch at the moment (to aid with the testing of all the device_classes work). It's menu driven, but it's not far off what a command line 'energenie_shell' might look like.

whaleygeek commented 8 years ago

There is some work done on this over on this fork/pull request, that might influence our thinking on a command line interface:

https://github.com/whaleygeek/pyenergenie/pull/25

I run the command simply as:
sudo python switch.py --name 0xABC --action on

(Where 'name' is the device ID in hex and 'action' is either 'on' or 'off'.)
whaleygeek commented 5 years ago

Also #114 and #113 would provide a way to do this outside of the process