diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f349903..6bf7909 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,14 @@ updates: schedule: interval: "weekly" open-pull-requests-limit: 0 - target-branch: "develop" + target-branch: "dev" - package-ecosystem: "github-actions" directory: "/" + target-branch: "dev" schedule: interval: "weekly" + groups: + patch-and-minor: + update-types: + - "minor" + - "patch" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1961df0..44c4800 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,13 +12,13 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 12.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 12.x - name: Cache Node.js modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS key: ${{ runner.OS }}-node-12.x-${{ hashFiles('**/package-lock.json') }} @@ -37,13 +37,13 @@ jobs: node-version: [10.x, 12.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Cache Node.js modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS key: ${{ runner.OS }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} @@ -54,3 +54,9 @@ jobs: run: npm ci - name: Build the project run: npm run build --if-present + - name: Archive distribution bundle + uses: actions/upload-artifact@v4 + with: + name: dist-node${{ matrix.node-version }} + path: | + dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88d83e3..aeec7c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,13 +12,13 @@ jobs: new_release_version: ${{ steps.semantic.outputs.new_release_version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 12.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 12.x - name: Cache Node.js modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS key: ${{ runner.OS }}-node-12.x-${{ hashFiles('**/package-lock.json') }} diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml index d58aede..5c8ca49 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/semantic-pull-request.yml @@ -12,6 +12,6 @@ jobs: name: Validate PR title runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@v5.2.0 + - uses: amannn/action-semantic-pull-request@v5.4.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/main.js b/src/main.js index 43f806d..f531621 100644 --- a/src/main.js +++ b/src/main.js @@ -527,27 +527,34 @@ class MiniGraphCard extends LitElement { setTooltip(entity, index, value, label = null) { const { + group_by, points_per_hour, hours_to_show, format, } = this.config; - const offset = hours_to_show < 1 && points_per_hour < 1 - ? points_per_hour * hours_to_show - : 1 / points_per_hour; - const id = Math.abs(index + 1 - Math.ceil(hours_to_show * points_per_hour)); + // time units in milliseconds in this function + const interval = getMilli(1 / points_per_hour); + const n_points = Math.ceil(hours_to_show * points_per_hour); + + // index is 0 (oldest) to n_points-1 (most recent ~= now) + // count of intervals from now to end of bin + // count is 0 (now) to n_points-1 (oldest) + const count = (n_points - 1) - index; + + // offset end by a minute, if grouped by, e.g., date or hour + const oneMinute = group_by !== 'interval' ? 60000 : 0; const now = this.getEndDate(); - const oneMinInHours = 1 / 60; - now.setMilliseconds(now.getMilliseconds() - getMilli(offset * id + oneMinInHours)); + now.setMilliseconds(now.getMilliseconds() - oneMinute - interval * count); const end = getTime(now, format, this._hass.language); - now.setMilliseconds(now.getMilliseconds() - getMilli(offset - oneMinInHours)); + now.setMilliseconds(now.getMilliseconds() + oneMinute - interval); const start = getTime(now, format, this._hass.language); this.tooltip = { value, - id, + count, entity, time: [start, end], index,