[DEPRECIATED] BitBar: Display & Control SmartThings from the macOS Menubar

Definitely! Have you used GitHub at all? I think the best way would be to create a fork of the current master (just go to the GitHub page and click Fork at the top-right), add your changes in there, then submit a pull request so the changes can be merged back in. Let me know if you need any help.

This is pretty cool. I may try this when I get a little time.

Great work.

@mattw @pmjoen

I have some version updates as well, I will have submitted them to your current code base via a Github pull request from my fork.

  1. Added Presence Sensor capability
  2. Added better config file reading and error handling logic.
  3. Added User configurable submenu limits & color for each sensor type category
  4. Added degree symbol to temperature values
  5. Added logic to handle Null Temperature Title in Main Menu
  6. Python code optimization


This version upgrade will require upgrades to one’s python file, python cfg file and ST SmartAPP.

1 Like

Hello,

I have checked my URL and secret code are correct several times but I am still getting the following error:
Any help would be appreciated.

Traceback (most recent call last):
File “/Users/matthew/Desktop/BitBar/ST/ST_Python_Logic.py”, line 42, in
temps = j[‘Temp Sensors’]
KeyError: ‘Temp Sensors’

Not sure! A wild guess would be that you could re-download the latest version of the application and make sure that all copies are the latest and that your URL and secret are entered in the ST_Python_Logic.cfg exactly correct to what was displayed in the SmartThings IDE Logging. There are new detailed install instructions located here.

This error is most likely related to the ST_Python_Logic.py not receiving the correct data response from the Smartthings STBitBarAPP when it sent a HTTP request.

When I checked STBitBarApp the latest ST_Python_Logic.py version in @mattw github, line 105 is where the code is located.

Getting a “No connection” error. Looks like I am not getting JSON data?

Michaels-MacBook-Pro-2:~ Michael$ /Users/Michael/Documents/STPlugins/ST.5m.sh
No Connection

Please check connection and try again
Debug information: Error code 6

Error code 6 is that it could not resolve the hostname. Can you verify the smartAppURL variable is set in the cfg file?

The GitHub page has been updated with a new version including the following changes:

Thanks @KurtSanders for adding presence and motion capability as well as many other changes with formatting and settings structure (explained in his post above)

Other new features:

  • Thermostat control and display
  • Menu bar text color changes based on thermostat status (red=heating/blue=cooling)
  • Thermostat last event time (so I can check how long it’s been running or idle at work)
  • Battery status display (while holding alt)
  • Connection retry logic for when resuming from sleep/reconnecting WiFi
  • More error handling and version verification

As Kurt mentioned, this requires updating:

  • ST_Python_Logic.py
  • ST_Python_Logic.cfg
  • SmartApp code

Let me know if there are any issues or requests!

`

1 Like

So I uninstalled everything and installed the new version from GitHub.

Now I am getting the error:
Error while communicating with ST API

Error Details: access_denied
Error Description: Access is denied

Not sure what I did wrong or what is happening.

I’m able to reproduce the same error (access_denied) if I leave off the / at the end of the smartAppURL.
It should look like:

https://[SmartThings Graph]:443/api/smartapps/installations/[Your SmartApp ID]/

Can you verify the forward slash is at the end? I can add in more format handling to help with small possible formatting errors.

When I add the ‘/’ at the end I now get this error instead:

N/A :
Traceback (most recent call last):
File “/Users/matthew/Documents/BitBar/ST/ST_Python_Logic.py”, line 120, in
print mainDisplay[0][‘name’], “:”, formatter.formatNumber(mainDisplay[0][‘value’])
File “/Users/matthew/Documents/BitBar/ST/ST_Python_Logic.py”, line 26, in formatNumber
r = round(number, self.decmialRounding)
TypeError: a float is required

Ah, looks like an issue if a display sensor is not selected. I just updated a fix to the GitHub page for this.

There are also two other changes:

  • Added support for switches submenu
  • Added parameter to show/hide sensor counts

This is an update to the python and configuration file

  • ST_Python_Logic.py
  • ST_Python_Logic.cfg

When I add my Nest Thermostat in Select Devices: Which Thermostat section and refresh my bitbar app, I get the following error:
Traceback (most recent call last):
File “/Applications/bitbar/ST/ST_Python_Logic.py”, line 340, in
for c in range(currentCoolingSetPoint - 5, currentCoolingSetPoint):
TypeError: unsupported operand type(s) for -: ‘NoneType’ and ‘int’

resetting the selection back to blank resolves the issue.

So when I added a display sensor I got everything to work thanks for that!

Just FYI after that I updated to the lasted update from GitHub and replaced the .py and .cfg files and got an error. Not sure if its an error in the update or with my setup. Just thought I would throw it out there.

File “/Users/matthew/Documents/BitBar/ST/ST_Python_Logic.py”, line 50
else: return val
^
IndentationError: unexpected indent

There was an issue @kurtsanders fixed if the setpoint was not an integer but it looks like your error there is no setpoint (NoneType). Do you have a cooling setpoint on your Nest?

I added in verification to make sure the heating/cooling setpoints have values (on GitHub now). Let me know if that helps at all.

Awesome, glad you got it working!

Hmm, I don’t see any formatting changes on that line. When updating, do you copy/paste the contents or download the file?

That fixed it. Thanks!

I found the issue and corrected it.
My IDE smartapp didn’t save for some reason.

All working great now thanks.
Only issue I still see is that when I add my Door Lock it throws an error and won’t display the door lock but the rest of the app still works

File “/Users/matthew/Documents/BitBar/ST/ST_Python_Logic.py”, line 507, in
sensor[‘name’] = sensor[‘name’] + “(” + sensor[‘value’] + “)”
TypeError: coercing to Unicode: need string or buffer, NoneType found

Oh and When you have your menu bar in Dark Mode it will not display any of the headers. FYI

Please excuse my ignorant question. How exactly do I download these? I am used to copying files in RAW but how do I download?

Thanks

Thanks for the feedback. I’ve added in support for dark mode (menu titles change to white). This is an update to the python script and ST.5m.sh script. Only drawback is if dark mode is changed often (using f.lux), BitBar needs to be restarted to reflect the changes.

I’m not sure what the error is with the lock. It should only get to that line if the lock is not in either ‘locked’ or ‘unlocked’ status. It looks like it’s coming back with no status. I added in extra logic for that case though, so try that out.