mholgatem / ThermOS

Another Raspberry Pi Thermostat
https://mholgatem.github.io/ThermOS/
MIT License
77 stars 17 forks source link

api #8

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi there is there any way to get to an api so it could be integrated into homeassistant? i don't seem to be able to find anything about it

would be nice to be able to remotely change and monitor temps and maybe change fan and heat/cool

thnx

mholgatem commented 7 years ago

At some point I would like to write an API, but I don't have time at the moment. I haven't worked with Home Assistant before, but if you can write custom HTML GET/POST messages, you can use the ThermOS web backend to control everything and get the data that you want.

If you take a look at thermostat_web.py, any definition that has @app.route(urlpath, methods=['POST']) above it is a worker function. You can post a form to that url path to do things such as set the temperature or edit a schedule entry.

Any definition that is preceded by @app.route(urlpath, methods=['GET']) is a function that will return data.

ghost commented 7 years ago

you got an example on how to do a post example would be nice for turning fan from on to auto and system from auto to cool and heat

thnx

Vasiley commented 7 years ago

I am also trying to extract data and push data to server from a remote endpoint.. Any suggestions of where to start would be helpfull. Your work is awesome and works well locally.

mholgatem commented 7 years ago

I'm pretty busy right now, but I'll try to get you guys some examples this evening

mholgatem commented 7 years ago

So here's just a quick post method with a python script:

import requests
url="http://localhost/hold"
data= {
    'onoffswitch':'on', #on=Cool, #off=Heat
    'target': u'75', #Target Temp
    'timeFrame': u'.25' #time in hours
    }
requests.post(url, data=data)

In this example, you first import the requests module. 2) you set the url (Note the '/hold' at the end), in my case, I was testing on the same machine that ThermOS was running. Otherwise, replace localhost with your Thermostat local IP 3) data that you want to send. Since we are sending data to the 'hold' function, there is specific names that must be used 4) post the request and the Thermostat will handle the rest

It will be up to you to figure out how to implement it into homeAssistant though as I'm not familiar with their API. I'll post some references for you to access other functions when I get a chance.

ghost commented 7 years ago

We figured it out now the whole thermostat is controllable from homeassistant

homeassistant: customize: sensor.fan_mode: friendly_name: Fan haaska_hidden: true icon: mdi:fan

sensor.system_mode:
  friendly_name: Mode
  haaska_hidden: true
  icon: mdi:settings

sensor.indoor_temperature:
  friendly_name: Indoor Temp
  haaska_hidden: true
  icon: mdi:thermometer-lines

sensor.operation_set_point:
  friendly_name: Setpoint
  haaska_hidden: true
  icon: mdi:oil-temperature

sensor.fan_on:
  friendly_name: Fan Status
  haaska_hidden: true
  icon: mdi:fan

sensor.operation_mode:
  friendly_name: Operation Mode
  haaska_hidden: true
  icon: mdi:air-conditioner

group: thermos: name: thermos entities:

input_select: heat_cool: name: Heat Cool options:

automation:

script: run: sequence:

shell_command: heat_cool_select: curl -d "mode={{ states.input_select.heat_cool.state }}&target={{ states.input_select.temp.state }}" -X POST http://73.54.53.122:8880/system

sensor:

IMPORTANT: This email is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humour or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution or copying of this email is not authorised (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word absquatulation has been used in its correct context somewhere other than in this warning, it does not have any legal or grammatical use and may be ignored. No animals were harmed in the transmission of this email, although the yorkshire terrier next door is living on borrowed time, let me tell you. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards, so just ignore that Alert Notice from Microsoft: However, by pouring a complete circle of salt around yourself and your computer you can ensure that no harm befalls you and your pets. If you have received this email in error, please add some nutmeg and egg whites and place it in a warm oven for 40 minutes. Whisk briefly and let it stand for 2 hours before icing.

Legal Notice: Receipt of this message constitutes your unconditional acceptance of agreement with all terms, conditions, conclusions and opinions, either expressed or implied, as interpreted by the author without further clarification. Use of any information contained herein [inclusive of any and all attachments] or omitted in part or in whole from the actual message is strictly prohibited and will be subject to collection of significant financial damages.

The views of my employer do not conform to my views, or to any accepted standard of logic that the Greeks thought up anyway...

None of the ideas expressed above are actually mine. They are told to me by Luthor and Ferdinand, the five inch tall space aliens who live under my desk. In return for these ideas, I have given them permission to eat any dust bunnies they may find under there.

No trees were destroyed in the sending of this message, however, a significant number of electrons were terribly inconvenienced.

On Tue, Oct 17, 2017 at 1:14 PM, mholgatem notifications@github.com wrote:

So here's just a quick post method with a python script:

import requests url="http://localhost/hold" data= { 'onoffswitch':'on', #on=Cool, #off=Heat 'target': u'75', #Target Temp 'timeFrame': u'.25' #time in hours } requests.post(url, data=data)

In this example, you first import the requests module. 2) you set the url (Note the '/hold' at the end), in my case, I was testing on the same machine that ThermOS was running. Otherwise, replace localhost with your Thermostat local IP 3) data that you want to send. Since we are sending data to the 'hold' function, there is specific names that must be used 4) post the request and the Thermostat will handle the rest

It will be up to you to figure out how to implement it into homeAssistant though as I'm not familiar with their API. I'll post some references for you to access other functions when I get a chance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-337290077, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mOsa3YUacC1RPGTUu3SPIfHvgkQDks5stOB6gaJpZM4Pxye_ .

mholgatem commented 7 years ago

wow, very cool! Is this all that is required or are there additional scripts that go with this to operate it?

ghost commented 7 years ago

that is all thats required and we can set cool heat off we can set temps and it shows all modes

