diff --git a/src/components/touchlink-page/index.tsx b/src/components/touchlink-page/index.tsx index 90ffb9365..feb83c388 100644 --- a/src/components/touchlink-page/index.tsx +++ b/src/components/touchlink-page/index.tsx @@ -10,6 +10,8 @@ import cx from "classnames"; import { Link } from "react-router-dom"; import { TouchlinkApi } from "../../actions/TouchlinkApi"; import { WithTranslation, withTranslation } from "react-i18next"; +import { Column } from "react-table"; +import { Table } from "../grid/ReactTableCom"; @@ -28,39 +30,45 @@ export class TouchlinkPage extends Component[] = [ + { + Header: t('zigbee:ieee_address') as string, + accessor: (touchlinkDevice) => touchlinkDevice.ieee_address, + Cell: ({ row: { original: touchlinkDevice } }) => devices[touchlinkDevice.ieee_address] ? + ({touchlinkDevice.ieee_address}) : touchlinkDevice.ieee_address + + }, + { + Header: t('zigbee:friendly_name') as string, + accessor: (touchlinkDevice) => devices[touchlinkDevice.ieee_address]?.friendly_name, + }, + { + id: 'channel', + Header: t('zigbee:channel') as string, + accessor: 'channel' + + }, + + { + id: 'actions', + Header: '', + Cell: ({ row: { original: touchlinkDevice } }) => { + return ( +
+ disabled={touchlinkInProgress} item={touchlinkDevice} title={t('identify')} className="btn btn-primary" onClick={this.onIdentifyClick}> + disabled={touchlinkInProgress} item={touchlinkDevice} title={t('factory_reset')} className="btn btn-danger" onClick={this.onResetClick}> +
+ ) + } + }, + + + ]; return (
- - - - - - - - - - - - {touchlinkDevices.map((touchlinkDevice, idx) => ( - - - - - - - - ))} - -
#{t('zigbee:ieee_address')}{t('zigbee:friendly_name')}{t('zigbee:channel')} 
{idx + 1}{ - devices[touchlinkDevice.ieee_address] ? - ({touchlinkDevice.ieee_address}) : touchlinkDevice.ieee_address}{devices[touchlinkDevice.ieee_address]?.friendly_name}{touchlinkDevice.channel} -
- disabled={touchlinkInProgress} item={touchlinkDevice} title={t('identify')} className="btn btn-primary" onClick={this.onIdentifyClick}> - disabled={touchlinkInProgress} item={touchlinkDevice} title={t('factory_reset')} className="btn btn-danger" onClick={this.onResetClick}> -
-
+ ); } diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 14c8cf117..4968d643c 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -375,7 +375,8 @@ "update_Home_assistant_entity_id": "Update Home Assistant entity ID", "zigbee_manufacturer": "Zigbee Manufacturer", "zigbee_model": "Zigbee Model", - "device": "Device" + "device": "Device", + "channel": "Channel" }, "scene": { "scene_id": "Scene ID", diff --git a/ws-messages/onTouchlink.json b/ws-messages/onTouchlink.json new file mode 100644 index 000000000..9eb6748ee --- /dev/null +++ b/ws-messages/onTouchlink.json @@ -0,0 +1,18 @@ +{ + "payload": { + "status": "ok", + "data": { + "found": [ + { + "ieee_address": "xxxxx", + "channel": 1 + }, + { + "ieee_address": "0x00124b001e73227f", + "channel": 10 + } + ] + } + }, + "topic": "bridge/response/touchlink/scan" +} \ No newline at end of file diff --git a/ws.js b/ws.js index 373fc94e6..b37082676 100644 --- a/ws.js +++ b/ws.js @@ -1,6 +1,6 @@ const WebSocket = require("ws"); const lineReader = require('line-reader'); - +const fs = require("fs"); const wss = new WebSocket.Server({ port: 8579, }); @@ -15,9 +15,10 @@ wss.on("connection", (ws) => { const msg = JSON.parse(message.data); switch (msg.topic) { case "bridge/request/networkmap": - lineReader.eachLine('./ws-messages/networkMapRequest.json', (line, last) => { - ws.send(line); - }); + ws.send(fs.readFileSync('./ws-messages/networkMapRequest.json', 'utf8')); + break; + case "bridge/request/touchlink/scan": + ws.send(fs.readFileSync('./ws-messages/onTouchlink.json', 'utf8')); break; default: break;