ThinkEco SmartAC Integration!

ConEd customers in NYC can order SmartAC kits for use with window AC units. Essentially, these are wifi-connected smart switches with an accompanying temperature-sensing remote. You set your window AC to its lowest setting (thereby ensuring it will always be “on”) and let the smart switch do the rest. When the smart switch turns the power back on, the window AC responds like a power failure and returns to its last setting (i.e. on). The remote senses the temperature in the room and allows you to turn the unit on/off and adjust the desired target temperature.

Unfortunately, ThinkEco is quite guarded with their API and have only opened it up to ConEd. As such, there is a single terrible app to control these devices remotely and no third party integrations (Alexa, Siri, Google Home). I set out to find a way to overcome this, so I’ll outline it here.


First, there is a wonderful plugin written by Dave Marquard which exposes your ThinkEco SmartAC units to Homebridge. While this does a fine job of generating Homekit / Siri integrations, I have no iOS devices so I needed to bring this into Home Assistant.

After some digging, I found that homebridge could be queried using HTTP calls which would return JSON answers. So let’s dive in!

I’m going to assume you have homebridge and home assistant installed. You don’t need the homebridge plugin for home assistant for the purposes of this tutorial.

Next, get the list of devices on your homebridge. Specifically, you need the aid and iid numbers for your SmartAC units. This post over on the homebridge github page helped a lot.

curl -X PUT http://IP:PORT/accessories --header "Content-Type:Application/json" --header "authorization: "XXX-XX-XXX"" -s > loghomekitaccessories.js

Note: throughout the rest of this tutorial, IP:PORT refers to the IP and port of your homebridge server.

Parsing through that output, I found that the aid's for my three SmartAC units were 16, 17 and 18. All of the aid's share a common list of iid's which each represent the different change-able states:

iid:10 - indicates the current on/off state
iid:11 - change this to actually turn it on/off
iid:12 - the current thermostat temperature (i.e. the temperature in the room as sensed by the remote)
iid:13 - the target temperature to cool the room to

Warning: I have no idea if these will be the same for you. I sent GET and PUT requests to the different iid's and matched the returns with the known values of my AC to figure this one out. Also, the output above provides some hints (min/max allowed values, whether the valuable to writeable or not, etc.).


Now we can set up some sensors, switches, sliders and automations to get the whole thing working.

sensors:

  # Read the current temperature
  - platform: rest
    resource: http://IP:PORT/characteristics?id=18.12 # note the syntax here: 18 is the aid, 12 is the iid
    name: Bedroom temperature
    value_template: '{{ (value_json.characteristics[0].value * 1.8 + 32)|round(0)}}' # Converts the temperature to F
    unit_of_measurement: "°F"
    headers:
      authorization: "XXX-XX-XXX" # This is your homebridge API password
      Content-Type: "application/json"

  # Check if the ACs are on or off
  - platform: rest
    resource: http://IP:PORT/characteristics?id=18.10
    name: Bedroom state
    value_template: '{% if value_json.characteristics[0].value == 2 %} On {% else %} Off {% endif %}' # The API returns "2" if it's on
    headers:
      authorization: "XXX-XX-XXX"
      Content-Type: "application/json"

  # Read what temperature the ACs are set to
  - platform: rest
    hide_entity: True
    resource: http://IP:PORT/characteristics?id=18.13
    name: Bedroom set temp
    value_template: '{{ (value_json.characteristics[0].value * 1.8 + 32)|round(0)}}'
    unit_of_measurement: "°F"
    headers:
      authorization: "XXX-XX-XXX"
      Content-Type: "application/json"

Now the switches:

switch:
  platform: command_line
  switches:
    bedroom_ac:
      command_on: /usr/bin/curl -X PUT http://IP:PORT/characteristics --header "Content-Type:Application/json" --header "authorization:XXX-XX-XXX" --data "{\"characteristics\":[{\"aid\":18,\"iid\":11,\"value\":2}]}"
      command_off: /usr/bin/curl -X PUT http://IP:PORT/characteristics --header "Content-Type:Application/json" --header "authorization:XXX-XX-XXX" --data "{\"characteristics\":[{\"aid\":18,\"iid\":11,\"value\":0}]}"
      command_state: /usr/bin/curl -X GET http://IP:PORT/characteristics?id=18.11 --header "Content-Type:Application/json" --header "authorization:XXX-XX-XXX"
      value_template: '{% if value_json.characteristics[0].value == 2 %} true {% else %} false {% endif %}'
      friendly_name: Bedroom AC

Then I made a slider:

input_slider:
  dining_room_temp_slider:
    name: Bedoom Temperature
    initial: 72
    min: 50
    max: 86
    step: 1

I used the shell_command component to send a PUT command actually change the target temperature of the AC:

shell_command:
  set_bedroom_temp: /usr/bin/curl -X PUT http://IP:PORT/characteristics --header "Content-Type:Application/json" --header "authorization:XXX-XX-XXX" --data "{\"characteristics\":[{\"aid\":18,\"iid\":13,\"value\":{{ ((states.input_slider.bedroom_temp_slider.state  | float -32 ) * 5/9) | round(1) }} }]}"

