-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/softwarecrash/Solar2MQTT
- Loading branch information
Showing
7 changed files
with
244 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
name: Update Central Firmware Repository | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
update-central-repo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
- name: Clone Central Repository | ||
run: | | ||
git clone https://all-solutions:${{ secrets.CENTRAL_REPO_TOKEN }}@github.com/all-solutions/Flash2MQTT.git Flash2MQTT | ||
- name: Download Firmware Assets | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
const releaseTag = context.payload.release.tag_name; | ||
// Get the release by tag name | ||
const release = await github.rest.repos.getReleaseByTag({ | ||
owner, | ||
repo, | ||
tag: releaseTag, | ||
}); | ||
// Filter assets that end with .bin | ||
const assets = release.data.assets.filter(asset => asset.name.endsWith('.bin')); | ||
if (assets.length === 0) { | ||
core.setFailed('No .bin assets found in the release.'); | ||
} | ||
for (const asset of assets) { | ||
const download = await github.rest.repos.getReleaseAsset({ | ||
owner, | ||
repo, | ||
asset_id: asset.id, | ||
headers: { | ||
Accept: 'application/octet-stream', | ||
}, | ||
}); | ||
// Write the asset to a file | ||
fs.writeFileSync(asset.name, Buffer.from(download.data)); | ||
console.log(`Downloaded ${asset.name}`); | ||
} | ||
- name: List Downloaded Files | ||
run: ls -la | ||
|
||
- name: Copy Firmware Files | ||
run: | | ||
mkdir -p Flash2MQTT/firmware/${{ github.event.repository.name }} | ||
cp *.bin Flash2MQTT/firmware/${{ github.event.repository.name }}/ | ||
- name: Install jq | ||
run: sudo apt-get update && sudo apt-get install -y jq | ||
|
||
- name: Update variants.json and firmware_list.json | ||
env: | ||
FIRMWARE_NAME: ${{ github.event.repository.name }} | ||
RELEASE_VERSION: ${{ github.event.release.tag_name }} | ||
run: | | ||
cd Flash2MQTT/firmware/${FIRMWARE_NAME} | ||
ls *.bin > bin_files.txt | ||
# Initialize variables | ||
total=0 | ||
count=0 | ||
# Remove 'v' or 'V' prefix from version if present | ||
version="${RELEASE_VERSION#v}" | ||
version="${version#V}" | ||
echo "Firmware Name: $FIRMWARE_NAME" | ||
echo "Release Version: $version" | ||
# Determine total number of desired variants | ||
echo "Determining total number of desired variants..." | ||
while read file; do | ||
echo "Processing file: $file" | ||
if [[ "$file" == *"_${version}.bin" ]]; then | ||
echo "File matches current release version." | ||
variant_part=$(echo "$file" | sed -E 's/^'"$FIRMWARE_NAME"'_//; s/_'"${version}"'\.bin$//') | ||
variant_name="${variant_part}" | ||
echo "Extracted variant_name: $variant_name" | ||
if [[ "$variant_name" == "d1_mini" || "$variant_name" == "esp01_1m" ]]; then | ||
echo "Variant $variant_name is desired. Incrementing total." | ||
total=$((total + 1)) | ||
else | ||
echo "Variant $variant_name is not desired." | ||
fi | ||
else | ||
echo "File does not match current release version." | ||
fi | ||
done < bin_files.txt | ||
echo "Total desired variants: $total" | ||
# Start building variants.json | ||
echo '[' > variants.json | ||
# Process files and create variants.json | ||
echo "Building variants.json..." | ||
while read file; do | ||
echo "Processing file: $file" | ||
if [[ "$file" == *"_${version}.bin" ]]; then | ||
echo "File matches current release version." | ||
variant_part=$(echo "$file" | sed -E 's/^'"$FIRMWARE_NAME"'_//; s/_'"${version}"'\.bin$//') | ||
variant_name="${variant_part}" | ||
echo "Extracted variant_name: $variant_name" | ||
case "$variant_name" in | ||
"d1_mini") | ||
display_name="D1 Mini" | ||
;; | ||
"esp01_1m") | ||
display_name="ESP-01" | ||
;; | ||
*) | ||
echo "Variant $variant_name is not desired. Skipping." | ||
continue | ||
;; | ||
esac | ||
count=$((count + 1)) | ||
echo "Adding variant $display_name to variants.json." | ||
echo ' {' >> variants.json | ||
echo ' "displayName": "'"$display_name"'",' >> variants.json | ||
echo ' "file": "https://all-solutions.github.io/Flash2MQTT/firmware/'"$FIRMWARE_NAME"'/'"$file"'"' >> variants.json | ||
if [ $count -lt $total ]; then | ||
echo ' },' >> variants.json | ||
else | ||
echo ' }' >> variants.json | ||
fi | ||
else | ||
echo "File does not match current release version." | ||
fi | ||
done < bin_files.txt | ||
echo ']' >> variants.json | ||
rm bin_files.txt | ||
# Update firmware_list.json | ||
cd .. | ||
# Install jq if not already installed | ||
if ! command -v jq &> /dev/null; then | ||
sudo apt-get update && sudo apt-get install -y jq | ||
fi | ||
# Initialize firmware_list.json if it doesn't exist | ||
if [ ! -f firmware_list.json ]; then | ||
echo '[]' > firmware_list.json | ||
fi | ||
# Update firmware_list.json | ||
tmpfile=$(mktemp) | ||
jq --arg name "$FIRMWARE_NAME" --arg version "$version" \ | ||
'if any(.[]; .name == $name) then map(if .name == $name then .version = $version else . end) else . + [{"name": $name, "version": $version}] end' \ | ||
firmware_list.json > "$tmpfile" && mv "$tmpfile" firmware_list.json | ||
- name: Commit and Push Changes | ||
run: | | ||
cd Flash2MQTT | ||
git add firmware/${{ github.event.repository.name }} | ||
git add firmware/firmware_list.json | ||
git commit -m "Update firmware for ${{ github.event.repository.name }} to version $version" | ||
git pull --rebase origin main | ||
git push https://all-solutions:${{ secrets.CENTRAL_REPO_TOKEN }}@github.com/all-solutions/Flash2MQTT.git HEAD:main | ||
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
bool PI_Serial::PIXX_QFLAG() | ||
{ | ||
if (protocol == PI30) | ||
{ | ||
String commandAnswer = this->requestData("QFLAG"); | ||
get.raw.qflag = commandAnswer; | ||
byte commandAnswerLength = commandAnswer.length(); | ||
if (commandAnswer == "NAK") | ||
{ | ||
return true; | ||
} | ||
if (commandAnswer == "ERCRC") | ||
{ | ||
return false; | ||
} | ||
if (commandAnswerLength == 11) | ||
{ | ||
staticData["Buzzer_Enabled"] = checkQFLAG(commandAnswer, 'a'); | ||
staticData["Overload_bypass_Enabled"] = checkQFLAG(commandAnswer, 'b'); | ||
staticData["Power_saving_Enabled"] = checkQFLAG(commandAnswer, 'j'); | ||
staticData["LCD_reset_to_default_Enabled"] = checkQFLAG(commandAnswer, 'k'); | ||
staticData["Overload_restart_Enabled"] = checkQFLAG(commandAnswer, 'u'); | ||
staticData["Over_temperature_restart_Enabled"] = checkQFLAG(commandAnswer, 'v'); | ||
staticData["LCD_backlight_Enabled"] = checkQFLAG(commandAnswer, 'x'); | ||
staticData["Primary_source_interrupt_alarm_Enabled"] = checkQFLAG(commandAnswer, 'y'); | ||
staticData["Record_fault_code_Enabled"] = checkQFLAG(commandAnswer, 'z'); | ||
} | ||
return true; | ||
} | ||
else if (protocol == NoD) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
return 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
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