This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| group: | |
| groundfloor: | |
| name: Ground floor | |
| entities: | |
| - switch.window_lights_downstairs | |
| - switch.wall_lights_downstairs | |
| - sensor.ground_floor_temp | |
| - sensor.ground_floor_humidity | |
| topfloor: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| switch: | |
| - platform: rest | |
| name: 'Window lights upstairs' | |
| resource: http://192.168.1.16:5000/Outlets/api/outlets/1/1 | |
| body_on: 'on' | |
| body_off: 'off' | |
| - platform: rest | |
| name: 'Floor light upstairs' | |
| resource: http://192.168.1.16:5000/Outlets/api/outlets/1/4 | |
| body_on: 'on' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| panel_iframe: | |
| charts: | |
| title: 'Charts' | |
| url: 'http://192.168.1.16:6001/ChartData' | |
| icon: 'mdi:chart-line' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sensor groundfloor: | |
| - platform: mqtt | |
| state_topic: "Home/GroundFloor/Temperature" | |
| name: 'Ground floor temp' | |
| unit_of_measurement: "C" | |
| sensor outdoor: | |
| - platform: mqtt | |
| state_topic: "Home/Outdoor/Temperature" | |
| name: 'Outdoor temp' | |
| unit_of_measurement: "C" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import threading | |
| states = {} | |
| lock = threading.Lock() | |
| def get_state(groupNumber, buttonNumber): | |
| key = str(groupNumber) + '_' + str(buttonNumber) | |
| state = 'off' | |
| lock.acquire() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route("/Outlets/api/outlets/<int:groupNumber>/<int:buttonNumber>",methods=["GET"]) | |
| def get_outlet_state(groupNumber, buttonNumber): | |
| return statestorage.get_state(groupNumber, buttonNumber) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route("/Outlets/api/outlets/<int:groupNumber>/<int:buttonNumber>",methods=["PUT","POST"]) | |
| def update_outlet_state(groupNumber, buttonNumber): | |
| state=None | |
| if request.json is not None: | |
| state=request.json.get("state") | |
| else: | |
| state=request.data | |
| if (state is None): | |
| abort(400) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route("/Outlets/api/outlets/<int:groupNumber>/<int:buttonNumber>",methods=["PUT","POST"]) | |
| def update_outlet_state(groupNumber, buttonNumber): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| switch upstairs_windows: | |
| - platform: rest | |
| name: 'Windows upstairs' | |
| resource: http://192.168.1.16:5000/Outlets/api/outlets/1/1 | |
| body_on: 'on' | |
| body_off: 'off' | |
| switch downstairs_windows: | |
| - platform: rest | |
| name: 'Windows downstairs' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import paho.mqtt.client as mqtt | |
| import datetime | |
| import time | |
| from Adafruit_IO import MQTTClient | |
| from adafruit_credentials import ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY | |
| from mylogger import logger | |
| # | |
| # Subscribes to messages via a local MQTT broker |