mirror of
https://github.com/Luzifer/tasmota-build.git
synced 2024-12-22 22:01:18 +00:00
Initial version
This commit is contained in:
commit
638d74145a
5 changed files with 98 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
tasmota
|
||||
venv
|
||||
build
|
27
Makefile
Normal file
27
Makefile
Normal file
|
@ -0,0 +1,27 @@
|
|||
TASMOTA_VERSION=v5.11.1
|
||||
|
||||
default: build_sonoff build_sonoff-minimal
|
||||
|
||||
ci: clean default
|
||||
|
||||
build_%: download update_user-config venv
|
||||
cd tasmota && ../venv/bin/platformio run -e $*
|
||||
mkdir -p build
|
||||
cp tasmota/.pioenvs/$*/firmware.bin build/$*.bin
|
||||
|
||||
clean:
|
||||
rm -rf tasmota build venv
|
||||
|
||||
download:
|
||||
git clone https://github.com/arendst/Sonoff-Tasmota.git tasmota
|
||||
cd tasmota && git reset --hard $(TASMOTA_VERSION)
|
||||
|
||||
update_user-config: venv
|
||||
./venv/bin/python update.py
|
||||
cd tasmota && git --no-pager diff -w sonoff/user_config.h
|
||||
|
||||
venv:
|
||||
virtualenv -p python2 venv
|
||||
./venv/bin/pip install -r requirements.txt
|
||||
|
||||
.PHONY: venv
|
24
config.yml
Normal file
24
config.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
|
||||
STA_SSID1: '${WIFI_SSID}'
|
||||
STA_PASS1: '${WIFI_PASS}'
|
||||
|
||||
OTA_URL: '${OTA_URL}'
|
||||
|
||||
MQTT_HOST: '${MQTT_HOST}'
|
||||
MQTT_USER: '${MQTT_USER}'
|
||||
MQTT_PASS: '${MQTT_PASS}'
|
||||
MQTT_TOPIC: '"unconfigured"'
|
||||
|
||||
USE_DOMOTICZ: '!undef'
|
||||
USE_EMULATION: '!undef'
|
||||
USE_DISCOVERY: '!undef'
|
||||
|
||||
NTP_SERVER1: '"ptbtime1.ptb.de"'
|
||||
NTP_SERVER2: '"ptbtime2.ptb.de"'
|
||||
|
||||
USE_IR_REMOTE: '!undef'
|
||||
USE_WS2812: '!undef'
|
||||
USE_ARILUX_RF: '!undef'
|
||||
|
||||
...
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
PyYAML
|
||||
platformio
|
42
update.py
Normal file
42
update.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def fmt_line(prefix, param, content, comment):
|
||||
return '{: <47} // {}'.format('{}#define {: <22} {}'.format(prefix, param, content), comment)
|
||||
|
||||
|
||||
def get_line(param, content, comment):
|
||||
if content == '!undef':
|
||||
return fmt_line('//', param, '', comment)
|
||||
if content == '!def':
|
||||
return fmt_line('', param, '', comment)
|
||||
|
||||
if content[:2] == '${':
|
||||
envvar = content.strip('${}')
|
||||
if envvar in os.environ:
|
||||
content = os.environ[envvar]
|
||||
|
||||
return fmt_line('', param, content, comment)
|
||||
|
||||
|
||||
def main():
|
||||
cfg = yaml.load(open('config.yml'))
|
||||
config = open('tasmota/sonoff/user_config.h').read().split('\n')
|
||||
|
||||
for (i, line) in enumerate(config):
|
||||
for param, content in cfg.items():
|
||||
if '#define {} '.format(param) in line:
|
||||
comment = line.lstrip('/').split(' //', 1)[1].strip()
|
||||
config[i] = get_line(param, content, comment)
|
||||
|
||||
with open('tasmota/sonoff/user_config.h', 'w') as fh:
|
||||
fh.write('\n'.join(config))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue