summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-10 03:20:10 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-10 03:20:10 +0300
commit05c5d18f7619c28e620d42c0921f81ced780cc2d (patch)
tree26ab7a74daba5d0f37ddb0bbe467e84fdc7fb1b6 /bin
parent54ddea4614dbd31dad577ae5fdb8ec4821490199 (diff)
save
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mqtt_node_util.py5
-rw-r--r--bin/web_kbn.py22
2 files changed, 18 insertions, 9 deletions
diff --git a/bin/mqtt_node_util.py b/bin/mqtt_node_util.py
index c1d457c..5587739 100755
--- a/bin/mqtt_node_util.py
+++ b/bin/mqtt_node_util.py
@@ -48,7 +48,6 @@ if __name__ == '__main__':
help='mqtt modules to include')
parser.add_argument('--switch-relay', choices=[0, 1], type=int,
help='send relay state')
- parser.add_argument('--legacy-relay', action='store_true')
parser.add_argument('--push-ota', type=str, metavar='OTA_FILENAME',
help='push OTA, receives path to firmware.bin')
parser.add_argument('--no-wait', action='store_true',
@@ -80,8 +79,10 @@ if __name__ == '__main__':
if arg.modules:
for m in arg.modules:
kwargs = {}
- if m == 'relay' and arg.legacy_relay:
+ if m == 'relay' and MqttNodesConfig().node_uses_legacy_relay_power_payload(arg.node_id):
kwargs['legacy_topics'] = True
+ if m == 'temphum' and MqttNodesConfig().node_uses_legacy_temphum_data_payload(arg.node_id):
+ kwargs['legacy_payload'] = True
module_instance = mqtt_node.load_module(m, **kwargs)
if m == 'relay' and arg.switch_relay is not None:
relay_module = module_instance
diff --git a/bin/web_kbn.py b/bin/web_kbn.py
index e160fde..8b4ca6f 100644
--- a/bin/web_kbn.py
+++ b/bin/web_kbn.py
@@ -75,27 +75,35 @@ class WebSite(http.HTTPServer):
self.app.router.add_static('/assets/', path=homekit_path('web', 'kbn_assets'))
- self.get('/', self.get_index)
- self.get('/modems', self.get_modems)
+ self.get('/main.cgi', self.get_index)
+ self.get('/modems.cgi', self.get_modems)
async def render_page(self,
req: http.Request,
+ template_name: str,
+ title: Optional[str] = None,
context: Optional[dict] = None):
if context is None:
context = {}
context = {
**context,
- 'head_static': get_head_static(),
- 'title': 'this is title'
+ 'head_static': get_head_static()
}
- response = aiohttp_jinja2.render_template('index.html', req, context=context)
+ if title is not None:
+ context['title'] = title
+ response = aiohttp_jinja2.render_template(template_name+'.j2', req, context=context)
return response
async def get_index(self, req: http.Request):
- return await self.render_page(req)
+ return await self.render_page(req, 'index',
+ title="Home web site")
async def get_modems(self, req: http.Request):
- pass
+ mc = ModemsConfig()
+ print(mc)
+ return await self.render_page(req, 'modems',
+ title='Состояние модемов',
+ context=dict(modems=ModemsConfig()))
if __name__ == '__main__':