Skip to content

Commit

Permalink
Sync changes from Pro repository
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Feb 1, 2024
1 parent 84ca52d commit 07ffa7d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 33 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ on:
"**/portal/**",
"tools/**",
"test/**",
".github/workflows/website.yml",
".github/workflows/dependabot.yml",
".github/dependabot.yml",
".github/FUNDING.yml",
]
pull_request:
Expand All @@ -35,9 +32,6 @@ on:
"**/portal/**",
"tools/**",
"test/**",
".github/workflows/website.yml",
".github/workflows/dependabot.yml",
".github/dependabot.yml",
".github/FUNDING.yml",
]

Expand Down Expand Up @@ -103,12 +97,17 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Get Envs
- name: Get Pro Envs
id: envs
run: |
repo="${{ github.repository }}"
rm -f platformio_override.ini
echo "pio_name=$(pio project config --json-output | jq -cr '.[0][1][0][1]')" >> $GITHUB_OUTPUT
echo "pio_default_envs=$(pio project config --json-output | jq -cr '.[0][1][1][1]')" >> $GITHUB_OUTPUT
if [[ "$repo" == "mathieucarbou/YaSolR" ]]; then
echo "pio_default_envs=$(pio project config --json-output | jq -cr '.[0][1][2][1]|split(",")')" >> $GITHUB_OUTPUT
else
echo "pio_default_envs=$(pio project config --json-output | jq -cr '.[0][1][3][1]|split(",")')" >> $GITHUB_OUTPUT
fi
outputs:
pio_name: ${{ steps.envs.outputs.pio_name }}
Expand All @@ -123,11 +122,9 @@ jobs:
environment: ${{ fromJSON(needs.pio_envs.outputs.pio_default_envs) }}
steps:
- name: Checkout
if: ${{ startsWith(matrix.environment, 'oss-') || startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
uses: actions/checkout@v4

- name: Get Tags
if: ${{ github.repository == 'mathieucarbou/YaSolR' }}
run: git fetch --force --tags origin

- name: Remove Pro Content
Expand All @@ -140,16 +137,16 @@ jobs:
lib/WebSerialLite \
site \
docs \
TODO.md \
make-oss.sh
- name: Remove OSS Content
if: ${{ startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
if: ${{ startsWith(matrix.environment, 'pro-') }}
run: |
rm -f -r -v \
lib/ESPDASH
- name: Cache PlatformIO
if: ${{ startsWith(matrix.environment, 'oss-') || startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
uses: actions/cache@v4
with:
key: ${{ runner.os }}-pio
Expand All @@ -165,20 +162,18 @@ jobs:
path: .pio/libdeps

- name: Cache YaSolR Pro
if: ${{ startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
if: ${{ startsWith(matrix.environment, 'pro-') }}
uses: actions/cache@v4
with:
key: ${{ runner.os }}-YaSolR-pro
path: .pio/libdeps

- name: Python
if: ${{ startsWith(matrix.environment, 'oss-') || startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Build
if: ${{ startsWith(matrix.environment, 'oss-') || startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
Expand All @@ -189,7 +184,6 @@ jobs:
mv .pio/build/${{ matrix.environment }}/firmware.factory.bin ./${{ needs.pio_envs.outputs.pio_name }}-$ref-${{ matrix.environment }}.factory.bin
- name: Upload
if: ${{ startsWith(matrix.environment, 'oss-') || startsWith(matrix.environment, 'pro-') && github.repository == 'mathieucarbou/YaSolR' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.environment }}
Expand All @@ -199,7 +193,7 @@ jobs:
release:
name: Release
if: ${{ github.repository == 'mathieucarbou/YaSolR' && github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') ) }}
if: ${{ github.repository_owner == 'mathieucarbou' && github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') ) }}
runs-on: ubuntu-latest
needs: [cpplint, YaSolR]
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
source: ./site
destination: ./site/_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: ./site/_site

Expand All @@ -46,4 +46,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![YaS☀️lR (Yet another Solar Router)](./site/assets/img/logo.png?raw=1)](https://yasolr.carbou.me/)
[![YaS☀️lR (Yet another Solar Router)](https://yasolr.carbou.me/assets/img/logo.png)](https://yasolr.carbou.me/)

[![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](http://perso.crans.org/besson/LICENSE.html)
[![Download](https://img.shields.io/badge/Download-bin-green.svg)](https://yasolr.carbou.me/download)
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Todo list

- tester avec board ethernet

- FEATURES

- remote (espnow)
Expand Down
2 changes: 1 addition & 1 deletion lib/MycilaDimmer/MycilaDimmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <functional>

namespace Mycila {
enum class DimmerType { TRIAC,
enum class DimmerType { TRIAC = 0,
SSR_RANDOM,
SSR_ZC };

Expand Down
10 changes: 6 additions & 4 deletions lib/MycilaTrial/MycilaTrial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ void Mycila::TrialClass::begin() {
}
}
_lastSave = millis();
Logger.warn(TAG, "%lu seconds left for trial", duration > MYCILA_TRIAL_DURATION ? 0 : MYCILA_TRIAL_DURATION - duration);
}

void Mycila::TrialClass::loop() {
const uint32_t uptime = millis();
if (uptime - _lastSave >= MYCILA_TRIAL_SAVE * 1000) {
const uint32_t elapsed = uptime - _lastSave;
if (elapsed >= MYCILA_TRIAL_SAVE * 1000) {
Preferences prefs;
prefs.begin(TAG, false);
const uint32_t duration = prefs.getLong("duration", 0) + (uptime - _lastSave) / 1000;
prefs.begin(TAG);
const uint32_t duration = prefs.getLong("duration", 0) + elapsed / 1000;
prefs.putLong("duration", duration);
prefs.end();
Logger.warn(TAG, "%lu seconds left for trial", duration > MYCILA_TRIAL_DURATION ? 0 : MYCILA_TRIAL_DURATION - duration);
_lastSave = uptime;
if (duration >= MYCILA_TRIAL_DURATION) {
Logger.error(TAG, "Trial expired");
while (true) {
delay(1000);
}
}
Logger.warn(TAG, "%lu seconds left for trial", duration > MYCILA_TRIAL_DURATION ? 0 : MYCILA_TRIAL_DURATION - duration);
}
}

Expand Down
7 changes: 3 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

[platformio]
name = YaSolR
default_envs = pro-esp32, pro-esp32-debug, pro-esp32s, pro-esp32s-debug, oss-esp32
default_envs = oss-esp32, oss-esp32-debug, oss-esp32s, oss-esp32s-debug, pro-esp32, pro-esp32-trial, pro-esp32-debug, pro-esp32s, pro-esp32s-trial, pro-esp32s-debug
pro_envs = oss-esp32,pro-esp32,pro-esp32-trial,pro-esp32-debug,pro-esp32s,pro-esp32s-trial,pro-esp32s-debug
oss_envs = oss-esp32,oss-esp32-debug,oss-esp32s,oss-esp32s-debug
extra_configs = platformio_override.ini

[env]
Expand Down Expand Up @@ -141,9 +143,6 @@ build_flags =
${pro.build_flags}
-D APP_VERSION_TRIAL
-D MYCILA_TRIAL_DURATION=259200
-D MYCILA_TRIAL_SAVE=300
; -D MYCILA_TRIAL_DURATION=60
; -D MYCILA_TRIAL_SAVE=10
lib_deps =
lib_ignore =
ElegantOTA
Expand Down
4 changes: 2 additions & 2 deletions src/YaSolRMycilaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ Mycila::DimmerType Mycila::DimmerConfigClass::getType(const char* name) const {
String val = Mycila::Config.get(key);
if (val == "TRIAC")
return Mycila::DimmerType::TRIAC;
if (val == "SSR RANDOM")
if (val == "SSR_RANDOM")
return Mycila::DimmerType::SSR_RANDOM;
if (val == "SSR ZC")
if (val == "SSR_ZC")
return Mycila::DimmerType::SSR_ZC;
return Mycila::DimmerType::TRIAC;
}
Expand Down
6 changes: 4 additions & 2 deletions src/YaSolRWebsite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void YaSolR::Website::begin() {
_pushButtonAction.update("", "restart,bypass");
_relay1Type.update("", "NO,NC");
_relay2Type.update("", "NO,NC");
_output1DimmerType.update("", "TRIAC,SSR RANDOM,SSR ZC");
_output2DimmerType.update("", "TRIAC,SSR RANDOM,SSR ZC");
_output1DimmerType.update("", "TRIAC,SSR_RANDOM,SSR_ZC");
_output2DimmerType.update("", "TRIAC,SSR_RANDOM,SSR_ZC");
_ntpTimezone.update("", "/api/ntp/timezones");

// tabs
Expand Down Expand Up @@ -656,6 +656,7 @@ void YaSolR::Website::update(bool skipWebSocketPush) {
_output1BypassType.update(Mycila::Config.get(KEY_OUTPUT1_RELAY_TYPE));
_output1Dimmer.update(Mycila::Config.getBool(KEY_OUTPUT1_DIMMER_ENABLE));
_output1DimmerPin.update(String(Mycila::Config.get(KEY_OUTPUT1_DIMMER_PIN).toInt()));
_output1DimmerType.update(Mycila::Config.get(KEY_OUTPUT1_DIMMER_TYPE));
_output1DimmerPowerLimit.update(static_cast<int32_t>(Mycila::Config.get(KEY_OUTPUT1_DIMMER_LEVEL_LIMIT).toInt()));
_output1Temp.update(Mycila::Config.getBool(KEY_OUTPUT1_TEMP_ENABLE));
_output1TempPin.update(String(Mycila::Config.get(KEY_OUTPUT1_TEMP_PIN).toInt()));
Expand All @@ -674,6 +675,7 @@ void YaSolR::Website::update(bool skipWebSocketPush) {
_output2BypassType.update(Mycila::Config.get(KEY_OUTPUT2_RELAY_TYPE));
_output2Dimmer.update(Mycila::Config.getBool(KEY_OUTPUT2_DIMMER_ENABLE));
_output2DimmerPin.update(String(Mycila::Config.get(KEY_OUTPUT2_DIMMER_PIN).toInt()));
_output2DimmerType.update(Mycila::Config.get(KEY_OUTPUT2_DIMMER_TYPE));
_output2DimmerPowerLimit.update(static_cast<int32_t>(Mycila::Config.get(KEY_OUTPUT2_DIMMER_LEVEL_LIMIT).toInt()));
_output2Temp.update(Mycila::Config.getBool(KEY_OUTPUT2_TEMP_ENABLE));
_output2TempPin.update(String(Mycila::Config.get(KEY_OUTPUT2_TEMP_PIN).toInt()));
Expand Down

0 comments on commit 07ffa7d

Please sign in to comment.