mirror of
https://github.com/esphome/esphome.git
synced 2025-09-01 10:52:19 +01:00
Add climate dry fan (#845)
* add climate dry fan * clang-format * updates, add swing mode, add back compat with old ha * revert client-config add swing * sort const.py * fix missing retur
This commit is contained in:
committed by
Otto Winter
parent
4f8f59f705
commit
1814e4a46b
@@ -1,6 +1,19 @@
|
||||
"""Python 3 script to automatically generate C++ classes for ESPHome's native API.
|
||||
|
||||
It's pretty crappy spaghetti code, but it works.
|
||||
|
||||
you need to install protobuf-compiler:
|
||||
running protc --version should return
|
||||
libprotoc 3.6.1
|
||||
|
||||
then run this script with python3 and the files
|
||||
|
||||
esphome/components/api/api_pb2_service.h
|
||||
esphome/components/api/api_pb2_service.cpp
|
||||
esphome/components/api/api_pb2.h
|
||||
esphome/components/api/api_pb2.cpp
|
||||
|
||||
will be generated, they still need to be formatted
|
||||
"""
|
||||
|
||||
import re
|
||||
@@ -10,13 +23,17 @@ from subprocess import call
|
||||
|
||||
# Generate with
|
||||
# protoc --python_out=script/api_protobuf -I esphome/components/api/ api_options.proto
|
||||
|
||||
import api_options_pb2 as pb
|
||||
import google.protobuf.descriptor_pb2 as descriptor
|
||||
|
||||
cwd = Path(__file__).parent
|
||||
file_header = '// This file was automatically generated with a tool.\n'
|
||||
file_header += '// See scripts/api_protobuf/api_protobuf.py\n'
|
||||
|
||||
cwd = Path(__file__).resolve().parent
|
||||
root = cwd.parent.parent / 'esphome' / 'components' / 'api'
|
||||
prot = cwd / 'api.protoc'
|
||||
call(['protoc', '-o', prot, '-I', root, 'api.proto'])
|
||||
prot = root / 'api.protoc'
|
||||
call(['protoc', '-o', str(prot), '-I', str(root), 'api.proto'])
|
||||
content = prot.read_bytes()
|
||||
|
||||
d = descriptor.FileDescriptorSet.FromString(content)
|
||||
@@ -617,7 +634,8 @@ def build_message_type(desc):
|
||||
|
||||
|
||||
file = d.file[0]
|
||||
content = '''\
|
||||
content = file_header
|
||||
content += '''\
|
||||
#pragma once
|
||||
|
||||
#include "proto.h"
|
||||
@@ -627,7 +645,8 @@ namespace api {
|
||||
|
||||
'''
|
||||
|
||||
cpp = '''\
|
||||
cpp = file_header
|
||||
cpp += '''\
|
||||
#include "api_pb2.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -739,7 +758,8 @@ def build_service_message_type(mt):
|
||||
return hout, cout
|
||||
|
||||
|
||||
hpp = '''\
|
||||
hpp = file_header
|
||||
hpp += '''\
|
||||
#pragma once
|
||||
|
||||
#include "api_pb2.h"
|
||||
@@ -750,7 +770,8 @@ namespace api {
|
||||
|
||||
'''
|
||||
|
||||
cpp = '''\
|
||||
cpp = file_header
|
||||
cpp += '''\
|
||||
#include "api_pb2_service.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
|
Reference in New Issue
Block a user