Last active
April 20, 2021 11:16
-
-
Save FriesischScott/6760a5548c6ebb0bb4e1e9faf0b85213 to your computer and use it in GitHub Desktop.
CO2 content of the beer based on the beer temperature and CO2 head pressure
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
function carbonation(P, T) { | |
return (P + 1.013) * Math.exp(-10.73797 + (2617.25 / (T + 273.15))) * 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works as expected:

My script in openHab:
`var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
press = parseFloat(itemRegistry.getItem("TPMS_8a8eb4_press").getState(),10)
temp = parseFloat(itemRegistry.getItem("TPMS_8a8eb4_temp").getState(),10)
logger.info("FR press: "+press);
logger.info("FR temp: "+temp);
carbo = carbonation(press/100, temp)
logger.info("FR carbo: "+carbo);
events.postUpdate("TPMS_8a8eb4_carb", carbo);
press = parseFloat(itemRegistry.getItem("TPMS_8a8e6a_press").getState(),10)
temp = parseFloat(itemRegistry.getItem("TPMS_8a8e6a_temp").getState(),10)
logger.info("RL press: "+press);
logger.info("RL temp: "+temp);
carbo = carbonation(press/100, temp)
logger.info("FR carbo: "+carbo);
events.postUpdate("TPMS_8a8e6a_carb", carbo);
function carbonation(P, T) {
return (P + 1.013) * Math.exp(-10.73797 + (2617.25 / (T + 273.15))) * 10
}`