cookiecutter https://github.com/pydanny/cookiecutter-django
project_name [My Awesome Project]: cx_backend
project_slug [cx_backend]:
description [Behold My Awesome Project!]: changxue backend
author_name [Daniel Roy Greenfeld]: wwj718
domain_name [example.com]: istemedu.com
email [wwj718@example.com]: wuwenjie718@gmail.com
version [0.1.0]:
Select open_source_license:
This file contains 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
# https://developers.home-assistant.io/docs/en/dev_101_events.html |
This file contains 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
# https://www.home-assistant.io/components/python_script/ | |
entity_id = data.get('entity_id') | |
rgb_color = data.get('rgb_color', [255, 255, 255]) | |
if entity_id is not None: | |
service_data = {'entity_id': entity_id, 'rgb_color': rgb_color, 'brightness': 255 } | |
hass.services.call('light', 'turn_on', service_data, False) | |
else: | |
service_data = {'rgb_color': rgb_color, 'brightness': 255 } | |
hass.services.call('light', 'turn_on',service_data,False) |
This file contains 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
# 打印lpr | |
import subprocess | |
import pathlib | |
p = pathlib.Path('.') | |
# 列出目录下所有png图片名 | |
imgs = list(p.glob('**/*.png'))[:2] | |
for i in imgs: | |
cmd = "lpr {}".format(i) | |
print(cmd) | |
subprocess.call(cmd,shell=True) |
This file contains 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
from microbit import * # sleep, uart, button_a, display | |
import random | |
uart.init(115200) | |
def display_handler(data): | |
''' : String -> None ''' | |
convert = { |
This file contains 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 asyncio | |
from hbmqtt.client import MQTTClient, ConnectException | |
from hbmqtt.mqtt.constants import QOS_1, QOS_2 | |
#产品ID | |
username='135585' | |
#产品APIKey: | |
password = "to do" | |
# [mqtt|ws][s]://[username][:password]@host.domain[:port] |
This file contains 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
print("hello") |
This file contains 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
localhost | |
push | |
browse | |
log access.log | |
proxy / 127.0.0.1:8123 { | |
websocket | |
transparent | |
} | |
header / Access-Control-Allow-Origin * |
This file contains 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
pc程序 | |
``` | |
while True: | |
data = {"a":i} | |
# data = "topic-sensor-data-x" + "\r\n" | |
data = json.dumps(data) + "\r\n" | |
# data = "a" + "\r\n" | |
data_bytes = data.encode("utf-8") | |
ser.write(data_bytes) |
This file contains 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
from microbit import * | |
def get_topic_and_data(b): | |
try: | |
c = b.rstrip() | |
sleep(10) | |
# c = b.split(b"\r\n")[0] | |
# uart.write(b) | |
# uart.write(b'{"a": 18}\r\n') # 稳定 | |
uart.write(c + b'\r\n') |