feat(tapo): add countdown/schedule support and CLI tool

This commit is contained in:
seb
2025-12-24 06:53:49 +01:00
parent 028763bdb2
commit 853a67c73a
12 changed files with 513 additions and 124 deletions

View File

@@ -124,14 +124,18 @@ echo -e "${GREEN}Building for local/native target...${NC}"
HOST_TARGET=$(rustc -vV | grep host | cut -d' ' -f2)
# Use separate target dir for local builds to avoid GLIBC conflicts with cross builds
CARGO_TARGET_DIR=target-local cargo build --release -j $(nproc)
# Build both tapo-agent and tapo-countdown
CARGO_TARGET_DIR=target-local cargo build --release --bin tapo-agent --bin tapo-countdown -j $(nproc)
# Copy binary to dist folder
# Copy binaries to dist folder
cp "target-local/release/tapo-agent" "dist/tapo-agent-local-${HOST_TARGET}"
cp "target-local/release/tapo-countdown" "dist/tapo-countdown-local-${HOST_TARGET}"
# Get binary size
size=$(du -h "dist/tapo-agent-local-${HOST_TARGET}" | cut -f1)
echo -e "${GREEN}dist/tapo-agent-local-${HOST_TARGET}${NC} ($size)"
# Get binary sizes
size_agent=$(du -h "dist/tapo-agent-local-${HOST_TARGET}" | cut -f1)
size_cnt=$(du -h "dist/tapo-countdown-local-${HOST_TARGET}" | cut -f1)
echo -e "${GREEN}dist/tapo-agent-local-${HOST_TARGET}${NC} ($size_agent)"
echo -e "${GREEN}dist/tapo-countdown-local-${HOST_TARGET}${NC} ($size_cnt)"
echo ""
# ============================================
@@ -145,14 +149,18 @@ for target in "${!TARGETS[@]}"; do
name="${TARGETS[$target]}"
echo -e "${GREEN}Building for $target ($name)...${NC}"
cross build --release --target "$target" -j $(nproc)
# Build both binaries
cross build --release --target "$target" --bin tapo-agent --bin tapo-countdown -j $(nproc)
# Copy binary to dist folder with descriptive name
# Copy binaries to dist folder with descriptive name
cp "target/$target/release/tapo-agent" "dist/tapo-agent-$name"
cp "target/$target/release/tapo-countdown" "dist/tapo-countdown-$name"
# Get binary size
size=$(du -h "dist/tapo-agent-$name" | cut -f1)
echo -e "${GREEN}dist/tapo-agent-$name${NC} ($size)"
# Get binary sizes
size_agent=$(du -h "dist/tapo-agent-$name" | cut -f1)
size_cnt=$(du -h "dist/tapo-countdown-$name" | cut -f1)
echo -e "${GREEN}dist/tapo-agent-$name${NC} ($size_agent)"
echo -e "${GREEN}dist/tapo-countdown-$name${NC} ($size_cnt)"
echo ""
done
@@ -163,13 +171,13 @@ ls -lh dist/
echo ""
echo "To deploy to Raspberry Pi:"
echo -e " ${YELLOW}scp dist/tapo-agent-pi3_pi4_64bit pi@raspberrypi:~/tapo-agent${NC}"
echo -e " ${YELLOW}ssh pi@raspberrypi 'chmod +x ~/tapo-agent && ./tapo-agent'${NC}"
echo -e " ${YELLOW}scp dist/tapo-agent-pi3_pi4_64bit dist/tapo-countdown-pi3_pi4_64bit pi@raspberrypi:~/${NC}"
echo -e " ${YELLOW}ssh pi@raspberrypi 'chmod +x ~/tapo-agent-* ~/tapo-countdown-*'${NC}"
echo ""
echo -e "${BLUE}Upload to bashupload.com for web console deploy (3 days, 1 download):${NC}"
echo -e " ${YELLOW}curl https://bashupload.com -F=@dist/tapo-agent-pi3_pi4_64bit${NC}"
echo -e " ${YELLOW}curl https://bashupload.com -F=@dist/tapo-agent-pi2_pi3_pi4_32bit${NC}"
echo -e " ${YELLOW}curl https://bashupload.com -F=@dist/tapo-countdown-pi3_pi4_64bit${NC}"
echo ""
echo "Then on Pi, download and run:"
echo -e " ${YELLOW}curl -sSL https://bashupload.com/XXXXX -o tapo-agent && chmod +x tapo-agent${NC}"