Skip to content

Commit

Permalink
add current sensor scale & offset
Browse files Browse the repository at this point in the history
  • Loading branch information
KipK committed Dec 1, 2024
1 parent 5747baf commit 66d0389
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 19 deletions.
62 changes: 61 additions & 1 deletion src/components/blocks/configuration/Evse.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import Firmware from "./../../../routes/Firmware.svelte";
import Limit from "./../main/Limit.svelte";
import { serialQueue } from "./../../../lib/queue.js";
import { onMount } from "svelte";
import { _ } from 'svelte-i18n'
import Borders from "./../../ui/Borders.svelte";
Expand All @@ -14,6 +15,7 @@
import { submitFormData } from "./../../../lib/utils.js"
let mounted = false
let scaleoffset_submit_state = ""
const states_items = [{name: $_("disabled"), value: false}, {name: $_("active"), value: true}]
const service_items = [{name: "Auto", value: 0},{name: "Level 1", value: 1},{name: "Level 2", value: 2}]
const phase_items = [{name: $_("no"), value: false}, {name: $_("yes"), value: true}]
Expand All @@ -23,6 +25,8 @@
default_state: {val: false, status: "", input: undefined, req: false},
is_threephase: {val: false, status: "", input: undefined, req: false},
scheduler_start_window: {val: 0, status: "", input: undefined, req: false},
scale: {var: 220, status: "", input: undefined, req: false},
offset: {var: 0, status: "", input: undefined, req: false},
pause_uses_disabled: {val: null, status: "", input: undefined, req: false},
service: {val: false, status: "", input: undefined, req: false},
led_brightness: {val: "", status: "", input: undefined, req: false}
Expand All @@ -33,13 +37,38 @@
formdata.default_state.val = $config_store.default_state
formdata.is_threephase.val = $config_store.is_threephase
formdata.scheduler_start_window.val = $config_store.scheduler_start_window
formdata.scale.val = $config_store.scale
formdata.offset.val = $config_store.offset
formdata.pause_uses_disabled.val = $config_store.pause_uses_disabled
formdata.service.val = $config_store.service
formdata.led_brightness.val = $config_store.led_brightness
}
let setProperty = async (prop) => {
await submitFormData({prop: prop, form: formdata , i18n_path: "config.shaper.missing-"})
await submitFormData({prop: prop, form: formdata , i18n_path: "config.evse.missing-"})
}
let scaleoffset_submit = async () => {
formdata.scale.status = "loading"
formdata.offset.status = "loading"
const data = {
scale: formdata.scale.val,
offset: formdata.offset.val
}
if (await serialQueue.add(()=>config_store.upload(data)))
{
formdata.scale.status = "ok"
formdata.offset.status = "ok"
return true
}
else {
formdata.scale.status = "error"
formdata.offset.status = "error"
return false
}
}
onMount(()=> {
Expand Down Expand Up @@ -132,6 +161,37 @@
</div>
</Borders>
</div>
<div class="my-1 is-flex is-justify-content-center" >
<Borders grow={true} has_help={true}>
<div slot="help">
{@html $_("config.evse.scale")}
</div>
<div class="is-uppercase has-text-weight-bold is-size-6 mb-3">{$_("config.evse.sensorscale")}</div>
<div class="is-flex is-justify-content-center is-align-items-center">
<div class="inputbox">
<InputForm
is_inline type="number" min=0 max=3600
bind:this={formdata.scale.input}
bind:value={formdata.scale.val}
bind:status={formdata.scale.status}
onChange={()=>scaleoffset_submit()}
/>
</div>
</div>
<div class="is-uppercase has-text-weight-bold is-size-6 mb-3">{$_("config.evse.sensoroffset")}</div>
<div class="is-flex is-justify-content-center is-align-items-center">
<div class="inputbox">
<InputForm
is_inline type="number" min=0 max=3600
bind:this={formdata.offset.input}
bind:value={formdata.offset.val}
bind:status={formdata.offset.status}
onChange={()=>scaleoffset_submit()}
/>
</div>
</div>
</Borders>
</div>
<div class="my-1 is-flex is-justify-content-center" >
<Borders grow={true}>
<div class="is-uppercase has-text-weight-bold is-size-6 mb-3">{$_("config.evse.service")}</div>
Expand Down
31 changes: 15 additions & 16 deletions src/components/blocks/configuration/VechicleMQTT.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,25 @@
let stg_submit = async () => {
stg_submit_state = "loading"
stg_submit_state = "loading"
const data = {
mqtt_vehicle_soc: $config_store.mqtt_vehicle_soc,
mqtt_vehicle_range: $config_store.mqtt_vehicle_range,
mqtt_vehicle_eta: $config_store.mqtt_vehicle_eta,
mqtt_vehicle_range_miles: $config_store.mqtt_vehicle_range_miles
}
const data = {
mqtt_vehicle_soc: $config_store.mqtt_vehicle_soc,
mqtt_vehicle_range: $config_store.mqtt_vehicle_range,
mqtt_vehicle_eta: $config_store.mqtt_vehicle_eta,
mqtt_vehicle_range_miles: $config_store.mqtt_vehicle_range_miles
}
if (await serialQueue.add(()=>config_store.upload(data)))
{
stg_submit_state = "ok"
return true
if (await serialQueue.add(()=>config_store.upload(data)))
{
stg_submit_state = "ok"
return true
}
else {
stg_submit_state = "error"
return false
}
else {
stg_submit_state = "error"
return false
}
}
</script>

<div class="mt-1 mb-1">
Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
"pause": "Pause Status",
"led-bn": "Led Brightness",
"led-bn-help": "RGB leds brightness (not related to LCD panel brightness)",
"scale": "Adjust current sensor scale and offset",
"sensorscale": "Current scale",
"sensoroffset": "Current offset",
"threephase": "Three-phase",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@
"pause": "Mode de pause",
"led-bn": "Luminosité des LEDs",
"led-bn-help": "Luminosité des LEDs RGB (ne concerne pas la luminosité du LCD)",
"sensorscale": "Échelle courant",
"sensoroffset": "Décalage courant",
"scale": "Ajuster l'échelle et offset du capteur de courant",
"sensorscale": "Échelle capteur de courant",
"sensoroffset": "Offset capteur de courant",
"threephase": "Triphasé",
"threephase-help": "Activer quand la charge se fait en triphasé pour avoir un calcul correct de la puissance",
"defaultstate": "État par défaut",
Expand Down

0 comments on commit 66d0389

Please sign in to comment.