Skip to content

πŸƒAPI server with minimal functionality to control the air conditioner πŸƒ

License

Notifications You must be signed in to change notification settings

JIIOryo/air_conditioner_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

air_conditioner_api

This is an API server with minimal functionality to control the air conditioner and is the wrapper for irrp.py which is part of the pigpio project.

Environment

Raspberry Pi 3 model B
Python 3.7.3

Setup

git clone https://github.com/JIIOryo/air_conditioner_api.git

cd air_conditioner_api

# install pigpio for python3
sudo apt install python3-pigpio -y

# pigpiod start
sudo systemctl enable pigpiod
sudo systemctl start pigpiod

# download irrp.py to project root path
curl http://abyz.me.uk/rpi/pigpio/code/irrp_py.zip | zcat > irrp.py

# pip install
pip3 install -r requirements.txt

# generate config file
cp config.json.template config.json

# run
python3 server.py

You need to connect the infrared LED to the GPIO set in config.json.

Endpoints

PUT:/on/cool

detail

Request

Schema

{
    "cool": {
        "type": "object",
        "properties": {
            "temperature": {
                "type": "number",
                "minimum": 16,
                "maximum": 31,
                "description": "Degree celsius of airflow from air conditioner."
            },
            "airflowLevel": {
                "type": "string",
                "enum": ["a", "1", "2", "3"],
                "description": "Level of airflow from air conditioner. a: auto, 1: low, 2: middle, 3: high"
            }
        },
        "required": [
            "temperature",
            "airflowLevel"
        ]
    }
}

Content-Type

application/json

Examples

{
    "temperature": 26,
    "airflowLevel": "1"
}
{
    "temperature": 23,
    "airflowLevel": "a"
}

Response

Content-Type

application/json

Success example

{
  "code": 200,
  "message": "ok"
}

Error example

{
  "code": 400,
  "error": "ValidationError",
  "message": "Validation error ..."
}

PUT:/on/hot

detail

Request

Schema

{
    "hot": {
        "type": "object",
        "properties": {
            "temperature": {
                "type": "number",
                "minimum": 16,
                "maximum": 31,
                "description": "Degree celsius of airflow from air conditioner."
            },
            "airflowLevel": {
                "type": "string",
                "enum": [
                    "a",
                    "1",
                    "2",
                    "3"
                ],
                "description": "Level of airflow from air conditioner. a: auto, 1: low, 2: middle, 3: high"
            }
        },
        "required": [
            "temperature",
            "airflowLevel"
        ]
    }
}

Content-Type

application/json

Examples

{
    "temperature": 26,
    "airflowLevel": "1"
}
{
    "temperature": 23,
    "airflowLevel": "a"
}

Response

Content-Type

application/json

Success example

{
  "code": 200,
  "message": "ok"
}

Error example

{
  "code": 400,
  "error": "ValidationError",
  "message": "Validation error ..."
}

PUT:/on/dehumidify

detail

Request

Schema

{
    "dehumidify": {
        "type": "object",
        "properties": {
            "dehumidificationLevel": {
                "type": "number",
                "minimum": 1,
                "maximum": 3,
                "description": "Level of dehumidification by air conditioner. 1: low, 2: middle, 3: high"
            },
            "airflowLevel": {
                "type": "string",
                "enum": [
                    "a",
                    "1",
                    "2",
                    "3"
                ],
                "description": "Level of airflow from air conditioner. a: auto, 1: low, 2: middle, 3: high"
            }
        },
        "required": [
            "dehumidificationLevel",
            "airflowLevel"
        ]
    }
}

Content-Type

application/json

Examples

{
    "dehumidificationLevel": 1,
    "airflowLevel": "2"
}
{
    "dehumidificationLevel": 3,
    "airflowLevel": "a"
}

Response

Content-Type

application/json

Success example

{
  "code": 200,
  "message": "ok"
}

Error example

{
  "code": 400,
  "error": "ValidationError",
  "message": "Validation error ..."
}

DELETE:/off

detail

Request

Schema

None

Content-Type

application/json

Examples

None

Response

Content-Type

application/json

Success example

{
  "code": 200,
  "message": "ok"
}

GET:/ping

detail

Request

Schema

None

Content-Type

application/json

Examples

None

Response

Content-Type

application/json

Success example

{
  "code": 200,
  "message": "ok"
}

GET:/

detail

This endpoint returns index.html with the minimally configured controller implemented.

Schema

None

Content-Type

text/html; charset=utf-8

Page

About

πŸƒAPI server with minimal functionality to control the air conditioner πŸƒ

Resources

License

Stars

Watchers

Forks

Packages

No packages published