public IActionResult Device(string id)
        {
            id = Uri.UnescapeDataString(id);

            var device = _stateService.FindDeviceById(id, out var state);

            if (device == null)
            {
                return(NotFound());
            }

            // find route to coordinator
            var routeToCoordinator = new List <ZigbeeDevice>();
            var reachCoordinator   = false;

            DeviceDetailsViewModel vm = new DeviceDetailsViewModel.Builder
            {
                Device                = device,
                RouteToCoordinator    = routeToCoordinator.ToImmutableArray(),
                RouteReachCoordinator = reachCoordinator,
                BridgeState           = state
            };

            return(View(vm));
        }
        public IActionResult Device(string id)
        {
            id = Uri.UnescapeDataString(id);

            var device = _stateService.FindDeviceById(id, out var state);

            if (device == null)
            {
                return(NotFound());
            }

            // find route to coordinator
            var routeToCoordinator = new List <ZigbeeDevice>();
            //var parentDevice = device;
            var reachCoordinator = false;
            //while (parentDevice != null)
            //{
            //	if (routeToCoordinator.Any(d => d.ZigbeeId.Equals(parentDevice.ZigbeeId)))
            //	{
            //		break; // cyclic route
            //	}
            //	routeToCoordinator.Add(parentDevice);
            //	if (string.IsNullOrWhiteSpace(parentDevice.ZigbeeId))
            //	{
            //		break;
            //	}

            //	parentDevice = state.Devices.FirstOrDefault(d => d.ZigbeeId?.Equals(parentDevice.ParentZigbeeId) ?? false);
            //	if (parentDevice?.ZigbeeId.Equals(state.CoordinatorZigbeeId) ?? false)
            //	{
            //		reachCoordinator = true;
            //		break;
            //	}
            //}

            DeviceDetailsViewModel vm = new DeviceDetailsViewModel.Builder
            {
                Device                = device,
                RouteToCoordinator    = routeToCoordinator.ToImmutableArray(),
                RouteReachCoordinator = reachCoordinator,
                BridgeState           = state
            };

            return(View(vm));
        }