homecontrol-dash: use double quotes
This commit is contained in:
parent
b84d2ce1fb
commit
5da17b01c4
1 changed files with 55 additions and 55 deletions
|
@ -20,7 +20,7 @@ PORT=8201
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
# arguments
|
# arguments
|
||||||
parser = argparse.ArgumentParser(description='homecontrol')
|
parser = argparse.ArgumentParser(description="homecontrol")
|
||||||
parser.add_argument("-a", "--address", dest="address", type=str, help="homecontrol address")
|
parser.add_argument("-a", "--address", dest="address", type=str, help="homecontrol address")
|
||||||
parser.add_argument("-p", "--port", dest="port", type=str, help="dashboard port")
|
parser.add_argument("-p", "--port", dest="port", type=str, help="dashboard port")
|
||||||
parser.add_argument("-c", "--config", dest="config", type=str, help="config file",
|
parser.add_argument("-c", "--config", dest="config", type=str, help="config file",
|
||||||
|
@ -54,7 +54,7 @@ def setup():
|
||||||
config["port"] = args.port
|
config["port"] = args.port
|
||||||
|
|
||||||
# save to file
|
# save to file
|
||||||
with open(args.config, 'w') as config_file:
|
with open(args.config, "w") as config_file:
|
||||||
json.dump(config, config_file)
|
json.dump(config, config_file)
|
||||||
|
|
||||||
# temporary option
|
# temporary option
|
||||||
|
@ -155,7 +155,7 @@ class HCDash:
|
||||||
app.config.suppress_callback_exceptions = True
|
app.config.suppress_callback_exceptions = True
|
||||||
|
|
||||||
app.layout = html.Div(children=[
|
app.layout = html.Div(children=[
|
||||||
html.H1(children='dashboard.ykonni.de'),
|
html.H1(children="dashboard.ykonni.de"),
|
||||||
dbc.Row([
|
dbc.Row([
|
||||||
dbc.Col(dcc.Tabs(id="tabs-select-class", value=tab, children=tabs))
|
dbc.Col(dcc.Tabs(id="tabs-select-class", value=tab, children=tabs))
|
||||||
]),
|
]),
|
||||||
|
@ -202,9 +202,9 @@ class HCDash:
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
[Output("sensor-data", "children"),
|
[Output("sensor-data", "children"),
|
||||||
Output('slider-min', 'min'), Output('slider-min', 'value'),
|
Output("slider-min", "min"), Output("slider-min", "value"),
|
||||||
Output('slider-min', 'max'), Output('slider-max', 'min'),
|
Output("slider-min", "max"), Output("slider-max", "min"),
|
||||||
Output('slider-max', 'value'), Output('slider-max', 'max')],
|
Output("slider-max", "value"), Output("slider-max", "max")],
|
||||||
[Input("tabs-select-sensor", "value")])
|
[Input("tabs-select-sensor", "value")])
|
||||||
def update_sensor(sensorId):
|
def update_sensor(sensorId):
|
||||||
self.logger.debug(f"update_sensor: {sensorId}")
|
self.logger.debug(f"update_sensor: {sensorId}")
|
||||||
|
@ -213,37 +213,37 @@ class HCDash:
|
||||||
dbc.Row([
|
dbc.Row([
|
||||||
dbc.Col(
|
dbc.Col(
|
||||||
dcc.Graph(
|
dcc.Graph(
|
||||||
id='graph-sensor-values',
|
id="graph-sensor-values",
|
||||||
figure={
|
figure={
|
||||||
'data': [ {'x': [0], 'y': [0], 'mode': 'line', 'name': 'None'} ],
|
"data": [ {"x": [0], "y": [0], "mode": "line", "name": "None"} ],
|
||||||
'layout': { 'title': 'initial values' }
|
"layout": { "title": "initial values" }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
dbc.Row([
|
dbc.Row([
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-min-txt', style={'marginLeft': '5em', 'marginRight': '3em'}),
|
html.Div(id="slider-min-txt", style={"marginLeft": "5em", "marginRight": "3em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-min', min=0, max=round(time.time()), step=600,
|
dcc.Slider(id="slider-min", min=0, max=round(time.time()), step=600,
|
||||||
value=0 ),
|
value=0 ),
|
||||||
], style={'marginLeft': '5em', 'marginRight': '3em'}
|
], style={"marginLeft": "5em", "marginRight": "3em"}
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-max-txt', style={'marginLeft': '3em', 'marginRight':
|
html.Div(id="slider-max-txt", style={"marginLeft": "3em", "marginRight":
|
||||||
'3em'}),
|
"3em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-max', min=0, max=round(time.time()), step=600,
|
dcc.Slider(id="slider-max", min=0, max=round(time.time()), step=600,
|
||||||
value=round(time.time())),
|
value=round(time.time())),
|
||||||
], style={'marginLeft': '3em', 'marginRight': '3em'}
|
], style={"marginLeft": "3em", "marginRight": "3em"}
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-limit-txt', style={'marginLeft': '3em', 'marginRight': '5em'}),
|
html.Div(id="slider-limit-txt", style={"marginLeft": "3em", "marginRight": "5em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-limit', min=0, max=1000, step=10, value=0 ),
|
dcc.Slider(id="slider-limit", min=0, max=1000, step=10, value=0 ),
|
||||||
], style={'marginLeft': '3em', 'marginRight': '5em'}
|
], style={"marginLeft": "3em", "marginRight": "5em"}
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
|
@ -260,30 +260,30 @@ class HCDash:
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-min-txt', 'children'),
|
Output("slider-min-txt", "children"),
|
||||||
[Input('slider-min', 'value')])
|
[Input("slider-min", "value")])
|
||||||
def update_slider_min_txt(value):
|
def update_slider_min_txt(value):
|
||||||
return f"From: {self.pTime(value)}"
|
return f"From: {self.pTime(value)}"
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-max-txt', 'children'),
|
Output("slider-max-txt", "children"),
|
||||||
[Input('slider-max', 'value')])
|
[Input("slider-max", "value")])
|
||||||
def update_slider_max_txt(value):
|
def update_slider_max_txt(value):
|
||||||
return f"To: {self.pTime(value)}"
|
return f"To: {self.pTime(value)}"
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-limit-txt', 'children'),
|
Output("slider-limit-txt", "children"),
|
||||||
[Input('slider-limit', 'value')])
|
[Input("slider-limit", "value")])
|
||||||
def update_slider_limit_txt(value):
|
def update_slider_limit_txt(value):
|
||||||
return f"Limit: {value if value > 0 else None}"
|
return f"Limit: {value if value > 0 else None}"
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('graph-sensor-values', 'figure'),
|
Output("graph-sensor-values", "figure"),
|
||||||
[Input('tabs-select-sensor', 'value'), Input('slider-min', 'value'),
|
[Input("tabs-select-sensor", "value"), Input("slider-min", "value"),
|
||||||
Input('slider-max', 'value'), Input('slider-limit', 'value')])
|
Input("slider-max", "value"), Input("slider-limit", "value")])
|
||||||
def update_graph_sensor_values(sensorId, min_ts, max_ts, limit):
|
def update_graph_sensor_values(sensorId, min_ts, max_ts, limit):
|
||||||
res = {}
|
res = {}
|
||||||
if min_ts > 0:
|
if min_ts > 0:
|
||||||
|
@ -301,8 +301,8 @@ class HCDash:
|
||||||
x = [0]
|
x = [0]
|
||||||
y = [0]
|
y = [0]
|
||||||
return {
|
return {
|
||||||
'data': [ {'x': x, 'y': y, 'mode': 'line', 'name': f'{s}'} ],
|
"data": [ {"x": x, "y": y, "mode": "line", "name": f"{s}"} ],
|
||||||
'layout': { 'title': f'Data for sensor: {s} ({len(x)} elements)' }
|
"layout": { "title": f"Data for sensor: {s} ({len(x)} elements)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,37 +323,37 @@ class HCDash:
|
||||||
dbc.Row([
|
dbc.Row([
|
||||||
dbc.Col(
|
dbc.Col(
|
||||||
dcc.Graph(
|
dcc.Graph(
|
||||||
id='graph-actor-values',
|
id="graph-actor-values",
|
||||||
figure={
|
figure={
|
||||||
'data': [ {'x': [0], 'y': [0], 'mode': 'line', 'name': 'None'} ],
|
"data": [ {"x": [0], "y": [0], "mode": "line", "name": "None"} ],
|
||||||
'layout': { 'title': 'initial values' }
|
"layout": { "title": "initial values" }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
dbc.Row([
|
dbc.Row([
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-actor-min-txt', style={'marginLeft': '5em', 'marginRight': '3em'}),
|
html.Div(id="slider-actor-min-txt", style={"marginLeft": "5em", "marginRight": "3em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-actor-min', min=0, max=round(time.time()), step=600,
|
dcc.Slider(id="slider-actor-min", min=0, max=round(time.time()), step=600,
|
||||||
value=0 ),
|
value=0 ),
|
||||||
], style={'marginLeft': '5em', 'marginRight': '3em'}
|
], style={"marginLeft": "5em", "marginRight": "3em"}
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-actor-max-txt', style={'marginLeft': '3em', 'marginRight':
|
html.Div(id="slider-actor-max-txt", style={"marginLeft": "3em", "marginRight":
|
||||||
'3em'}),
|
"3em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-actor-max', min=0, max=round(time.time()), step=600,
|
dcc.Slider(id="slider-actor-max", min=0, max=round(time.time()), step=600,
|
||||||
value=round(time.time())),
|
value=round(time.time())),
|
||||||
], style={'marginLeft': '3em', 'marginRight': '3em'}
|
], style={"marginLeft": "3em", "marginRight": "3em"}
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
dbc.Col([
|
dbc.Col([
|
||||||
html.Div(id='slider-actor-limit-txt', style={'marginLeft': '3em', 'marginRight': '5em'}),
|
html.Div(id="slider-actor-limit-txt", style={"marginLeft": "3em", "marginRight": "5em"}),
|
||||||
html.Div([
|
html.Div([
|
||||||
dcc.Slider(id='slider-actor-limit', min=0, max=1000, step=10, value=0 ),
|
dcc.Slider(id="slider-actor-limit", min=0, max=1000, step=10, value=0 ),
|
||||||
], style={'marginLeft': '3em', 'marginRight': '5em'}
|
], style={"marginLeft": "3em", "marginRight": "5em"}
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
|
@ -379,24 +379,24 @@ class HCDash:
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-actor-min-txt', 'children'),
|
Output("slider-actor-min-txt", "children"),
|
||||||
[Input('slider-actor-min', 'value')])
|
[Input("slider-actor-min", "value")])
|
||||||
def update_slider_actor_min_txt(value):
|
def update_slider_actor_min_txt(value):
|
||||||
# self.logger.debug(f"update_slider_actor_min_txt: {value}")
|
# self.logger.debug(f"update_slider_actor_min_txt: {value}")
|
||||||
return f"From: {self.pTime(value)}"
|
return f"From: {self.pTime(value)}"
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-actor-max-txt', 'children'),
|
Output("slider-actor-max-txt", "children"),
|
||||||
[Input('slider-actor-max', 'value')])
|
[Input("slider-actor-max", "value")])
|
||||||
def update_slider_actor_max_txt(value):
|
def update_slider_actor_max_txt(value):
|
||||||
# self.logger.debug(f"update_slider_actor_max_txt: {value}")
|
# self.logger.debug(f"update_slider_actor_max_txt: {value}")
|
||||||
return f"To: {self.pTime(value)}"
|
return f"To: {self.pTime(value)}"
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('slider-actor-limit-txt', 'children'),
|
Output("slider-actor-limit-txt", "children"),
|
||||||
[Input('slider-actor-limit', 'value')])
|
[Input("slider-actor-limit", "value")])
|
||||||
def update_slider_actor_limit_txt(value):
|
def update_slider_actor_limit_txt(value):
|
||||||
return f"Limit: {value if value > 0 else None}"
|
return f"Limit: {value if value > 0 else None}"
|
||||||
|
|
||||||
|
@ -411,9 +411,9 @@ class HCDash:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output('graph-actor-values', 'figure'),
|
Output("graph-actor-values", "figure"),
|
||||||
[Input('tabs-select-actor', 'value'), Input('slider-actor-min', 'value'),
|
[Input("tabs-select-actor", "value"), Input("slider-actor-min", "value"),
|
||||||
Input('slider-actor-max', 'value'), Input('slider-actor-limit', 'value')])
|
Input("slider-actor-max", "value"), Input("slider-actor-limit", "value")])
|
||||||
def update_graph_actor(actorId, min_ts, max_ts, limit):
|
def update_graph_actor(actorId, min_ts, max_ts, limit):
|
||||||
self.logger.debug(f"update_graph_actor: {actorId}, {min_ts}, {max_ts}, {limit}")
|
self.logger.debug(f"update_graph_actor: {actorId}, {min_ts}, {max_ts}, {limit}")
|
||||||
res = {}
|
res = {}
|
||||||
|
@ -431,8 +431,8 @@ class HCDash:
|
||||||
x = [0]
|
x = [0]
|
||||||
y = [0]
|
y = [0]
|
||||||
return {
|
return {
|
||||||
'data': [ {'x': x, 'y': y, 'mode': 'markers', 'name': f'{s}'} ],
|
"data": [ {"x": x, "y": y, "mode": "markers", "name": f"{s}"} ],
|
||||||
'layout': { 'title': f'Data for sensor: {s} ({len(x)} elements)' }
|
"layout": { "title": f"Data for sensor: {s} ({len(x)} elements)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,5 +445,5 @@ def main():
|
||||||
hcd = HCDash(config)
|
hcd = HCDash(config)
|
||||||
hcd.main()
|
hcd.main()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue