Created
December 30, 2019 23:22
-
-
Save beikeland/e9efd374acce35b3feb7a84fd29afe4a to your computer and use it in GitHub Desktop.
OpenEVSE current sharing over MQTT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on init | |
do | |
setvar $leaf=1 %leaf state | |
setvar $tesla=1 | |
setvar $pn=0 %pilot new | |
setvar $teslamp="" | |
subscribe local "ev/+/state" | |
subscribe local "ev/+" | |
on topic local "ev/+" | |
do | |
if $this_data = "connected" then | |
println $this_topic | " = " | $this_data | |
endif | |
on topic local "ev/+/state" | |
do | |
setvar $teslamp=1 | |
if $this_topic = "ev/l/state" then | |
if $this_data = $leaf then | |
setvar $teslamp=0 | |
else | |
if $this_data = then | |
setvar $teslamp=0 | |
else | |
setvar $leaf = $this_data | |
println "!!charge leaf "| $leaf | "<tesla: " | $tesla | ">" | |
endif | |
endif | |
endif | |
if $this_topic = "ev/t/state" then | |
if $this_data = $tesla then | |
setvar $teslamp=0 | |
else | |
if $this_data = 2 then | |
setvar $teslamp=0 | |
else | |
setvar $tesla = $this_data | |
println "!!charge tesla "| $tesla | "<leaf: " | $leaf | ">" | |
endif | |
endif | |
endif | |
if $teslamp = 1 then | |
if $leaf = 3 then %l | |
if $tesla = 3 then %l+t | |
setvar $pn=10 | " V" %v | |
publish local "ev/t/rapi/in/$SC" $pn | |
publish local "ev/l/rapi/in/$SC" $pn | |
else %l | |
setvar $pn=6 | " V" %v | |
publish local "ev/t/rapi/in/$SC" $pn | |
setvar $pn=14 | " V" %v | |
publish local "ev/l/rapi/in/$SC" $pn | |
endif | |
else | |
if $tesla = 3 then %t | |
setvar $pn=14 | " V" %v | |
publish local "ev/t/rapi/in/$SC" $pn | |
setvar $pn=6 | " V" %v | |
publish local "ev/l/rapi/in/$SC" $pn | |
endif | |
endif | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment