Skip to content

Commit

Permalink
Merge branch 'master' into divert_sim_summary
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremypoulter authored May 9, 2023
2 parents ca22736 + ce2dfe9 commit 5f9309f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ paths:
rapi_connected: 1
amp: 0
pilot: 32
max_current: 32
temp1: 282
temp2: -2560
temp3: -2560
Expand Down
2 changes: 2 additions & 0 deletions docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Main settings:

`<base-topic>/divertmode/set [1 | 2]` : enable (1)/ disable (2) divert mode
`<base-topic>/shaper/set [0 | 1]` : temporary enable (1)/ disable (0) current shaper ( doesn't survive reboot )
`<base-topic>/restart` : restarts the gateway



MQTT setup is pre-populated with OpenEnergyMonitor [emonPi default MQTT server credentials](https://guide.openenergymonitor.org/technical/credentials/#mqtt).
Expand Down
3 changes: 3 additions & 0 deletions models/Status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ properties:
pilot:
type: integer
description: 'the pilot value, in amps'
max_current:
type: integer
description: 'the actual max current value defined either by max_current_soft or a running claim'
temp:
type: number
description: 'the derived temperature, in 1/10th °C'
Expand Down
4 changes: 3 additions & 1 deletion scripts/auto_fw_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
def get_build_flag():
ret = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, text=True) #Uses any tags
full_hash = ret.stdout.strip()
ret = subprocess.run(["git", "symbolic-ref", "--short", "HEAD"], stdout=subprocess.PIPE, text=True) # retrieve branch name
branch = ret.stdout.strip()
short_hash = full_hash[:8]

build_version = "local_" + short_hash
build_version = "local_" + branch + "_" + short_hash

# get the GITHUB_REF_NAME
ref_name = os.environ.get('GITHUB_REF_NAME')
Expand Down
2 changes: 1 addition & 1 deletion src/divert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ void DivertTask::update_state()
if(_state != current_evse_state)
{
_state = current_evse_state;
event["divert_active"] = isActive();
}
}

event["divert_active"] = isActive();
event["charge_rate"] = _charge_rate;
event["trigger_current"] = trigger_current;
event["voltage"] = voltage;
Expand Down
2 changes: 2 additions & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class InputTask : public MicroTasks::Task
event["vehicle"] = evse.isVehicleConnected() ? 1 : 0;
event["colour"] = evse.getStateColour();
event["pilot"] = evse.getChargeCurrent();
event["max_current"] = evse.getMaxCurrent();
event["manual_override"] = manual.isActive() ? 1 : 0; //TODO: remove this
event["status"] = evse.getState().toString();
event["elapsed"] = evse.getSessionElapsed();
Expand Down Expand Up @@ -104,6 +105,7 @@ void create_rapi_json(JsonDocument &doc)
doc["voltage"] = evse.getVoltage() * VOLTS_SCALE_FACTOR;
doc["power"] = evse.getPower() * POWER_SCALE_FACTOR;
doc["pilot"] = evse.getChargeCurrent();
doc["max_current"] = evse.getMaxCurrent();
if(evse.isTemperatureValid(EVSE_MONITOR_TEMP_MONITOR)) {
doc["temp"] = evse.getTemperature(EVSE_MONITOR_TEMP_MONITOR) * TEMP_SCALE_FACTOR;
} else {
Expand Down
11 changes: 11 additions & 0 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ void mqttmsg_callback(MongooseString topic, MongooseString payload) {
mqtt_clear_schedule(payload_str.toInt());
}

// Restart
else if (topic_string == mqtt_topic + "/restart") {
restart_system();
}

else
{
// If MQTT message is RAPI command
Expand Down Expand Up @@ -360,6 +365,12 @@ mqtt_connect()
mqtt_sub_topic = mqtt_topic + "/schedule/clear";
mqttclient.subscribe(mqtt_sub_topic);
yield();

// ask for a system restart
mqtt_sub_topic = mqtt_topic + "/restart";
mqttclient.subscribe(mqtt_sub_topic);
yield();

connecting = false;
});

Expand Down

0 comments on commit 5f9309f

Please sign in to comment.