And finally, I set up some automations to make the slider actually do its job:

automation:
# This first automation responds to the slider and calls the shell command
  - alias: "Set Bedroom Temp"
    hide_entity: True
    trigger:
      - platform: state
        entity_id: input_slider.bedroom_temp_slider
    action:
      service: shell_command.set_bedroom_temp

# This second automation responds to the the slider (and also runs once on startup) to override the "initial value" on the slider and set it to the actual value that the AC is set to now.
  - alias: "bedroom input slider"
    hide_entity: True
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id: sensor.bedroom_set_temp
    action:
      service: input_slider.select_value
      data_template:
        entity_id: input_slider.bedroom_temp_slider
        value: "{{ states.sensor.bedroom_set_temp.state | int }}"

I made a grouping in my groups.yaml file so that these each display on the frontend neatly:

bedroom_ac:
  name: Bedroom AC
  entities:
      - sensor.bedroom_temperature
      - sensor.bedroom_set_temp
      - input_slider.bedroom_temp_slider
      - switch.bedroom_ac

And in the end I get a card like this:
image


I hope this helps someone else! I’m also sure there are more elegant ways to achieve all of this so please add your suggestions in the comments section. I’m fairly new to Home Assistant so I bet I could benefit from your wisdom.

2 Likes

OMG i have literally been trying to get this to work for the last year… thank you so much for your explanation. I have 6 of these (NYC coned program) and i can’t be happier… if you’re in new york, i owe u a drink

Thanks Again

L Russell

Hey Russell,

I’m glad you liked it. I’ve actually written a better version than what’s posted above. I found this to be a little unreliable. The newer version uses a python script and BS4 to login to the website and scrape the data directly. This gets saved in a small data file and gets read on request by HA (using command line sensors and Google Fire).

Ultimately I want to write a custom component for HA I just don’t have the time right now. PM me your email and I can send you the details.

Did you by chance figure out a way to use the Thinkeco SmartAC devices without going using the plugin which goes out to the thinkeco web site?

It seems a little crazy to go out to the web to get info on the SmartAC in lieu of scraping it directly from the devices if possible.

@grantbey – could you send me your python script as well? I’m also trying to get the modlet integrated. Sent you a PM with my info.

Nope, the API is closed and you can’t login. This is unfortunate.

The only way I can find to do it is to scrape the modlet website using BS4.

Ugh. They mentioned that they’re working on Alexa integration, but that’s as much as I’ve heard…

Hey @grantbey, would you share the latest version of your implementation with us?

Thanks!

Hi @grantbey thank you for all of this! I would also really appreciate seeing your latest version. I’m a bit of a novice hacker here, so starting with some working code would be really helpful.

@grantbey I would also love a copy of the integration you have. I will PM you my email once I have access to the PM feature here lol

@grantbey

I spent some time getting this to mostly work. I have 3 thinkeco devices so its not been the most fun, lots of the things freak out when adding more than one.

Most important - I spent so long trying to figure out the sliders, only to find a post mentioning that input_slider has been replaced with input_number
I made the changes and am getting closer to having them all work together, but you might want to update this before others spend hours trying to work just because of a depreciated variable name

hey guys… i think the website mymodlet.com changed its web design… now home bridge isn’t connecting… i think the update broke the code… blah… i spent the last week perfecting my 7 units! lol

Same problem - the log seems to be showing that the plugin is searching for the login box and not finding it anymore. This will have to be fixed in the ThinkEco plugin https://github.com/dave-atx/homebridge-platform-smartac

(node:713) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): StatusCodeError: 302 - "<html><head><title>Object moved</title></head><body>\r\n<h2>Object moved to <a href=\"/Account/Login\">here</a>.</h2>\r\n</body></html>\r\n"

(node:713) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@wesminiger – looks like someone enterprising fixed the “API” calls for the website update and submit a pull request.

Not sure if the dave-atx repository is still active, the pull requests were sourced from:

I was looking for integration for Google home and couldn’t find anything so realized to do myself.

Just finished setup with gbridge (https://about.gbridge.io/) + Node Red using API from the mobile app.

If anyone would need I added sample draft flow to the github: https://github.com/sashas777/SmartAC_ThinkEco_GoogleHome/tree/master

@sashas777
Hey, thanks for the reply/update on this! I had to cludge it together with Homebridge, then connect to Hassio, this seems also a bit workaround, but using gBridge. I’ve been planning to rebuild parts of my Hassio setup, I’ll see how much work to get your method working!

ThinkEco Smart AC now natively supports Google Home:

https://support.thinkecoinc.com/s/article/How-do-I-set-up-Google-Home-to-control-my-smartAC

Could I please trouble you for a copy of the script too?

Thanks!

With ConEd in NY discontinuing their Rewards program, and SmartAC program… This may be something to look into with Home Assistant. directly. Thinkeco looks to be still up and running as well as their APP.