Possibility to use curl to get values in plaintext from document root. Plan is to prepend register list to the output.
This commit is contained in:
parent
66481d8404
commit
88b17e496f
|
@ -23,37 +23,29 @@ server {
|
||||||
# include snippets/snakeoil.conf;
|
# include snippets/snakeoil.conf;
|
||||||
|
|
||||||
root /home/jarno/enervent-ctrl/enervent-ctrl-python/html;
|
root /home/jarno/enervent-ctrl/enervent-ctrl-python/html;
|
||||||
|
index index.html;
|
||||||
# Add index.php to the list if you are using PHP
|
|
||||||
index index.html index.htm index.nginx-debian.html;
|
|
||||||
|
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
# First attempt to serve request as file, then
|
# First attempt to serve request as file, then
|
||||||
# as directory, then fall back to displaying a 404.
|
# as directory, then fall back to displaying a 404.
|
||||||
|
if ($http_user_agent ~* "^curl") {
|
||||||
|
proxy_pass http://enervent-ctrl;
|
||||||
|
}
|
||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api {
|
#location ~ /static|/coils|/registers {
|
||||||
|
# root /home/jarno/enervent-ctrl/enervent-ctrl-python/html;
|
||||||
|
#}
|
||||||
|
|
||||||
|
location ~ /api {
|
||||||
proxy_pass http://enervent-ctrl;
|
proxy_pass http://enervent-ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
# pass PHP scripts to FastCGI server
|
|
||||||
#
|
|
||||||
#location ~ \.php$ {
|
|
||||||
# include snippets/fastcgi-php.conf;
|
|
||||||
#
|
|
||||||
# # With php-fpm (or other unix sockets):
|
|
||||||
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
|
|
||||||
# # With php-cgi (or other tcp sockets):
|
|
||||||
# fastcgi_pass 127.0.0.1:9000;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# deny access to .htaccess files, if Apache's document root
|
|
||||||
# concurs with nginx's one
|
|
||||||
#
|
|
||||||
#location ~ /\.ht {
|
|
||||||
# deny all;
|
|
||||||
#}
|
|
||||||
}
|
}
|
|
@ -4,11 +4,11 @@ from flask import jsonify
|
||||||
|
|
||||||
class PingvinCoil():
|
class PingvinCoil():
|
||||||
"""Single coil data structure"""
|
"""Single coil data structure"""
|
||||||
def __init__(self, symbol="reserved", description="reserved"):
|
def __init__(self, symbol="-", description="-"):
|
||||||
self.symbol = symbol
|
self.symbol = symbol
|
||||||
self.value = False
|
self.value = False
|
||||||
self.description = description
|
self.description = description
|
||||||
self.reserved = symbol == "reserved" and description == "reserved"
|
self.reserved = symbol == "-" and description == "-"
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return {
|
return {
|
||||||
|
@ -88,7 +88,7 @@ class PingvinCoils():
|
||||||
PingvinCoil(),
|
PingvinCoil(),
|
||||||
PingvinCoil(),
|
PingvinCoil(),
|
||||||
PingvinCoil("COIL_COOLING_EN", "Active cooling function enabled"),
|
PingvinCoil("COIL_COOLING_EN", "Active cooling function enabled"),
|
||||||
PingvinCoil("COIL_LTO_EN"),
|
PingvinCoil("COIL_LTO_EN", "N/A"),
|
||||||
PingvinCoil("COIL_HEATING_EN", "Active heating function enabled"),
|
PingvinCoil("COIL_HEATING_EN", "Active heating function enabled"),
|
||||||
PingvinCoil("COIL_LTO_DEFROST_EN", "HRC defrosting function enabled during winter season"),
|
PingvinCoil("COIL_LTO_DEFROST_EN", "HRC defrosting function enabled during winter season"),
|
||||||
PingvinCoil(),
|
PingvinCoil(),
|
||||||
|
@ -142,8 +142,9 @@ class PingvinCoils():
|
||||||
def print(self, debug=False):
|
def print(self, debug=False):
|
||||||
"""Human-readable print of all coil values"""
|
"""Human-readable print of all coil values"""
|
||||||
coilvals = ""
|
coilvals = ""
|
||||||
|
null = ""
|
||||||
for i, coil in enumerate(self.coils):
|
for i, coil in enumerate(self.coils):
|
||||||
coilvals = coilvals + f"Coil {i}\t{coil.value} [{coil.symbol}] ({coil.description})\n"
|
coilvals = coilvals + f"Coil {i : <{4}}{coil.value : <{2}} {coil.symbol : <{25}}{coil.description}\n"
|
||||||
return coilvals
|
return coilvals
|
||||||
|
|
||||||
def serialize(self, include_reserved=False):
|
def serialize(self, include_reserved=False):
|
||||||
|
|
|
@ -29,6 +29,9 @@ def coil(address):
|
||||||
elif request.method == 'PUT':
|
elif request.method == 'PUT':
|
||||||
return {"success": pingvin.coils.write(address)}
|
return {"success": pingvin.coils.write(address)}
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def dump():
|
||||||
|
return pingvin.coils.print(debug=DEBUG)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
log.info(f"Starting enervent-logger {VERSION}")
|
log.info(f"Starting enervent-logger {VERSION}")
|
||||||
|
|
Loading…
Reference in New Issue