Skip to content

Commit

Permalink
Merge pull request #36 from jisotalo/dev
Browse files Browse the repository at this point in the history
## [3.1.1] - 24.11.2024
- Bugikorjaus: Käänteinen ohjaus ei näkynyt oikein tilasivulla
  - Kiitos [https://github.com/joomoz](https://github.com/joomoz)!
  • Loading branch information
jisotalo authored Nov 24, 2024
2 parents ee6f64a + 8e19579 commit f20fd4e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.1.1] - 24.11.2024
- Bugikorjaus: Käänteinen ohjaus ei näkynyt oikein tilasivulla
- Kiitos [https://github.com/joomoz](https://github.com/joomoz)!

## [3.1.0] - 22.11.2024
- Lisätty tarkistus kellonajan muuttumiselle
- Jos aika muuttuu yllättäen yli 5 min, haetaan hinnat ja suoritetaan logiikat uusiksi
Expand Down
2 changes: 1 addition & 1 deletion dist/shelly-porssisahko-1-instance-no-history.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shelly-porssisahko-addon-temp-hours.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shelly-porssisahko-addon-temp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shelly-porssisahko-ht-sensor-temp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shelly-porssisahko-open-meteo-api.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shelly-porssisahko.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/shelly-porssisahko.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const CNST = {
let _ = {
s: {
/** version number */
v: "3.1.0",
v: "3.1.1",
/** Device name */
dn: '',
/** 1 if config is checked */
Expand Down Expand Up @@ -203,7 +203,7 @@ let cmd = []; // Active commands for each instances (internal)
* Used to see changes in system time
*/
let prevEpoch = 0;

/**
* True if loop is currently running
* (new one is not started + HTTP requests are not handled)
Expand Down Expand Up @@ -353,10 +353,10 @@ function updateState() {

if (_.s.timeOK && Math.abs(epochNow - prevEpoch) > 300) {
log("Time changed 5 min+ -> refresh");
_.s.p[0].ts = 0;
_.s.p[0].now = 0;
_.s.p[1].ts = 0;

_.s.p[0].ts = 0;
_.s.p[0].now = 0;
_.s.p[1].ts = 0;
_.p[0] = [];
_.p[1] = [];
}
Expand Down Expand Up @@ -1103,7 +1103,7 @@ function updateCurrentPrice() {
_.s.p[0].now = 0;
return;
}

let now = epoch();

for (let i = 0; i < _.p[0].length; i++) {
Expand Down
32 changes: 16 additions & 16 deletions src/statics/tab-status.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* shelly-porssisahko
*
*
* (c) Jussi isotalo - http://jisotalo.fi
* https://github.com/jisotalo/shelly-porssisahko
*
* License: GNU Affero General Public License v3.0
*
* License: GNU Affero General Public License v3.0
*/
{
/**
Expand Down Expand Up @@ -33,9 +33,9 @@

/**
* Callback called by main loop
*
*
* @param {*} instChanged true = instance has changed (reset data)
* @returns
* @returns
*/
const onUpdate = async (instChanged) => {
try {
Expand All @@ -44,7 +44,7 @@
qs("s-cmd").innerHTML = "Ladataan...";
return;
}

if (!state) {
throw new Error("ei saatu dataa");
}
Expand All @@ -70,10 +70,10 @@
qs("s-now").innerHTML = d.p.length > 0
? `${s.p[0].now.toFixed(2)} c/kWh`
: "";

qs("s-st").innerHTML = si.st === 9
? STATE_STR[si.st].replace("%s", formatDateTime(new Date(si.fCmdTs * 1000), false))
: STATE_STR[si.st] + (ci.inv ? " (käänteinen)" : "");
: STATE_STR[si.st] + (ci.i ? " (käänteinen)" : "");

//Extended status for instance (by user scripts)
if (si.str != "") {
Expand Down Expand Up @@ -131,20 +131,20 @@
qs("s-pi1").innerHTML = buildPriceTable(s.p[1]);

/**
* Helper that builds price/cmd table for today or tomorrow
* Helper that builds price/cmd table for today or tomorrow
*/
const buildPriceList = (dayIndex, element) => {
let header = ` <tr><td class="t bg">Aika</td><td class="t bg">Hinta</td><td class="t bg">Ohjaus</td></tr>`;

if (s.p[dayIndex].ts == 0) {
element.innerHTML = `${header}${notYetKnown}`;;
return;
}
}

//------------------------------
// Cheapest hours logic
// This needs match 1:1 the Shelly script side
//------------------------------
//------------------------------
let cheapest = [];
if (ci.mode === 2) {
//Select increment (a little hacky - to support custom periods too)
Expand All @@ -165,7 +165,7 @@
let end = (i + ci.m2.p);

if (ci.m2.p < 0 && i == 0) {
//Custom period 1
//Custom period 1
start = ci.m2.ps;
end = ci.m2.pe;

Expand Down Expand Up @@ -235,7 +235,7 @@

//------------------------------
// Building the price list
//------------------------------
//------------------------------
element.innerHTML = header;

let per = 0;
Expand All @@ -260,7 +260,7 @@
&& !foff;

//Invert
if (ci.inv) {
if (ci.i) {
cmd = !cmd;
}

Expand All @@ -272,13 +272,13 @@
&& ((ci.m2.p < 0 && (i == ci.m2.ps || i == ci.m2.pe))
|| (ci.m2.p == -2 && (i == ci.m2.ps2 || i == ci.m2.pe2))
|| (ci.m2.p > 0 && i >= per + ci.m2.p))) {

//Period changed
per += ci.m2.p;
bg = !bg;
}

element.innerHTML +=
element.innerHTML +=
`<tr style="${date.getHours() === new Date().getHours() && dayIndex == 0 ? `font-weight:bold;` : ``}${(bg ? "background:#ededed;" : "")}">
<td class="fit">${formatTime(date, false)}</td>
<td>${row[1].toFixed(2)} c/kWh</td>
Expand Down

0 comments on commit f20fd4e

Please sign in to comment.