Python Forum
Looking For Help On Controlling Philips Hue From PyCharm
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking For Help On Controlling Philips Hue From PyCharm
#1
This is my first post. I hope I am posting in the correct area.
I very recently started learning python because I am interested in home automation (I started using Tasker some years ago and loved it). I like to dive in and get my hands dirty and learn that way. Right now I'm trying to figure out how to control my Philips Hue lights from the PyCharm editor. I have downloaded the API and have become familiar with it, but I do not know where to go from there. I figure there is something I need to download to PyCharm directly before hand, but I do not know where to find this. I would love some help on getting this setup so I can get to making some code for my lights.

Sorry if any of this sounds super noobish. I'm still learning the technical terms.

Thank you!
Reply
#2
Welcome to the forum.
So PyCharm is just an IDE. One of many. Nice alternative is VS Code, but as I said there are many
You can run your scripts from the IDE (any IDE), but you have many other options to choose from - e.g. from command prompt (cmd.exe) or double-click on it (if python.exe is associated with py files) or convert your script to exe, etc.
I don't know how far you have done this, but:
1. first of all you need to download and install python
2. install any external packages that may be required (e.g. there may be some package to facilitate development with this API - official or third-party)
3.Possibly set-up your project in the IDE (e.g. for PyCharm)
4.Start to develop your script(s) and have fun.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Are you asking how to use Python to call the API? Are you familiar with using urllib or something like that to make network requests?
Reply
#4
Follow @buran advice to first get Python setup before PyCharm,i guess you use Windows?
There are many Python modules made for this,eg the first one that show up in Google search.
phue: A Python library for Philips Hue.

To use it pretty straight forward.
If setup of Python is okay then the important pip work(Used to install all library/modules to Python).
Example:
# Test that pip work
C:\
λ pip -V
pip 18.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install phue
C:\
λ pip install phue
Collecting phue
  Downloading https://files.pythonhosted.org/packages/34/d2/35bfef007857ef2949b7271a263ef0c37cd9714f5b61f7d5ac02f20d7174/phue-1.0.tar.gz
Installing collected packages: phue
  Running setup.py install for phue ... done
Successfully installed phue-1.0
At this point is installed and look at it.
C:\
λ ptpython
>>> from phue import Bridge  

>>> Bridge
<class 'phue.Bridge'>

>>> Bridge.connect
<function Bridge.connect at 0x04C3A4F8>

>>> help(Bridge.connect)
Help on function connect in module phue:

connect(self)
    Connect to the Hue bridge

>>> help(Bridge)
Help on class Bridge in module phue:

class Bridge(builtins.object)
 |  Bridge(ip=None, username=None, config_file_path=None)
 |
 |  Interface to the Hue ZigBee bridge
 |
 |  You can obtain Light objects by calling the get_light_objects method:
 |
 |      >>> b = Bridge(ip='192.168.1.100')
 |      >>> b.get_light_objects()
 |      [<phue.Light at 0x10473d750>,
 |       <phue.Light at 0x1046ce110>]
 |
 |  Or more succinctly just by accessing this Bridge object as a list or dict:
 |
 |      >>> b[1]
 |      <phue.Light at 0x10473d750>
 |      >>> b['Kitchen']
 |      <phue.Light at 0x10473d750>
 |
 |  Methods defined here:
 |
 |  __getitem__(self, key)
 |      Lights are accessibly by indexing the bridge either with
-- More  --
So you see that setup work i don't have Philips Hue,so i can not test out connecting to IP out eg:
>>> b = Bridge('ip_of_your_bridge')
>>> b.get_light_objects()
Reply
#5
How would you control one light im trying to set up the same thing however when i give a command it does it to all the lights in my house
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Controlling program with TCP commands lavacode 1 518 Jul-10-2023, 04:39 PM
Last Post: deanhystad
  Controlling text-to-speech pauses with pyttsx3 pmac1300 4 4,322 Mar-14-2022, 06:47 AM
Last Post: Coricoco_fr
  Controlling what get outputted to stdout when running external commands Daring_T 4 2,111 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  Controlling Python Program From Django Front End sourabhjaiswal92 3 3,173 May-21-2018, 06:07 AM
Last Post: wavic
  controlling multiple server simultaneously. caligola 3 3,565 May-11-2018, 05:44 PM
Last Post: wavic
  Controlling trailing zeros with rounding? RedSkeleton007 1 24,410 Jan-25-2018, 07:23 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020