i run it on a 5 inch touchscreen ppl are getting interested now in it since total cost to make the whole thing is about 60-70$

On Oct 19, 2017 7:37 PM, "mholgatem" notifications@github.com wrote:

wow, very cool! Is this all that is required or are there additional scripts that go with this to operate it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-338066763, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mKqWF7UUX-iWSJf3ufV-bRGaYUBzks5st90hgaJpZM4Pxye_ .

ghost commented 7 years ago

https://photos.app.goo.gl/OT74t3n6PFoixyxM2

On Oct 19, 2017 7:37 PM, "mholgatem" notifications@github.com wrote:

wow, very cool! Is this all that is required or are there additional scripts that go with this to operate it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-338066763, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mKqWF7UUX-iWSJf3ufV-bRGaYUBzks5st90hgaJpZM4Pxye_ .

ghost commented 7 years ago

https://photos.app.goo.gl/wyprCgSj4T3NglqG2

On Oct 19, 2017 7:37 PM, "mholgatem" notifications@github.com wrote:

wow, very cool! Is this all that is required or are there additional scripts that go with this to operate it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-338066763, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mKqWF7UUX-iWSJf3ufV-bRGaYUBzks5st90hgaJpZM4Pxye_ .

mholgatem commented 7 years ago

ah, ok. I see your shell command now. Very nice! I'm going to re-open this issue, so that I remember it. When I have some time, I'll build it into the project (if you don't mind). BTW, how did you come across this project?

ghost commented 7 years ago

well there was not really a good thermostat thats DIY so i spend a couple hours googeling and yours was the best one so i made one . then i needed remote control so me and a friend spend a coupke days integrating it to homeassistant. now we got someone else working on a rest api and mqtt for it so we can use the hvac module homeassistant has.

On Oct 19, 2017 8:03 PM, "mholgatem" notifications@github.com wrote:

ah, ok. I see your shell command now. Very nice! I'm going to re-open this issue, so that I remember it. When I have some time, I'll build it into the project (if you don't mind). BTW, how did you come across this project?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-338070464, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mC3ZYoS4DqZeol1Qg_HJFcBFkSmDks5st-M1gaJpZM4Pxye_ .

mholgatem commented 7 years ago

very cool. If you guys are familiar with github, you are always welcome to create a pull request. I'm always eager to have help on these projects.

ghost commented 7 years ago

yeah we will once we got rest and mqtt working this thermostat is going places quick now we will have a writeup on our homeassistant project and module page soon .... the guy thats supposed to write it is looking after his wife atm in the hospital she had surgery yesterday so itll be a couple days

On Oct 19, 2017 8:17 PM, "mholgatem" notifications@github.com wrote:

very cool. If you guys are familiar with github, you are always welcome to create a pull request. I'm always eager to have help on these projects.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mholgatem/ThermOS/issues/8#issuecomment-338072419, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ8mPfzfh7vMc5KSt38Duf_03yizcjQks5st-atgaJpZM4Pxye_ .

Vasiley commented 7 years ago

Good Morning mholgatem

I am the guy that got nominated to write this up... LOL ... I am open to anyway to write it up... At first a had a fork and was going to add a file of the homeassistant thermo.yaml (package) config and a readme with pics and discriptions of the wiring and formatting of the touchscreen. I am new to git and was worried that it could take credit away from you... Any suggestions... My plan was a git for Homeassitant DIY thermo powered by mholgatem? I didnt know if having your software on the git would be best or a link.. I dont like links it has users digging around and getting lost.

Vasiley commented 7 years ago

and also would this fork update from changes on your end.. I think the Home Assistant option you give you more exposure

mholgatem commented 7 years ago

I don't really care much about credit, I just like to see how people use my code. But what I was thinking is that we can make an installer for the Home Assistant stuff. As far as I am aware, the config yaml files just need to be copied into the correct Home Assistant folder, right? We could do a thing like this:

Install ThermOS → Check for Home Assistant installation → if no Home Assistant, ask if you'd like to install Home Assistant → Copy thermo.yaml to correct Home Assistant folder Then ask if this will be run with a touch screen or in headless mode

If you want to figure out the config stuff, you can either send it to me via email (holgate.mark1@gmail.com) or you can create a pull request by clicking 'create new pull request' on the code page.

Vasiley commented 7 years ago

yes but the home assistant install is not quite that easy.. The yaml for the thermos would have to have the correct ip of the thermos and you would need to secure home assistant with ssl and a dyndns..and config a password... Let me think... I think zombu would know a little better than I since All i did is the homeassistant config for him

mholgatem commented 7 years ago

setting the correct ip is easy, I have lots of bash scripts that do that sort of thing. I would set up the home assistant to be local network only, so that the ssl/dyndns/password stuff can be skipped. My thinking is that if they want it public facing, then they can do the legwork to set that stuff up. I personally discourage setting up public facing hardware unless you are working on your own project or are making enough money doing it to cover legal fees. All that it takes is one litigious person to tie up all of your assets defending yourself in court.

Vasiley commented 7 years ago

Zombu is trying to use a tinkerboard that has more horsepower for the ha install.... will post when that happens

mholgatem commented 7 years ago

cool. let me know.

Are you guys running the thermostat on a separate board from the home assistant?

Vasiley commented 7 years ago

We are trying to give user a option for either way... a installer that will give option of home assistant installed or not ..... I have started the write up but its still alpha https://github.com/Vasiley/Diy_Thermostat_with_Homeassistant

mholgatem commented 7 years ago

it's looking good. If you want, you can also go here and scroll down to the Github Pages section, you can create your own project webpage like this.

Vasiley commented 7 years ago

Cool.... Once I get all info will try that Thanks Just learning all this LOL

mholgatem commented 7 years ago

yeah, it's a lot to take in all at once. let me know if you have any questions.